Class: Drunker::Source
- Inherits:
-
Object
- Object
- Drunker::Source
- Defined in:
- lib/drunker/source.rb
Instance Attribute Summary collapse
-
#target_files ⇒ Object
readonly
Returns the value of attribute target_files.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(target_dir, config:, logger:) ⇒ Source
constructor
A new instance of Source.
- #location ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(target_dir, config:, logger:) ⇒ Source
Returns a new instance of Source.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/drunker/source.rb', line 5 def initialize(target_dir, config:, logger:) = Time.now.to_i s3 = Aws::S3::Resource.new(client: Aws::S3::Client.new(config.)) @bucket = s3.create_bucket(bucket: "drunker-source-store-#{}") logger.info("Created source bucket: #{bucket.name}") @name = "drunker_source_#{}.zip" @target_files = [] @config = config @logger = logger set_target_files(target_dir) archive(target_dir) do |path| bucket.object(name).upload_file(path.to_s) logger.info("Uploaded source archive: #{location}") end @logger = logger end |
Instance Attribute Details
#target_files ⇒ Object (readonly)
Returns the value of attribute target_files.
3 4 5 |
# File 'lib/drunker/source.rb', line 3 def target_files @target_files end |
Instance Method Details
#delete ⇒ Object
35 36 37 38 |
# File 'lib/drunker/source.rb', line 35 def delete bucket.delete! logger.info("Deleted bucket: #{bucket.name}") end |
#location ⇒ Object
24 25 26 |
# File 'lib/drunker/source.rb', line 24 def location "#{bucket.name}/#{name}" end |
#to_h ⇒ Object
28 29 30 31 32 33 |
# File 'lib/drunker/source.rb', line 28 def to_h { type: "S3", location: location } end |