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.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/berkshelf/uploader.rb', line 13 def initialize(berksfile, *args) @berksfile = berksfile @lockfile = berksfile.lockfile opts = args.last.respond_to?(:to_hash) ? args.pop.to_hash.each_with_object({}) { |(k, v), m| m[k.to_sym] = v } : {} @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.
8 9 10 |
# File 'lib/berkshelf/uploader.rb', line 8 def berksfile @berksfile end |
#lockfile ⇒ Object (readonly)
Returns the value of attribute lockfile.
9 10 11 |
# File 'lib/berkshelf/uploader.rb', line 9 def lockfile @lockfile end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
11 12 13 |
# File 'lib/berkshelf/uploader.rb', line 11 def names @names end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/berkshelf/uploader.rb', line 10 def @options end |
Instance Method Details
#run ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/berkshelf/uploader.rb', line 28 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 |