Class: Berkshelf::Uploader
- Inherits:
-
Object
- Object
- Berkshelf::Uploader
- Defined in:
- lib/berkshelf/uploader.rb
Instance Attribute Summary collapse
-
#berksfile ⇒ Object
readonly
Returns the value of attribute berksfile.
-
#lockfile ⇒ Object
readonly
Returns the value of attribute lockfile.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(berksfile, *args) ⇒ Uploader
constructor
A new instance of Uploader.
- #run ⇒ Object
Constructor Details
#initialize(berksfile, *args) ⇒ Uploader
Returns a new instance of Uploader.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/berkshelf/uploader.rb', line 8 def initialize(berksfile, *args) @berksfile = berksfile @lockfile = berksfile.lockfile opts = args.last.respond_to?(:to_hash) ? args.pop.to_hash.symbolize_keys : {} @options = { force: false, freeze: true, halt_on_frozen: false, validate: true, }.merge(opts) @names = Array(args).flatten end |
Instance Attribute Details
#berksfile ⇒ Object (readonly)
Returns the value of attribute berksfile.
3 4 5 |
# File 'lib/berkshelf/uploader.rb', line 3 def berksfile @berksfile end |
#lockfile ⇒ Object (readonly)
Returns the value of attribute lockfile.
4 5 6 |
# File 'lib/berkshelf/uploader.rb', line 4 def lockfile @lockfile end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
6 7 8 |
# File 'lib/berkshelf/uploader.rb', line 6 def names @names end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/berkshelf/uploader.rb', line 5 def @options end |
Instance Method Details
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/berkshelf/uploader.rb', line 23 def run Berkshelf.log.info "Uploading cookbooks" cookbooks = if names.empty? Berkshelf.log.debug " No names given, using all cookbooks" filtered_cookbooks else Berkshelf.log.debug " Names given (#{names.join(', ')})" names.map { |name| lockfile.retrieve(name) } end # Perform all validations first to prevent partially uploaded cookbooks Validator.validate_files(cookbooks) upload(cookbooks) cookbooks end |