Class: ConfigureS3Website::FileConfigSource

Inherits:
ConfigSource show all
Defined in:
lib/configure-s3-website/config_source/file_config_source.rb

Instance Method Summary collapse

Constructor Details

#initialize(yaml_file_path) ⇒ FileConfigSource

Returns a new instance of FileConfigSource.



6
7
8
9
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 6

def initialize(yaml_file_path)
  @yaml_file_path = yaml_file_path
  @config = FileConfigSource.parse_config yaml_file_path
end

Instance Method Details

#cloudfront_distribution_configObject



52
53
54
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 52

def cloudfront_distribution_config
  @config['cloudfront_distribution_config']
end

#cloudfront_distribution_idObject



56
57
58
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 56

def cloudfront_distribution_id
  @config['cloudfront_distribution_id']
end

#cloudfront_distribution_id=(dist_id) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 60

def cloudfront_distribution_id=(dist_id)
  @config['cloudfront_distribution_id'] = dist_id
  file_contents = File.open(@yaml_file_path).read
  File.open(@yaml_file_path, 'w') do |file|
    result = file_contents.gsub(
      /(s3_bucket:.*$)/,
      "\\1\ncloudfront_distribution_id: #{dist_id}"
    )
    file.write result
  end
end

#descriptionObject



11
12
13
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 11

def description
  @yaml_file_path
end

#error_documentObject



48
49
50
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 48

def error_document
  @config['error_document']
end

#index_documentObject



44
45
46
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 44

def index_document
  @config['index_document']
end

#profileObject



23
24
25
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 23

def profile
  @config['profile']
end

#routing_rulesObject



40
41
42
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 40

def routing_rules
  @config['routing_rules']
end

#s3_access_key_idObject



15
16
17
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 15

def s3_access_key_id
  @config['s3_id']
end

#s3_bucket_nameObject



27
28
29
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 27

def s3_bucket_name
  @config['s3_bucket']
end

#s3_endpointObject



31
32
33
34
35
36
37
38
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 31

def s3_endpoint
  endpoint = @config['s3_endpoint'] || 'us-east-1'
  if endpoint == 'EU'
    'eu-west-1'
  else
    endpoint
  end
end

#s3_secret_access_keyObject



19
20
21
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 19

def s3_secret_access_key
  @config['s3_secret']
end