Class: Jets::TmpLoader
Class Method Summary
collapse
Instance Method Summary
collapse
#apigateway, #cfn, #lambda, #logs, #s3, #s3_resource, #sns, #sqs, #sts
#lookup, #stack_exists?, #stack_in_progress?
Constructor Details
#initialize(yaml_path = nil) ⇒ TmpLoader
Returns a new instance of TmpLoader.
9
10
11
12
13
14
|
# File 'lib/jets/tmp_loader.rb', line 9
def initialize(yaml_path=nil)
yaml_path ||= "#{Jets.root}handlers/data.yml"
@data = YAML.load_file(yaml_path)
@s3_bucket = @data['s3_bucket']
@rack_zip = @data['rack_zip']
end
|
Class Method Details
.load! ⇒ Object
5
6
7
|
# File 'lib/jets/tmp_loader.rb', line 5
def self.load!
new.load
end
|
Instance Method Details
#download(key, dest) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/jets/tmp_loader.rb', line 33
def download(key, dest)
s3.get_object(response_target: dest,
bucket: @s3_bucket,
key: key)
end
|
#download_and_extract(zip_file, folder_dest) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/jets/tmp_loader.rb', line 25
def download_and_extract(zip_file, folder_dest)
s3_key = "jets/code/#{zip_file}" download_path = "/tmp/#{zip_file}"
download(s3_key, download_path)
unzip(download_path, folder_dest)
end
|
#load ⇒ Object
16
17
18
|
# File 'lib/jets/tmp_loader.rb', line 16
def load
rack
end
|
#rack ⇒ Object
20
21
22
23
|
# File 'lib/jets/tmp_loader.rb', line 20
def rack
return unless @rack_zip
download_and_extract(@rack_zip, '/tmp/rack')
end
|
#sh(command) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/jets/tmp_loader.rb', line 45
def sh(command)
puts "=> #{command}"
success = system(command)
raise "Command #{command} failed" unless success
success
end
|
#unzip(zipfile, folder_dest) ⇒ Object
41
42
43
|
# File 'lib/jets/tmp_loader.rb', line 41
def unzip(zipfile, folder_dest)
sh "unzip -qo #{zipfile} -d #{folder_dest}"
end
|