Class: Configuration::S3

Inherits:
Object
  • Object
show all
Includes:
ClassLogging
Defined in:
lib/httpimagestore/configuration/s3.rb

Class Method Summary collapse

Class Method Details

.match(node) ⇒ Object



38
39
40
# File 'lib/httpimagestore/configuration/s3.rb', line 38

def self.match(node)
  node.name == 's3'
end

.parse(configuration, node) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/httpimagestore/configuration/s3.rb', line 42

def self.parse(configuration, node)
  configuration.s3 and raise StatementCollisionError.new(node, 's3')

  node.grab_values
  node.required_attributes('key', 'secret')
  node.valid_attribute_values('ssl', true, false, nil)

  key, secret, ssl = node.grab_attributes('key', 'secret', 'ssl')
  ssl = true if ssl.nil?

  configuration.s3 = AWS::S3.new(
    access_key_id: key,
    secret_access_key: secret,
    logger: logger_for(AWS::S3),
    log_level: :debug,
    use_ssl: ssl
  )

  log.info "S3 client using '#{key}' key and #{ssl ? 'HTTPS' : 'HTTP'} connections"
end