embulk-parser-xml 0.0.8 → 0.0.9

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: f8284460171d8cc58f9eb93c4c1312a51e2081ad
4
- data.tar.gz: 8e8e62e32e82d849d3f630feb0eb240beced7fbb
3
+ metadata.gz: a7839ccf472a059658c90afa88109f8950bb57ee
4
+ data.tar.gz: 0d85a7a3ef12497d8d1b55577cad7be34201f664
5
5
  SHA512:
6
- metadata.gz: d6f5a5628f72f709ff983386d7c28131d63c2fdd49677736684a13f7bc9da4b10f594f9b82c0f768c90dc59f171dd7ac58d878c4307f2f44a93270248eaa15a3
7
- data.tar.gz: 0714c2f2525be725a7fc07ec06390e24f68bf687e11f16d77a540cea9f7ba53fb38598fae7c663e2031c1faca71d13f623d1c467d8cfe061934ab7f8c49d83a9
6
+ metadata.gz: 84a4c664adba35e2db800d92c45ad3e2c025457f20273eeccf87e90b09fea8b79ef7cbe0d852c2ca3c054fffd0548e0de7df87c82e52d831672f2307005c2079
7
+ data.tar.gz: f5230f3be80460721c0045b9e4cbad1e669738b70f5db5c98c8578dcafe6ac7c71b94483272eae43ef2cb7ea96516d378518ee6f4884dc6e5b1d6eb4b7ba16c6
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- jruby-9.0.4.0
1
+ jruby-9.0.0.0
data/README.md CHANGED
@@ -52,6 +52,7 @@ parser:
52
52
  schema:
53
53
  - {path: name, type: string, name: name}
54
54
  - {path: age, type: long, name: age}
55
+ - {path: hobbies/hobby, type: json, name: hobbies}
55
56
  ```
56
57
 
57
58
  - **type**: specify this plugin as `xpath` .
@@ -71,7 +72,6 @@ schema:
71
72
  - **timezone**: timestamp will be parsing in this timezone, `"+0900"` is used by default.
72
73
 
73
74
 
74
-
75
75
  Here is XML for xample:
76
76
 
77
77
  ```xml
@@ -81,10 +81,17 @@ Here is XML for xample:
81
81
  <student>
82
82
  <name>John</name>
83
83
  <age>10</age>
84
+ <hobbies>
85
+ <hobby>music</hobby>
86
+ <hobby>movie</hobby>
87
+ </hobbies>
84
88
  </student>
85
89
  <student>
86
90
  <name>Paul</name>
87
91
  <age>16</age>
92
+ <hobbies>
93
+ <hobby>game</hobby>
94
+ </hobbies>
88
95
  </student>
89
96
  <student>
90
97
  <name>George</name>
@@ -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.8"
7
+ spec.version = "0.0.9"
8
8
  spec.authors = ["Takuma kanari"]
9
9
  spec.email = ["chemtrails.t@gmail.com"]
10
10
  spec.summary = %q{Embulk parser plugin for XML}
@@ -27,7 +27,7 @@ module Embulk
27
27
  Nokogiri::XML(data).xpath(@task["root"], @task["namespaces"]).each do |item|
28
28
  dest = @task["schema"].inject([]) do |memo, s|
29
29
  es = item.xpath(s["path"], @namespaces)
30
- memo << convert(es.empty? ? nil : es.text, s["type"])
30
+ memo << convert(es.empty? ? nil : es.map(&:text), s["type"])
31
31
  memo
32
32
  end
33
33
  @page_builder.add(dest)
@@ -39,20 +39,24 @@ module Embulk
39
39
 
40
40
  private
41
41
  def convert(val, type)
42
- v = val.nil? ? "" : val
42
+ v = if type == "json"
43
+ val.nil? ? nil : val
44
+ else
45
+ val.nil? ? "" : val.join("")
46
+ end
43
47
  case type
44
- when "string"
45
- v
46
- when "long"
47
- v.to_i
48
- when "double"
49
- v.to_f
50
- when "boolean"
51
- ["yes", "true", "1"].include?(v.downcase)
52
- when "timestamp"
53
- v.empty? ? nil : Time.strptime(v, c["format"])
54
- else
55
- raise "Unsupported type '#{type}'"
48
+ when "string", "json"
49
+ v
50
+ when "long"
51
+ v.to_i
52
+ when "double"
53
+ v.to_f
54
+ when "boolean"
55
+ ["yes", "true", "1"].include?(v.downcase)
56
+ when "timestamp"
57
+ v.empty? ? nil : Time.strptime(v, c["format"])
58
+ else
59
+ raise "Unsupported type '#{type}'"
56
60
  end
57
61
  end
58
62
  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.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takuma kanari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-22 00:00:00.000000000 Z
11
+ date: 2017-01-24 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.6.6
105
+ rubygems_version: 2.4.8
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Embulk parser plugin for XML