Class: Dep
Defined Under Namespace
Classes: Dependency
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #filter(environment) ⇒ Object
-
#initialize(dependencies) ⇒ Dep
constructor
A new instance of Dep.
- #require(environment) ⇒ Object
Constructor Details
#initialize(dependencies) ⇒ Dep
Returns a new instance of Dep.
61 62 63 64 65 66 67 68 69 |
# File 'lib/dependencies/dep.rb', line 61 def initialize(dependencies) @dependencies = [] @missing = [] dependencies.each_line do |line| next unless line =~ /^([\w\-_]+) ?([<~=> \d\.]+)?(?: \(([\w, ]+)\))?(?: ([a-z]+:\/\/.+?))?$/ @dependencies << Dependency.new($1, $2, $3, $4) end end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
59 60 61 |
# File 'lib/dependencies/dep.rb', line 59 def dependencies @dependencies end |
Instance Method Details
#each(&block) ⇒ Object
97 98 99 |
# File 'lib/dependencies/dep.rb', line 97 def each(&block) @dependencies.each(&block) end |
#filter(environment) ⇒ Object
71 72 73 74 75 |
# File 'lib/dependencies/dep.rb', line 71 def filter(environment) @dependencies.select do |dep| dep.for_environment?(environment) end end |
#require(environment) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/dependencies/dep.rb', line 77 def require(environment) filter(environment).each do |dep| @missing << dep unless dep.require end if !@missing.empty? $stderr.puts "\nMissing dependencies:\n\n" @missing.each do |dep| $stderr.puts " #{dep}" end $stderr.puts $stderr.puts "Run `dep list` to view missing dependencies or `dep vendor --all` if you want to vendor them.\n\n" exit(1) end $:.unshift File.("lib") end |