Class: Berkshelf::Installer::Worker
- Inherits:
-
Object
- Object
- Berkshelf::Installer::Worker
- Defined in:
- lib/berkshelf/installer.rb
Instance Attribute Summary collapse
-
#berksfile ⇒ Object
readonly
Returns the value of attribute berksfile.
-
#downloader ⇒ Object
readonly
Returns the value of attribute downloader.
Instance Method Summary collapse
-
#initialize(berksfile) ⇒ Worker
constructor
A new instance of Worker.
-
#install(dependency) ⇒ CachedCookbook
Install a specific dependency.
Constructor Details
#initialize(berksfile) ⇒ Worker
Returns a new instance of Worker.
73 74 75 76 |
# File 'lib/berkshelf/installer.rb', line 73 def initialize(berksfile) @berksfile = berksfile @downloader = Downloader.new(berksfile) end |
Instance Attribute Details
#berksfile ⇒ Object (readonly)
Returns the value of attribute berksfile.
70 71 72 |
# File 'lib/berkshelf/installer.rb', line 70 def berksfile @berksfile end |
#downloader ⇒ Object (readonly)
Returns the value of attribute downloader.
71 72 73 |
# File 'lib/berkshelf/installer.rb', line 71 def downloader @downloader end |
Instance Method Details
#install(dependency) ⇒ CachedCookbook
Install a specific dependency.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/berkshelf/installer.rb', line 84 def install(dependency) Berkshelf.log.info "Installing #{dependency}" if dependency.installed? Berkshelf.log.debug " Already installed - skipping install" Berkshelf.formatter.use(dependency) dependency.cached_cookbook else name, version = dependency.name, dependency.locked_version.to_s source = berksfile.source_for(name, version) # Raise error if our Berksfile.lock has cookbook versions that # can't be found in sources raise MissingLockfileCookbookVersion.new(name, version, "in any of the sources") unless source Berkshelf.log.debug " Downloading #{dependency.name} (#{dependency.locked_version}) from #{source}" cookbook = source.cookbook(name, version) Berkshelf.log.debug " => #{cookbook.inspect}" Berkshelf.formatter.install(source, cookbook) downloader.download(name, version) do |stash| CookbookStore.import(name, version, stash) end end end |