embulk-parser-xml 0.0.9 → 0.0.10

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
- SHA1:
3
- metadata.gz: a7839ccf472a059658c90afa88109f8950bb57ee
4
- data.tar.gz: 0d85a7a3ef12497d8d1b55577cad7be34201f664
2
+ SHA256:
3
+ metadata.gz: e750797e86d86dfbbddd9247d2bad23881a1d7f8d2b98897d719b088de9e9928
4
+ data.tar.gz: bd32a47244e4681c2c358a022fbe2fec79f73e4f891e8333a1eabb1795e32fd1
5
5
  SHA512:
6
- metadata.gz: 84a4c664adba35e2db800d92c45ad3e2c025457f20273eeccf87e90b09fea8b79ef7cbe0d852c2ca3c054fffd0548e0de7df87c82e52d831672f2307005c2079
7
- data.tar.gz: f5230f3be80460721c0045b9e4cbad1e669738b70f5db5c98c8578dcafe6ac7c71b94483272eae43ef2cb7ea96516d378518ee6f4884dc6e5b1d6eb4b7ba16c6
6
+ metadata.gz: '082e8b076bab49358ad237921ffa86429b62c7622c7ce644f5c641cebd9477cbd8b76d29ac35fbe77ab358cff02b5f2e7367b907ff84561f0edc813f5b6c5c93'
7
+ data.tar.gz: fbfd28b181c4ac019b93c8f4597fd8a1413958852320ccdfabe664ee0c92f609c781bcd27c73d0f2523b2f86cb04a64e80f146185d0efe9003ff5cf1294ca123
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- jruby-9.0.0.0
1
+ jruby-9.0.4.0
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "embulk-parser-xml"
7
- spec.version = "0.0.9"
7
+ spec.version = "0.0.10"
8
8
  spec.authors = ["Takuma kanari"]
9
9
  spec.email = ["chemtrails.t@gmail.com"]
10
10
  spec.summary = %q{Embulk parser plugin for XML}
@@ -25,9 +25,9 @@ module Embulk
25
25
  data = file.read
26
26
  if !data.nil? && !data.empty?
27
27
  Nokogiri::XML(data).xpath(@task["root"], @task["namespaces"]).each do |item|
28
- dest = @task["schema"].inject([]) do |memo, s|
29
- es = item.xpath(s["path"], @namespaces)
30
- memo << convert(es.empty? ? nil : es.map(&:text), s["type"])
28
+ dest = @task["schema"].inject([]) do |memo, schema|
29
+ es = item.xpath(schema["path"], @namespaces)
30
+ memo << convert(es.empty? ? nil : es.map(&:text), schema)
31
31
  memo
32
32
  end
33
33
  @page_builder.add(dest)
@@ -38,13 +38,13 @@ module Embulk
38
38
  end
39
39
 
40
40
  private
41
- def convert(val, type)
42
- v = if type == "json"
41
+ def convert(val, schema)
42
+ v = if schema["type"] == "json"
43
43
  val.nil? ? nil : val
44
44
  else
45
45
  val.nil? ? "" : val.join("")
46
46
  end
47
- case type
47
+ case schema["type"]
48
48
  when "string", "json"
49
49
  v
50
50
  when "long"
@@ -54,7 +54,14 @@ module Embulk
54
54
  when "boolean"
55
55
  ["yes", "true", "1"].include?(v.downcase)
56
56
  when "timestamp"
57
- v.empty? ? nil : Time.strptime(v, c["format"])
57
+ unless v.empty?
58
+ dest = Time.strptime(v, schema["format"])
59
+ utc_offset = dest.utc_offset
60
+ zone_offset = Time.zone_offset(schema["timezone"])
61
+ dest.localtime(zone_offset) + utc_offset - zone_offset
62
+ else
63
+ nil
64
+ end
58
65
  else
59
66
  raise "Unsupported type '#{type}'"
60
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-parser-xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takuma kanari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-24 00:00:00.000000000 Z
11
+ date: 2017-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.4.8
105
+ rubygems_version: 2.6.13
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Embulk parser plugin for XML