embulk-input-lkqd 0.4.0 → 0.5.0

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: 49509853db610fef7a5568f4c42fbc17f049a542
4
- data.tar.gz: 3d4ecb0f053acd0f83b2a457841afda8d0b4257a
3
+ metadata.gz: 866f3cba36f1579e65bfd63ed2db19ec2781dddc
4
+ data.tar.gz: 095f3b63d64f391babe144787e32a0b7070d2691
5
5
  SHA512:
6
- metadata.gz: 3d6c7f66ae0bfd4b544893790a36cb53389d22303defa06492c0bd3942d4011dbe9bc7f36ccd8fb4faba178f04394437099e423af4af6b701415904b2d7162f3
7
- data.tar.gz: 6fe7d73a0e4b82d91d645192f186255f8125ab0d474a5db5ea6ad794572ef98753fbe436556a398fd6e4ea728c65ae44fa29c2aea2cfb874c52a87f929695fe0
6
+ metadata.gz: f064a350f85fb9734439f0d7197f8405d29199dbd0a7ac35cf097240284c3ecd0fa6c8de291077fef296c6572661abf25f47e714be35a3a0ca443d972846f039
7
+ data.tar.gz: ba4818c5483cf6347a6a81d0ab8c248ba0a8908e5aa4edb4bfaf930b6e25adae4eff66dcb2ad0af415d86b4bb6c332a6e1482a0a74af9b285a4004ac9caf28a4
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "embulk-input-lkqd"
3
- spec.version = "0.4.0"
3
+ spec.version = "0.5.0"
4
4
  spec.authors = ["Ming Liu"]
5
5
  spec.summary = "LKQD input plugin for Embulk"
6
6
  spec.description = "Loads reporting data from LKQD API."
@@ -16,6 +16,7 @@ module Embulk
16
16
  "secret_key_id" => config.param("secret_key_id", :string),
17
17
  "secret_key" => config.param("secret_key", :string),
18
18
  "endpoint" => config.param("endpoint", :string, default: 'https://api.lkqd.com/reports'),
19
+ "try_convert" => config.param("try_convert", :string, default: "true"),
19
20
  "report_parameters" => config.param("report_parameters", :hash, default: {}),
20
21
  }
21
22
  task['authorization'] = Base64.urlsafe_encode64("#{task['secret_key_id']}:#{task['secret_key']}")
@@ -62,7 +63,7 @@ module Embulk
62
63
  end
63
64
  end
64
65
 
65
- def self.try_convert(row)
66
+ def self.try_convert(row, options={})
66
67
  return row.map do |field|
67
68
  name, value = field
68
69
  column_name = name.gsub(/^\W/, '')
@@ -70,7 +71,7 @@ module Embulk
70
71
  if column_option.nil?
71
72
  next value
72
73
  elsif column_option['type'] == 'timestamp'
73
- next Time.strptime(value, column_option['format']).to_i
74
+ next Time.strptime(value + " " + options[:timezone], column_option['format'] + " %Z").to_i
74
75
  elsif column_option['type'] == 'long'
75
76
  next value.gsub(',','').to_i
76
77
  elsif column_option['type'] == 'double' && value.match(/%$/)
@@ -88,8 +89,10 @@ module Embulk
88
89
  end
89
90
 
90
91
  def run
92
+ convert_options = {timezone: @task['report_parameters']['timezone']}
91
93
  CSV.foreach(@task['tempfile_path'], {headers: true}).each do |row|
92
- page_builder.add(Lkqd.try_convert(row))
94
+ row = @task['try_convert'] == "true" ? Lkqd.try_convert(row, convert_options) : row
95
+ page_builder.add(row)
93
96
  end
94
97
  page_builder.finish
95
98
  FileUtils.rm_rf(@task['tempfile_path'])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-lkqd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ming Liu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-17 00:00:00.000000000 Z
11
+ date: 2017-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http