Class: Berkshelf::Installer
- Inherits:
-
Object
- Object
- Berkshelf::Installer
- Defined in:
- lib/berkshelf/installer.rb
Defined Under Namespace
Classes: Worker
Instance Attribute Summary collapse
-
#berksfile ⇒ Object
readonly
Returns the value of attribute berksfile.
-
#downloader ⇒ Object
readonly
Returns the value of attribute downloader.
-
#lockfile ⇒ Object
readonly
Returns the value of attribute lockfile.
Instance Method Summary collapse
- #build_universe ⇒ Object
-
#initialize(berksfile) ⇒ Installer
constructor
A new instance of Installer.
- #run ⇒ Array<Berkshelf::CachedCookbook>
Constructor Details
Instance Attribute Details
#berksfile ⇒ Object (readonly)
Returns the value of attribute berksfile.
5 6 7 |
# File 'lib/berkshelf/installer.rb', line 5 def berksfile @berksfile end |
#downloader ⇒ Object (readonly)
Returns the value of attribute downloader.
7 8 9 |
# File 'lib/berkshelf/installer.rb', line 7 def downloader @downloader end |
#lockfile ⇒ Object (readonly)
Returns the value of attribute lockfile.
6 7 8 |
# File 'lib/berkshelf/installer.rb', line 6 def lockfile @lockfile end |
Instance Method Details
#build_universe ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/berkshelf/installer.rb', line 16 def build_universe berksfile.sources.collect do |source| Thread.new do begin Berkshelf.formatter.msg("Fetching cookbook index from #{source.uri}...") source.build_universe rescue Berkshelf::APIClientError => ex Berkshelf.formatter.warn "Error retrieving universe from source: #{source}" Berkshelf.formatter.warn " * [#{ex.class}] #{ex}" end end end.map(&:join) end |
#run ⇒ Array<Berkshelf::CachedCookbook>
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/berkshelf/installer.rb', line 31 def run lockfile.reduce! Berkshelf.formatter.msg('Resolving cookbook dependencies...') dependencies, cookbooks = if lockfile.trusted? install_from_lockfile else install_from_universe end Berkshelf.log.debug " Finished resolving, calculating locks" to_lock = dependencies.select do |dependency| berksfile.has_dependency?(dependency) end Berkshelf.log.debug " New locks" to_lock.each do |lock| Berkshelf.log.debug " #{lock}" end lockfile.graph.update(cookbooks) lockfile.update(to_lock) lockfile.save cookbooks end |