lib/librarian/source/local.rb in librarian-0.0.20 vs lib/librarian/source/local.rb in librarian-0.0.21

- old
+ new

@@ -1,33 +1,47 @@ +require 'librarian/helpers/debug' require 'librarian/support/abstract_method' module Librarian module Source # Requires that the including source class have methods: # #path # #environment module Local + include Helpers::Debug include Support::AbstractMethod abstract_method :path - def manifests(dependency) - manifest = manifest_class.create(self, dependency, filesystem_path) + def manifests(name) + manifest = Manifest.new(self, name) [manifest].compact end def manifest(name, version, dependencies) - manifest = manifest_class.create(self, Dependency.new(name, nil, nil), filesystem_path) + manifest = Manifest.new(self, name) manifest.version = version manifest.dependencies = dependencies manifest end - def manifest_search_paths(dependency) - paths = [filesystem_path, filesystem_path.join(dependency.name)] + def manifest_search_paths(name) + paths = [filesystem_path, filesystem_path.join(name)] paths.select{|s| s.exist?} end + + def found_path(name) + @_found_paths ||= { } + @_found_paths[name] ||= begin + paths = manifest_search_paths(name) + paths.find{|p| manifest?(name, p)} + end + end + + private + + abstract_method :manifest? # (name, path) -> boolean end end end