Class: Gfid::Manager
Instance Attribute Summary collapse
-
#dependency_gems ⇒ Object
readonly
Returns the value of attribute dependency_gems.
-
#gems ⇒ Object
readonly
Returns the value of attribute gems.
Instance Method Summary collapse
- #clear! ⇒ Object
- #collect_gems ⇒ Object
- #download! ⇒ Object
- #gem_name(name, version = nil) ⇒ Object
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
Constructor Details
#initialize ⇒ Manager
Returns a new instance of Manager.
7 8 9 10 |
# File 'lib/gfid/manager.rb', line 7 def initialize @gems = [] @dependency_gems = [] end |
Instance Attribute Details
#dependency_gems ⇒ Object (readonly)
Returns the value of attribute dependency_gems.
6 7 8 |
# File 'lib/gfid/manager.rb', line 6 def dependency_gems @dependency_gems end |
#gems ⇒ Object (readonly)
Returns the value of attribute gems.
6 7 8 |
# File 'lib/gfid/manager.rb', line 6 def gems @gems end |
Instance Method Details
#clear! ⇒ Object
40 41 42 43 |
# File 'lib/gfid/manager.rb', line 40 def clear! @gems = [] @dependency_gems = [] end |
#collect_gems ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gfid/manager.rb', line 18 def collect_gems while !dependency_gems.empty? next_dependency_gems = [] dependency_gems.flatten.each do |gem| @gems << gem gem.ask_dependencies.each do |dependency_gem| next_dependency_gems << dependency_gem if !next_dependency_gems.map { |g| g.name }.include?(dependency_gem.name) end end @dependency_gems = next_dependency_gems end gems end |
#download! ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/gfid/manager.rb', line 32 def download! collect_gems.each do |gem| open(gem.filename, "wb") do |file| file.write gem.download!.body end end end |