Class: RedshiftETL::Config
- Inherits:
-
Object
- Object
- RedshiftETL::Config
- Defined in:
- lib/redshift_etl/config.rb
Instance Method Summary collapse
- #check! ⇒ Object
- #columns ⇒ Object
- #connection_string ⇒ Object
- #disabled? ⇒ Boolean
- #enabled? ⇒ Boolean
- #filename ⇒ Object
- #final_s3_path ⇒ Object
- #incremental_updates? ⇒ Boolean
-
#initialize(file_path) ⇒ Config
constructor
A new instance of Config.
- #primary_key ⇒ Object
- #query ⇒ Object
- #redshift_connection ⇒ Object
- #redshift_schema ⇒ Object
- #redshift_table ⇒ Object
- #s3 ⇒ Object
- #s3_access_key_id ⇒ Object
- #s3_bucket ⇒ Object
- #s3_bucket_name ⇒ Object
- #s3_region ⇒ Object
- #s3_secret_access_key ⇒ Object
- #table_name ⇒ Object
- #temp_s3_path ⇒ Object
- #update_timestamp_column ⇒ Object
Constructor Details
#initialize(file_path) ⇒ Config
Returns a new instance of Config.
10 11 12 13 14 15 16 |
# File 'lib/redshift_etl/config.rb', line 10 def initialize(file_path) fail "plz provide a file" if file_path.blank? @config = YAML.load(File.open(file_path)) rescue puts $! fail "Did you provide a valid YAML file?" end |
Instance Method Details
#check! ⇒ Object
94 95 96 97 98 |
# File 'lib/redshift_etl/config.rb', line 94 def check! fail "plz set AWS_SECRET_ACCESS_KEY" if s3_secret_access_key.blank? fail "plz set REDSHIFT_DATABASE_URL" if redshift_connection.blank? fail "plz set AWS_ACCESS_KEY_ID" if s3_access_key_id.blank? end |
#columns ⇒ Object
70 71 72 |
# File 'lib/redshift_etl/config.rb', line 70 def columns @config["columns"] end |
#connection_string ⇒ Object
54 55 56 |
# File 'lib/redshift_etl/config.rb', line 54 def connection_string @config["connection_string"] end |
#disabled? ⇒ Boolean
30 31 32 |
# File 'lib/redshift_etl/config.rb', line 30 def disabled? !enabled? end |
#enabled? ⇒ Boolean
26 27 28 |
# File 'lib/redshift_etl/config.rb', line 26 def enabled? @config["enabled"] end |
#filename ⇒ Object
58 59 60 |
# File 'lib/redshift_etl/config.rb', line 58 def filename @config["filename"] + '.csv' end |
#final_s3_path ⇒ Object
22 23 24 |
# File 'lib/redshift_etl/config.rb', line 22 def final_s3_path "files/#{redshift_schema}/#{redshift_table}/" end |
#incremental_updates? ⇒ Boolean
38 39 40 |
# File 'lib/redshift_etl/config.rb', line 38 def incremental_updates? @config["incremental_updates"] end |
#primary_key ⇒ Object
34 35 36 |
# File 'lib/redshift_etl/config.rb', line 34 def primary_key @config["primary_key"] end |
#query ⇒ Object
46 47 48 |
# File 'lib/redshift_etl/config.rb', line 46 def query @config["query"] end |
#redshift_connection ⇒ Object
74 75 76 |
# File 'lib/redshift_etl/config.rb', line 74 def redshift_connection ENV['REDSHIFT_DATABASE_URL'] end |
#redshift_schema ⇒ Object
66 67 68 |
# File 'lib/redshift_etl/config.rb', line 66 def redshift_schema @config["redshift_schema"] end |
#redshift_table ⇒ Object
62 63 64 |
# File 'lib/redshift_etl/config.rb', line 62 def redshift_table @config["redshift_table"] end |
#s3 ⇒ Object
100 101 102 |
# File 'lib/redshift_etl/config.rb', line 100 def s3 AWS::S3.new(access_key_id: s3_access_key_id, secret_access_key: s3_secret_access_key) end |
#s3_access_key_id ⇒ Object
78 79 80 |
# File 'lib/redshift_etl/config.rb', line 78 def s3_access_key_id ENV['AWS_ACCESS_KEY_ID'] end |
#s3_bucket ⇒ Object
104 105 106 |
# File 'lib/redshift_etl/config.rb', line 104 def s3_bucket s3.buckets[s3_bucket_name] end |
#s3_bucket_name ⇒ Object
90 91 92 |
# File 'lib/redshift_etl/config.rb', line 90 def s3_bucket_name "tanga-redshift" end |
#s3_region ⇒ Object
86 87 88 |
# File 'lib/redshift_etl/config.rb', line 86 def s3_region "us-east-1" end |
#s3_secret_access_key ⇒ Object
82 83 84 |
# File 'lib/redshift_etl/config.rb', line 82 def s3_secret_access_key ENV['AWS_SECRET_ACCESS_KEY'] end |
#table_name ⇒ Object
50 51 52 |
# File 'lib/redshift_etl/config.rb', line 50 def table_name @config["table_name"] end |
#temp_s3_path ⇒ Object
18 19 20 |
# File 'lib/redshift_etl/config.rb', line 18 def temp_s3_path "tmp/#{redshift_schema}/#{redshift_table}/#{temp_key}/" end |
#update_timestamp_column ⇒ Object
42 43 44 |
# File 'lib/redshift_etl/config.rb', line 42 def @config["update_timestamp_column"] end |