Class: AffiliateWindow::ETL::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/affiliate_window/etl/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#envObject

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_idObject



17
18
19
# File 'lib/affiliate_window/etl/config.rb', line 17

def 
  env.fetch("ACCOUNT_ID", 1234)
end

#affiliate_api_passwordObject



21
22
23
# File 'lib/affiliate_window/etl/config.rb', line 21

def affiliate_api_password
  env.fetch("AFFILIATE_API_PASSWORD", "password")
end

#database_urlObject



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_daysObject



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

#loggerObject



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