Class: Menu::Release
- Inherits:
-
Object
- Object
- Menu::Release
- Defined in:
- lib/menu/release.rb
Instance Attribute Summary collapse
-
#beta ⇒ Object
Returns the value of attribute beta.
-
#md5 ⇒ Object
Returns the value of attribute md5.
-
#options ⇒ Object
Returns the value of attribute options.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #<=>(o) ⇒ Object
-
#initialize(hash = {}) ⇒ Release
constructor
A new instance of Release.
- #payload_file=(file) ⇒ Object
- #to_json(s) ⇒ Object
- #upload_payload ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Release
Returns a new instance of Release.
8 9 10 11 12 13 |
# File 'lib/menu/release.rb', line 8 def initialize hash={} @version = hash['version'] @md5 = hash['md5'] @payload = hash['payload'] @beta = hash['beta'] end |
Instance Attribute Details
#beta ⇒ Object
Returns the value of attribute beta.
6 7 8 |
# File 'lib/menu/release.rb', line 6 def beta @beta end |
#md5 ⇒ Object
Returns the value of attribute md5.
6 7 8 |
# File 'lib/menu/release.rb', line 6 def md5 @md5 end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/menu/release.rb', line 5 def @options end |
#payload ⇒ Object
Returns the value of attribute payload.
6 7 8 |
# File 'lib/menu/release.rb', line 6 def payload @payload end |
#version ⇒ Object
Returns the value of attribute version.
6 7 8 |
# File 'lib/menu/release.rb', line 6 def version @version end |
Instance Method Details
#<=>(o) ⇒ Object
15 16 17 |
# File 'lib/menu/release.rb', line 15 def <=> o version <=> o.version end |
#payload_file=(file) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/menu/release.rb', line 33 def payload_file= file unless File.exists? file puts "Could not open payload" exit 1 end @payload_file = file puts "Calcuating checksum..." if @options.verbose @md5 = Digest::MD5.file(file).hexdigest puts "Checksum: "+ @md5 end |
#to_json(s) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/menu/release.rb', line 44 def to_json s { version: @version, beta: @beta, payload: @payload, md5: @md5 }.to_json end |
#upload_payload ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/menu/release.rb', line 19 def upload_payload s3 = Aws::S3::Client.new(region: 'us-east-1') key = "#{.component}/v#{@version}-#{@md5}#{File.extname(@payload_file)}" puts "Uploading payload (#{key}) to S3..." if @options.verbose s3.put_object( acl: "public-read", body: File.open(@payload_file), bucket: @options.bucket, key: key ) puts "Upload complete." if @options.verbose @payload = ENV['MENU_SSL_URL'] + '/' + key end |