Parent

Files

POM::Metadir

Metadata

Constants

FILE_PATTERN

Extra metadata can be stored in meta/ or .meta/.

PROFILE_OMIT
RE_EMAIL

Attributes

api[RW]

Location of API documentation.

authors[RW]

List of authors. :attr_accessor: authors

blog[RW]

Resource to project blog.

codename[RW]

Code name of the release (eg. Woody)

collection[RW]
conflicts[RW]

With what other packages does this package conflict. :attr_accessor: conflicts

consider[RW]

Abirtary information, especially about what might be needed to use or build or use this package that does not fit under requires. This is strictly information for the end-user to consider, eg. “Needs gcc 4.4+” or “Needs fast graphics card”.

contact[RW]

Contact can be any sort of resource that is intended to be the end-users initial point of contact. It could be the url to a mailing list, or a url to a forum, or the email address of the maintainer, etc.

created[RW]

The date the project was started.

default=[RW]

Load path(s) (used by Ruby’s own site loading and RubyGems). The default is ‘lib/’, which is usually correct. :attr_accessor: loadpath

description[RW]

Detailed description. Aliased as abstract.

development[RW]

Location of development site.

distribute[RW]

Package distribution service webpage.

documentation[RW]

Location of documentation.

download[RW]

Downloadable packages.

executables[RW]

Executables default to the contents of bin/.

extensions[RW]

List of extension configuration scripts. These are used to compile the extensions.

externals[RW]

External requirements, outside of the normal packaging system. :attr_accessor: externals

forum[RW]

User discussion forum.

homepage[RW]

Offical project website.

irc[RW]

IRC channel

issues[RW]

Location of issue tracker.

license[RW]

License.

loadpath[RW]

Load path(s) (used by Ruby’s own site loading and RubyGems). The default is ‘lib/’, which is usually correct. :attr_accessor: loadpath

mailinglist[RW]

Mailing list email or web address to online version.

maintainer[RW]

Maintainer. This is the package maintainers name and optionally their email addresses, eg. “Trans <trans@foo.com>”.

name[RW]

Project’s package name. The entry is required and must not contain spaces or puncuation.

platforms[RW]

Platforms this project/package supports (nil for universal).

provides[RW]

What other package(s) does this package provide the same dependency fulfilment. For example, a package ‘bar-plus’ might fulfill the same dependency criteria as package ‘bar’, so ‘bar-plus’ is said to provide ‘bar’. :attr_accessor: provides

recommend[RW]

What other packages should be used with this package. :attr_accessor: recommend

released[RW]

Date this version was released.

replaces[RW]

What other packages does this package replace. This is very much like provides but expresses a closser relation. For instance “libXML” has been replaced by “libXML2”. :attr_accessor: replaces

repository[RW]

Resource for central public repository, e.g.

git://github.com/protuils/pom.git
requires[RW]

What other packages must this package have in order to function. This includes any requirements neccessary for installation. :attr_accessor: requries

source[RW]

Browse source code.

status[RW]

Current status (stable, beta, alpha, rc1, etc.) DEPRECATE: Should be indicated by trailing letter on version number?

suggest[RW]

What other packages could be useful with this package. :attr_accessor: suggest

suite[RW]

Name of the user-account or master-project to which this project belongs. The suite name defaults to the project name if no entry is given. This is also aliased as collection.

summary[RW]

A one-line brief description.

support[RW]

Location of support forum.

title[RW]

Title of package (this defaults to project name capitalized).

version[RW]

Current version of the project. Should be a dot separated string. Eg. “1.0.0”.

wiki[RW]

Location of wiki-wiki.

Public Class Methods

file_pattern() click to toggle source
# File lib/pom/metadir.rb, line 20
def self.file_pattern
  FILE_PATTERN
end
find(root) click to toggle source
# File lib/pom/metadir.rb, line 25
def self.find(root)
  root = Pathname.new(root)
  root.glob(file_pattern).select{ |f| f.directory? }.first
end
load(root=Dir.pwd) click to toggle source

Like new but reads all metadata into memory.

# File lib/pom/metadir.rb, line 39
def self.load(root=Dir.pwd)
  o = new(root)
  o.load!
  o
end
new(root=nil, prime={}) click to toggle source
# File lib/pom/metadir.rb, line 81
def initialize(root=nil, prime={})
  if root
    @root  = Pathname.new(root)
    @store = self.class.find(root)
    super(@root, @store)
    #super(nil, @root + 'meta', @root + '.meta')
    @data = prime
    initialize_preload
  else
    super(nil, *stores)
  end
  #load!
end
new_project(root=Dir.pwd) click to toggle source

If creating new metadata from scratch, use this to prefill entries to new project defaults.

# File lib/pom/metadir.rb, line 48
def self.new_project(root=Dir.pwd)
  prime = { 
    'name'       => File.basename(root),
    'version'    => '0.0.0',
    'requires'   => [],
    'summary'    => "FIX: brief one line description here",
    'contact'    => "FIX: name <email> or uri",
    'authors'    => "FIX: names of authors here",
    'repository' => "FIX: master public repo uri"
  }
  o = new(root, prime)
  if path = new_project_config
    o.load!(path)
  end
  return o
end
new_project_config() click to toggle source

Load per-user config values for a new project. This is used by the ‘pom init’ command.

# File lib/pom/metadir.rb, line 68
def self.new_project_config
  new_project_defaults.each do |name, value|
    self[name] = value
  end
  home_config = ENV['XDG_CONFIG_HOME'] || '~/.config'
  store = stores.find{ |s| s[0,1] != '.' }  # not hidden
  path  = Pathname.new(File.join(home_config, 'pom', store))
  path.exist? ? path : nil
end

Public Instance Methods

