Sha256: 69d9e938f15a6b4a622b2a25da1008e9a5a5960dfb202761deea2b1c8174462d
Contents?: true
Size: 1.24 KB
Versions: 82
Compression:
Stored size: 1.24 KB
Contents
module Jets class TmpLoader include AwsServices def self.load! new.load end 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 def load rack end def rack return unless @rack_zip download_and_extract(@rack_zip, '/tmp/rack') end def download_and_extract(zip_file, folder_dest) s3_key = "jets/code/#{zip_file}" # jets/code/rack-checksum.zip download_path = "/tmp/#{zip_file}" # /tmp/rack-checksum.zip download(s3_key, download_path) unzip(download_path, folder_dest) end def download(key, dest) # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Client.html#get_object-instance_method # stream object directly to disk s3.get_object(response_target: dest, bucket: @s3_bucket, key: key) end def unzip(zipfile, folder_dest) sh "unzip -qo #{zipfile} -d #{folder_dest}" end def sh(command) puts "=> #{command}" success = system(command) raise "Command #{command} failed" unless success success end end end
Version data entries
82 entries across 82 versions & 3 rubygems
Version | Path |
---|---|
jets-1.6.3 | lib/jets/tmp_loader.rb |
jets-1.6.2 | lib/jets/tmp_loader.rb |