embulk-parser-flexml 0.1.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/embulk-parser-flexml.gemspec +1 -1
- data/lib/embulk/parser/flexml.rb +6 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b0fa387accb2417fa52c186d799930350988543
|
4
|
+
data.tar.gz: 530f5f92aa261d28d36ae4536218861e79ba66e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 809850f391e9964b4a0420bc86d31e4f86eb4b2a750332e1d1ddef14b904d03b61192e1c99da739f98dc1fee5e4c9d9bd9ab45da871057b4c30698d41d8c7d21
|
7
|
+
data.tar.gz: 370de18ca67cee63979c7f42d67833875aaf50ce6384d360881e7e1a3c133ac19f460f525504cf829d95cbb2385d7c811cf6765f481e8e79dc61f62bd924c680
|
data/README.md
CHANGED
@@ -17,6 +17,9 @@ Flexible xml parser for embulk. read data using xpath and from attributes
|
|
17
17
|
- **type**: type of the attribute (string, required)
|
18
18
|
- **attribute**: if specified, value of this attribute will be the output, otherwise child will be the output (string, optional)
|
19
19
|
- **xpath**: child element to select (string, required)
|
20
|
+
- **format**: timestamp format to parse (string, required)
|
21
|
+
- **timezone**: timestamp will be parsed in this timezone (string, optional)
|
22
|
+
|
20
23
|
|
21
24
|
## Example
|
22
25
|
|
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "embulk-parser-flexml"
|
6
|
-
spec.version = "0.
|
6
|
+
spec.version = "0.2.2"
|
7
7
|
spec.authors = ["Surya Asriadie"]
|
8
8
|
spec.email = ["surya.asriadie@gmail.com"]
|
9
9
|
spec.summary = %q{Flexible Embulk parser plugin for XML}
|
data/lib/embulk/parser/flexml.rb
CHANGED
@@ -14,7 +14,7 @@ module Embulk
|
|
14
14
|
if s["type"] == "timestamp"
|
15
15
|
memo[s["name"]].merge!({
|
16
16
|
"format" => s["format"],
|
17
|
-
"timezone" => s["timezone"]
|
17
|
+
"timezone" => s["timezone"]
|
18
18
|
})
|
19
19
|
end
|
20
20
|
memo
|
@@ -43,9 +43,9 @@ module Embulk
|
|
43
43
|
end
|
44
44
|
|
45
45
|
val = if c.has_key?("attribute")
|
46
|
-
row
|
46
|
+
row&.attributes&.dig(c["attribute"])
|
47
47
|
else
|
48
|
-
row
|
48
|
+
row&.text
|
49
49
|
end
|
50
50
|
convert(val, c)
|
51
51
|
end
|
@@ -53,7 +53,7 @@ module Embulk
|
|
53
53
|
@page_builder.add(values)
|
54
54
|
end
|
55
55
|
rescue Exception => e
|
56
|
-
Embulk.logger.error e
|
56
|
+
Embulk.logger.error "Failed to parse xml: #{e.message}"
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -74,6 +74,8 @@ module Embulk
|
|
74
74
|
when "timestamp"
|
75
75
|
unless v.empty?
|
76
76
|
dest = Time.strptime(v, config["format"])
|
77
|
+
return dest.utc if config["timezone"].nil?
|
78
|
+
|
77
79
|
utc_offset = dest.utc_offset
|
78
80
|
zone_offset = Time.zone_offset(config["timezone"])
|
79
81
|
dest.localtime(zone_offset) + utc_offset - zone_offset
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-parser-flexml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Surya Asriadie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|