embulk-parser-flexml 0.1.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7adaffddc6300c0dab74df9372121d310acbdaeb
4
- data.tar.gz: 5ef5446c5dfc8746dbdebb12941819305a6f8820
3
+ metadata.gz: 2c38653cf5150955c6f0bb9955fc3c2abd43229b
4
+ data.tar.gz: 78febb4d3da68e4c378fa4f0c2dfc2e0e332315b
5
5
  SHA512:
6
- metadata.gz: 4e89dbac3ec544f4cfee5bd51fbaccc997751977e204c9bdbca2493153c4e4c928ab42c10e11fa4a5e009c8550fdf160284ec7999cfa55221e439d99c1b79171
7
- data.tar.gz: 3bb2d3ed00c8ef58505f212fcf6613a02836e4fe74f2f578c54f9d42ed809ab99b137cfdd3f856896f74349cbb35230e33753005b902cfdc2cc5a2badf702330
6
+ metadata.gz: 67e3a09cffe108cc20722dd2007380f830d706fc3affc9fcf49fb50d67dadc07e2c68d2c8ba4f5adc7f0e12dd05b484b635a7a495cc96e073fab6eb16ab6e8ef
7
+ data.tar.gz: 3f98920cf3f2afd4ff67cbf8643bb9a65ec2c8ed6aa62bac8be74bfce5dbb9b6b163c1a13bc954335c45713b13a681a7dd50b207cddcc6c4452246a15d31d9a8
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.1.1"
6
+ spec.version = "0.2.3"
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}
@@ -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"] || "+0900"
17
+ "timezone" => s["timezone"]
18
18
  })
19
19
  end
20
20
  memo
@@ -42,12 +42,16 @@ module Embulk
42
42
  e
43
43
  end
44
44
 
45
- val = if c.has_key?("attribute")
46
- row.attributes[c["attribute"]]
45
+ unless row.nil?
46
+ val = if c.has_key?("attribute")
47
+ row.attributes[c["attribute"]]
48
+ else
49
+ row.text
50
+ end
51
+ convert(val, c)
47
52
  else
48
- row.text
53
+ nil
49
54
  end
50
- convert(val, c)
51
55
  end
52
56
 
53
57
  @page_builder.add(values)
@@ -74,6 +78,8 @@ module Embulk
74
78
  when "timestamp"
75
79
  unless v.empty?
76
80
  dest = Time.strptime(v, config["format"])
81
+ return dest.utc if config["timezone"].nil?
82
+
77
83
  utc_offset = dest.utc_offset
78
84
  zone_offset = Time.zone_offset(config["timezone"])
79
85
  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.1.1
4
+ version: 0.2.3
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-12-08 00:00:00.000000000 Z
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