Class: Menu::Release

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#betaObject

Returns the value of attribute beta.



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

def beta
  @beta
end

#md5Object

Returns the value of attribute md5.



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

def md5
  @md5
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

#payloadObject

Returns the value of attribute payload.



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

def payload
  @payload
end

#versionObject

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_payloadObject



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 = "#{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