assert_valid() click to toggle source

Assert that the mininal information if provided.

# File lib/pom/metadir.rb, line 396
def assert_valid
  raise ValidationError, "no name"    unless name
  raise ValidationError, "no version" unless version
  raise ValidationError, "no summary" unless summary
  #raise ValidationError, "no maintainer" unless maintainer
  #raise ValidationError, "no homepage"   unless homepage
end
author() click to toggle source

Returns the first entry in the authors list.

# File lib/pom/metadir.rb, line 334
def author
  authors.first
end
author=(name) click to toggle source
# File lib/pom/metadir.rb, line 379
def author=(name)
  authors.unshift(name).uniq!
end
backup!(chroot=nil) click to toggle source

Backup current metadata files to .cache/pom/.

# File lib/pom/metadir.rb, line 473
def backup!(chroot=nil)
  self.root = chroot if chroot
  return unless stores.any?{ |dir| File.exist?(dir) }
  FileUtils.mkdir_p(cache) unless File.exist?(cache)
  stores.each do |store|
    temp, $DEBUG = $DEBUG, false
    FileUtils.cp_r(store, cache) if File.exist?(store)
    $DEBUG = temp
  end
  return cache
end
cache() click to toggle source

Backup directory.

# File lib/pom/metadir.rb, line 467
def cache
  root + '.cache/pom'
end
email() click to toggle source

Contact’s email address.

# File lib/pom/metadir.rb, line 325
def email
  if md = RE_EMAIL.match(contact.to_s)
    md[0]
  else
    nil
  end
end
load!(path=nil) click to toggle source

Load metadata from the .meta and/or meta directories.

# File lib/pom/metadir.rb, line 124
def load!(path=nil)
  if path
    super(path)
  else
    if root
      #load_version_stamp
      super
    end
  end
  self
end
name=(entry) click to toggle source

Name assignment. The entry must not contain spaces or puncuation.

# File lib/pom/metadir.rb, line 363
def name=(entry)
  raise ValidationError, "invalid name -- #{n}" unless /^[\w-]+$/ =~ entry
  self['name'] = entry
end
package_name(buildno=nil) click to toggle source

Package name is generally in the form of name-version, or name-version-platform if platform is specified.

TODO: Improve buildno support ?

# File lib/pom/metadir.rb, line 342
def package_name(buildno=nil)
  if buildno
    buildno = Time.now.strftime("%H*60+%M")
    versnum = "#{version}.#{buildno}"
  else
    versnum = version
  end

  if platform
    "#{name}-#{versnum}-#{platform}"
  else
    "#{name}-#{versnum}"
  end
end
Also aliased as: stage_name
released=(date) click to toggle source
# File lib/pom/metadir.rb, line 374
def released=(date)
  self['released'] = Time.parse(date.strip) if date
end
root() click to toggle source

Project root directory.

# File lib/pom/metadir.rb, line 106
def root
  @root
end
root=(dir) click to toggle source

Change the root location if dir.

# File lib/pom/metadir.rb, line 118
def root=(dir) 
  @root = Pathname.new(dir)
  #@paths = [@root + 'meta', @root + '.meta']
end
save!(chroot=nil) click to toggle source

Save metadata to meta/ directory (or .meta/ if it is found).

# File lib/pom/metadir.rb, line 486
def save!(chroot=nil)
  self.root = chroot if chroot
  super
end
stage_name(buildno=nil) click to toggle source
Alias for: package_name
store() click to toggle source

Storage locations for metadata. POM supports the use of meta and the hidden .meta.

# File lib/pom/metadir.rb, line 113
def store
  @store
end
summary=(line) click to toggle source

Limit summary to 69 characters.

# File lib/pom/metadir.rb, line 369
def summary=(line)
  self['summary'] = line.to_s[0..69]
end
to_package() click to toggle source

For upgrading to new system.

# File lib/pom/metadir.rb, line 492
def to_package
  package = Package.new(root)
  package.name    = name
  package.version = version
  package.date    = released
  package.path    = loadpath
  package
end
to_profile() click to toggle source

For upgrading to new system.

# File lib/pom/metadir.rb, line 504
def to_profile
  #load!
  profile = Profile.new(root, name)
  to_h.each do |k,v|
    next if PROFILE_OMIT.include?(k.to_s)
    profile.__send__("#{k}=", v)
  end
  profile.resources.homepage = homepage
  profile.resources.repository = repository
  profile
end
to_require() click to toggle source
# File lib/pom/metadir.rb, line 517
def to_require
  req = {}
  req['runtime']             = requires  unless requires.empty?
  req['runtime/recommend']   = recommend unless recommend.empty?
  req['runtime/optional']    = suggest   unless suggest.empty?
  req['alternate/conflict']  = conflicts unless conflicts.empty?
  req['alternate/provision'] = provides  unless provides.empty?
  req['alternate/replace']   = replaces  unless replaces.empty?
  r = Require.new(root)
  r.merge!(req)
  r
end
to_s() click to toggle source

Provide a summary text of project’s metadata.

# File lib/pom/metadir.rb, line 407
def to_s
  s = []
  s << "#{title} v#{version}"
  s << ""
  s << "#{summary}"
  s << ""
  s << "contact    : #{contact}"
  s << "homepage   : #{homepage}"
  s << "repository : #{repository}"
  s << "authors    : #{authors.join(',')}"
  s << "package    : #{name}-#{version}"
  s << "requires   : #{requires.join(',')}"
  s.join("\n")
end
valid?() click to toggle source

Is the minimal information provided?

# File lib/pom/metadir.rb, line 386
def valid?
  return false unless name
  return false unless version
  return false unless summary
  #return false unless maintainer
  #return false unless homepage
  true
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.