Class: Pgchief::Config::S3

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pgchief/config/s3.rb

Overview

Class to store s3 configuration settings

Constant Summary collapse

PREFIX_REGEX =
%r{\As3://(?<bucket>(\w|-)*)/(?<path>(\w|/|-)*/)\z}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ S3

Returns a new instance of S3.


22
23
24
# File 'lib/pgchief/config/s3.rb', line 22

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.


20
21
22
# File 'lib/pgchief/config/s3.rb', line 20

def config
  @config
end

Instance Method Details

#bucketObject


34
35
36
# File 'lib/pgchief/config/s3.rb', line 34

def bucket
  s3_match[:bucket]
end

#clientObject


26
27
28
29
30
31
32
# File 'lib/pgchief/config/s3.rb', line 26

def client
  @client ||= Aws::S3::Client.new(
    access_key_id: s3_key,
    secret_access_key: s3_secret,
    region: s3_region
  )
end

#configured?Boolean

Returns:

  • (Boolean)

42
43
44
45
46
47
48
49
# File 'lib/pgchief/config/s3.rb', line 42

def configured?
  [
    s3_key,
    s3_secret,
    s3_region,
    s3_objects_path
  ].none?(&:nil?)
end

#pathObject


38
39
40
# File 'lib/pgchief/config/s3.rb', line 38

def path
  s3_match[:path]
end