class Menu::Release

Attributes

beta[RW]
md5[RW]
options[RW]
payload[RW]
version[RW]

Public Class Methods

new(hash={}) click to toggle source
# File lib/menu/release.rb, line 8
def initialize hash={}
  @version = hash['version']
  @md5 = hash['md5']
  @payload = hash['payload']
  @beta = hash['beta']
end

Public Instance Methods

<=>(o) click to toggle source
# File lib/menu/release.rb, line 15
def <=> o
  version <=> o.version
end
payload_file=(file) click to toggle source
# 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) click to toggle source
# File lib/menu/release.rb, line 44
def to_json s
  {
    version: @version,
    beta: @beta,
    payload: @payload,
    md5: @md5
  }.to_json
end
upload_payload() click to toggle source
# File lib/menu/release.rb, line 19
def upload_payload
  s3 = Aws::S3::Client.new(region: 'us-east-1')
  key = "#{options.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