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



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

def cloudfront_distribution_config
  @config['cloudfront_distribution_config']
end

#cloudfront_distribution_idObject



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

def cloudfront_distribution_id
  @config['cloudfront_distribution_id']
end

#cloudfront_distribution_id=(dist_id) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 51

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



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

def error_document
  @config['error_document']
end

#index_documentObject



35
36
37
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 35

def index_document
  @config['index_document']
end

#routing_rulesObject



31
32
33
# File 'lib/configure-s3-website/config_source/file_config_source.rb', line 31

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



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

def s3_bucket_name
  @config['s3_bucket']
end

#s3_endpointObject



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

def s3_endpoint
  @config['s3_endpoint']
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