Class: UploadRunner
Instance Attribute Summary collapse
-
#md_json ⇒ Object
readonly
Returns the value of attribute md_json.
Instance Method Summary collapse
-
#initialize(opts) ⇒ UploadRunner
constructor
A new instance of UploadRunner.
- #start ⇒ Object
- #upload(md_file) ⇒ Object
Methods included from Common
#banner, #box_metadata, #build_list, #builds_yml, #duration, #info, #macos?, #metadata_files, #private_box?, #unix?, #vc_account, #warn, #windows?
Constructor Details
#initialize(opts) ⇒ UploadRunner
Returns a new instance of UploadRunner.
8 9 10 |
# File 'lib/bento/upload.rb', line 8 def initialize(opts) @md_json = opts.md_json end |
Instance Attribute Details
#md_json ⇒ Object (readonly)
Returns the value of attribute md_json.
6 7 8 |
# File 'lib/bento/upload.rb', line 6 def md_json @md_json end |
Instance Method Details
#start ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bento/upload.rb', line 12 def start ("Starting uploads...") time = Benchmark.measure do files = md_json ? [md_json] : files.each do |md_file| upload(md_file) end end ("Uploads finished in #{duration(time.real)}.") end |
#upload(md_file) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/bento/upload.rb', line 23 def upload(md_file) puts "Attempting to upload #{md_file}" md = (md_file) box_desc = "a bento box for #{md['name']}" box = vc_account.ensure_box(md["name"], {short_description: box_desc, is_private: private_box?(md["name"])}) box_ver = box.ensure_version(md["version"], File.read(md_file)) if builds_yml["slugs"].value?(box.name) slug_desc = "a bento box for #{builds_yml['slugs'].key(box.name)}" slug = vc_account.ensure_box(builds_yml["slugs"].key(box.name), {short_description: slug_desc, is_private: false}) slug_ver = slug.ensure_version(md["version"], File.read(md_file)) end md["providers"].each do |k, v| provider = box_ver.ensure_provider(k, nil) ("Uploading #{box.name}/#{box_ver.version}/#{provider.name}...") provider.upload_file("builds/#{v['file']}") (provider.download_url.to_s) next unless builds_yml["slugs"].value?(box.name) slug_provider = slug_ver.ensure_provider(k, nil) ("Uploading #{slug.name}/#{slug_ver.version}/#{slug_provider.name}...") slug_provider.upload_file("builds/#{v['file']}") (slug_provider.download_url.to_s) end end |