Sha256: 7d46b0e924ac7b0d991562cdff75b154a83c4f362471f74bb035afbdab465ab8
Contents?: true
Size: 1014 Bytes
Versions: 1
Compression:
Stored size: 1014 Bytes
Contents
require 'yaml' require 'erb' module ConfigureS3Website class FileConfigSource < ConfigSource def initialize(yaml_file_path) @config = parse_config yaml_file_path end def s3_access_key_id @config['s3_id'] end def s3_secret_access_key @config['s3_secret'] end def s3_bucket_name @config['s3_bucket'] end def s3_endpoint @config['s3_endpoint'] end def routing_rules @config['routing_rules'] end private def parse_config(yaml_file_path) config = YAML.load(ERB.new(File.read(yaml_file_path)).result) validate_config(config, yaml_file_path) config end def validate_config(config, yaml_file_path) required_keys = %w{s3_id s3_secret s3_bucket} missing_keys = required_keys.reject do |key| config.keys.include?key end unless missing_keys.empty? raise "File #{yaml_file_path} does not contain the required key(s) #{missing_keys.join(', ')}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
configure-s3-website-1.2.0 | lib/configure-s3-website/config_source/file_config_source.rb |