Class: Menu::Release

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/menu/release.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/menu/release.rb', line 5

def options
  @options
end

Instance Method Details

#<=>(o) ⇒ Object



7
8
9
# File 'lib/menu/release.rb', line 7

def <=> o
  version <=> o.version
end

#payload_file=(file) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/menu/release.rb', line 25

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
  @md5 = md5
  puts "Checksum: "+ md5
end

#to_json(s) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/menu/release.rb', line 37

def to_json s
  {
    version: version,
    beta: beta,
    payload: payload,
    md5: md5
  }.to_json
end

#upload_payloadObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/menu/release.rb', line 11

def upload_payload
  s3 = Aws::S3::Client.new(region: 'us-east-1')
  key = "#{options.component}/v#{self.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
  self.payload = ENV['MENU_SSL_URL'] + '/' + key
end