Maintainer. This is the package maintainers name and optionally their email addresses, eg. “Trans <trans@foo.com>”.
MetaStore
Extra metadata can be stored in meta/ or .meta/.
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 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.
Load path(s) (used by Ruby’s own site loading and RubyGems). The default is ‘lib/’, which is usually correct. :attr_accessor: loadpath
External requirements, outside of the normal packaging system. :attr_accessor: externals
Load path(s) (used by Ruby’s own site loading and RubyGems). The default is ‘lib/’, which is usually correct. :attr_accessor: loadpath
Maintainer. This is the package maintainers name and optionally their email addresses, eg. “Trans <trans@foo.com>”.
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
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
What other packages must this package have in order to function. This includes any requirements neccessary for installation. :attr_accessor: requries
Current status (stable, beta, alpha, rc1, etc.) DEPRECATE: Should be indicated by trailing letter on version number?
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.
# File lib/pom/metadir.rb, line 20 def self.file_pattern FILE_PATTERN end
# 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
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
# 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
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
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
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
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
Backup directory.
# File lib/pom/metadir.rb, line 467 def cache root + '.cache/pom' end
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 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 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 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
# File lib/pom/metadir.rb, line 374 def released=(date) self['released'] = Time.parse(date.strip) if date end
Project root directory.
# File lib/pom/metadir.rb, line 106 def root @root end
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 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
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
Limit summary to 69 characters.
# File lib/pom/metadir.rb, line 369 def summary=(line) self['summary'] = line.to_s[0..69] end
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
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
# 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
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
Generated with the Darkfish Rdoc Generator 2.