The Require class provide access to REQUIRE file, and models the categorized list of project dependencies. In essence it is an array of Dependency objects.
Default file name to use when saving requirements to file.
File glob pattern to use to find a project’s requirements file.
File glob pattern to use to find a project’s requirements file. This returns the constant FILE_PATTERN value.
# File lib/pom/require.rb, line 24 def self.file_pattern FILE_PATTERN end
Find the first matching requirements file.
# File lib/pom/require.rb, line 29 def self.find(root) root = Pathname.new(root) root.glob(file_pattern, File::FNM_CASEFOLD).first end
New requirements class.
# File lib/pom/require.rb, line 41 def initialize(root, file=nil) @root = Pathname.new(root) @file = file || self.class.find(root) @dependencies = [] if @file && @file.exist? data = YAML.load(File.new(@file)) merge!(data) else warn "No REQUIRE file at #{root}" if $DEBUG end end
List of all development dependencies.
# File lib/pom/require.rb, line 72 def development dependencies.select{ |dep| dep.development? } end
Iterate over each dependency.
# File lib/pom/require.rb, line 56 def each(&block) dependencies.each(&block) end
Merge in another list of dependencies. This can by a Hash or another Require object.
# File lib/pom/require.rb, line 94 def merge!(data) data.each do |group, deps| deps.each do |pkg| dep = Dependency.new(pkg, group) @dependencies << dep end end @dependencies.uniq! end
List of required depenedencies. This works by removing all optional dependencies from the dependencies list.
# File lib/pom/require.rb, line 67 def requirements dependencies.reject{ |dep| dep.optional? } end
Save dependency list to file in YAML format.
# File lib/pom/require.rb, line 87 def save!(file=nil) file = file || self.file || DEFAULT_FILE File.open(file, 'w'){ |f| f << to_yaml } end
Generated with the Darkfish Rdoc Generator 2.