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 +5 -5
- data/.ruby-version +1 -1
- data/embulk-parser-xml.gemspec +1 -1
- data/lib/embulk/parser/xpath.rb +14 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e750797e86d86dfbbddd9247d2bad23881a1d7f8d2b98897d719b088de9e9928
|
4
|
+
data.tar.gz: bd32a47244e4681c2c358a022fbe2fec79f73e4f891e8333a1eabb1795e32fd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '082e8b076bab49358ad237921ffa86429b62c7622c7ce644f5c641cebd9477cbd8b76d29ac35fbe77ab358cff02b5f2e7367b907ff84561f0edc813f5b6c5c93'
|
7
|
+
data.tar.gz: fbfd28b181c4ac019b93c8f4597fd8a1413958852320ccdfabe664ee0c92f609c781bcd27c73d0f2523b2f86cb04a64e80f146185d0efe9003ff5cf1294ca123
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
jruby-9.0.
|
1
|
+
jruby-9.0.4.0
|
data/embulk-parser-xml.gemspec
CHANGED
@@ -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.
|
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}
|
data/lib/embulk/parser/xpath.rb
CHANGED
@@ -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,
|
29
|
-
es = item.xpath(
|
30
|
-
memo << convert(es.empty? ? nil : es.map(&:text),
|
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,
|
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?
|
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.
|
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-
|
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.
|
105
|
+
rubygems_version: 2.6.13
|
106
106
|
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: Embulk parser plugin for XML
|