lib/indexer/metadata.rb in indexer-0.1.0 vs lib/indexer/metadata.rb in indexer-0.2.0

- old
+ new

@@ -49,11 +49,11 @@ def self.revise(data) Revision.upconvert(data) end # - # Create a new Meta::Spec given a Gem::Specification or .gemspec file. + # Create a new Metadata instance given a Gem::Specification or .gemspec file. # # @param [Gem::Specification,String] gemspec # RubyGems Gem::Specification object or path to .gemspec file. # def self.from_gemspec(gemspec) @@ -317,21 +317,24 @@ alias :companies :organizations= alias :companies= :organizations= # TODO: should we warn if directory does not exist? - # Sets the require paths of the project. + # Sets the named paths of the project. # - # @param [Array<String>, String] paths - # The require-paths or a glob-pattern. + # @param [Hash[String]=Array<String>] path_map + # Mappaing of names to list of paths. # - def load_path=(paths) - @data[:load_path] = \ - Array(paths).map do |path| - Valid.path!(path) - path + def paths=(path_map) + @data[:paths] = \ + map = {} + path_map = path_map.to_hash if path_map.respond_to?(:to_hash) + Valid.hash!(path_map) + path_map.each do |name, paths| + map[name.to_s] = Array(paths).map{ |path| Valid.path!(path) } end + map end # List of language engine/version family supported. def engines=(value) @data[:engines] = ( @@ -533,10 +536,24 @@ #end # -- Utility Methods ---------------------------------------------------- # + # Legacy method to common Ruby path via `paths['load']`. + # + def load_path + paths['load'] + end + + # + # Legacy method to set `paths['load']`. + # + def load_path=(path) + paths['load'] = Array(path).map{ |path| Valid.path!(path) } + end + + # # Adds a new requirement. # # @param [String] name # The name of the requirement. # @@ -597,10 +614,10 @@ return false unless name return false unless version true end -# TODO: What was used for again, load_path ? +# TODO: What was used for again, load path ? =begin # # Iterates over the paths. # # @param [Array<String>, String] paths