Class: AffiliateWindow::ETL::Config
- Inherits:
-
Object
- Object
- AffiliateWindow::ETL::Config
- Defined in:
- lib/affiliate_window/etl/config.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
Instance Method Summary collapse
- #account_id ⇒ Object
- #affiliate_api_password ⇒ Object
- #database_url ⇒ Object
-
#initialize(env:) ⇒ Config
constructor
A new instance of Config.
- #last_n_days ⇒ Object
- #logger ⇒ Object
Constructor Details
#initialize(env:) ⇒ Config
Returns a new instance of Config.
6 7 8 |
# File 'lib/affiliate_window/etl/config.rb', line 6 def initialize(env:) self.env = env end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
4 5 6 |
# File 'lib/affiliate_window/etl/config.rb', line 4 def env @env end |
Instance Method Details
#account_id ⇒ Object
17 18 19 |
# File 'lib/affiliate_window/etl/config.rb', line 17 def account_id env.fetch("ACCOUNT_ID", 1234) end |
#affiliate_api_password ⇒ Object
21 22 23 |
# File 'lib/affiliate_window/etl/config.rb', line 21 def affiliate_api_password env.fetch("AFFILIATE_API_PASSWORD", "password") end |
#database_url ⇒ Object
10 11 12 13 14 15 |
# File 'lib/affiliate_window/etl/config.rb', line 10 def database_url env.fetch( "DATABASE_URL", "postgres://#{`whoami`.strip}@localhost:5432/affiliate_window?pool=5&encoding=unicode", ) end |
#last_n_days ⇒ Object
25 26 27 |
# File 'lib/affiliate_window/etl/config.rb', line 25 def last_n_days env.fetch("LAST_N_DAYS", "7").to_i end |
#logger ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/affiliate_window/etl/config.rb', line 29 def logger name = env.fetch("DEBUG_STREAM", "stdout") name = name.downcase.to_sym stream = { stdout: $stdout, stderr: $stderr, none: nil }.fetch(name) Logger.new(stream) if stream end |