affiliate_window_etl 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 427040cb240f63771c270492ff23b8ef7a637555
4
- data.tar.gz: a74df8ab95bea6ef1d9a9a4d89a9e47619038940
3
+ metadata.gz: 9608ebcbad9449f57193fc51055c6be2d8aabe0d
4
+ data.tar.gz: f4d7a27eb09a864bb4b7e7adf3dbfc7d3fc675f9
5
5
  SHA512:
6
- metadata.gz: a9823fd008567eda7180925fadc8c879b07ce4890d9a28f4df2669e99badb8292048f09716db45b275e976c27a056043bdced42e0ea6a5eec4c036e5c1544611
7
- data.tar.gz: 263d5b0442bd721c3907d62138177b03a91d55b19182d44ec863bcd4af233bdf552b198d5c8a5858041e18e52ad1512da53f2ae18854482a5e6ed76d02ab3654
6
+ metadata.gz: 735481f591f4113b3e0f25364cf0f174698a908671b90b0ceac8a4d69a9af9794946c7171e298d6b0fc0676b0902b655cff93e67ff5f5ddb2b21538cb1a9b567
7
+ data.tar.gz: d5e2a0e4701a960f2c447dd4a3c7af41d2ba372d1bc74d646af061be289b79b84ccca5908f4e0765a5b9e75360d49b4341aa6e12b5e010fb47f13d03645a33e0
data/README.md CHANGED
@@ -95,6 +95,9 @@ The stream to write debug output. Defaults to `stdout`.
95
95
 
96
96
  Valid options are: `stdout`, `stderr` and `none`.
97
97
 
98
+ Optionally, you can initialize the ETL with a custom logger if you are using the
99
+ Ruby API.
100
+
98
101
  ## How to contribute
99
102
 
100
103
  Bug reports and pull requests are welcome on
@@ -1,9 +1,10 @@
1
1
  class AffiliateWindow
2
2
  class ETL
3
- attr_accessor :config
3
+ attr_accessor :config, :logger
4
4
 
5
- def initialize(env: ENV)
5
+ def initialize(env: ENV, logger: nil)
6
6
  self.config = Config.new(env: env)
7
+ self.logger = logger || config.logger
7
8
  end
8
9
 
9
10
  def run
@@ -40,7 +41,7 @@ class AffiliateWindow
40
41
  def extracter
41
42
  Extracter.new(
42
43
  client: client,
43
- output: config.output_stream,
44
+ logger: logger,
44
45
  )
45
46
  end
46
47
 
@@ -26,11 +26,12 @@ class AffiliateWindow
26
26
  env.fetch("LAST_N_DAYS", "7").to_i
27
27
  end
28
28
 
29
- def output_stream
29
+ def logger
30
30
  name = env.fetch("DEBUG_STREAM", "stdout")
31
31
  name = name.downcase.to_sym
32
32
 
33
- { stdout: $stdout, stderr: $stderr, none: nil }.fetch(name)
33
+ stream = { stdout: $stdout, stderr: $stderr, none: nil }.fetch(name)
34
+ Logger.new(stream) if stream
34
35
  end
35
36
  end
36
37
  end
@@ -3,11 +3,11 @@ class AffiliateWindow
3
3
  class Extracter # rubocop:disable Metrics/ClassLength
4
4
  CHUNK_SIZE = 100
5
5
 
6
- attr_accessor :client, :output
6
+ attr_accessor :client, :logger
7
7
 
8
- def initialize(client:, output: nil)
8
+ def initialize(client:, logger: nil)
9
9
  self.client = client
10
- self.output = output
10
+ self.logger = logger
11
11
  end
12
12
 
13
13
  def extract(type, params = {})
@@ -181,9 +181,8 @@ class AffiliateWindow
181
181
  end
182
182
 
183
183
  def write(message)
184
- return unless output
185
- message_with_quota = "[quota:#{client.remaining_quota}] #{message}"
186
- output.puts(message_with_quota)
184
+ return unless logger
185
+ logger.debug { "[quota:#{client.remaining_quota}] #{message}" }
187
186
  end
188
187
  end
189
188
  end
@@ -1,5 +1,5 @@
1
1
  class AffiliateWindow
2
2
  class ETL
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: affiliate_window_etl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reevoo Developers