embulk-parser-flexml 0.0.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -1
- data/embulk-parser-flexml.gemspec +2 -2
- data/lib/embulk/parser/flexml.rb +3 -5
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7adaffddc6300c0dab74df9372121d310acbdaeb
|
4
|
+
data.tar.gz: 5ef5446c5dfc8746dbdebb12941819305a6f8820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e89dbac3ec544f4cfee5bd51fbaccc997751977e204c9bdbca2493153c4e4c928ab42c10e11fa4a5e009c8550fdf160284ec7999cfa55221e439d99c1b79171
|
7
|
+
data.tar.gz: 3bb2d3ed00c8ef58505f212fcf6613a02836e4fe74f2f578c54f9d42ed809ab99b137cfdd3f856896f74349cbb35230e33753005b902cfdc2cc5a2badf702330
|
data/README.md
CHANGED
@@ -1,2 +1,52 @@
|
|
1
1
|
# embulk-parser-flexml
|
2
|
-
|
2
|
+
|
3
|
+
Parser plugin for [Embulk](https://github.com/embulk/embulk).
|
4
|
+
|
5
|
+
Flexible xml parser for embulk. read data using xpath and from attributes
|
6
|
+
|
7
|
+
* **Plugin type**: parser
|
8
|
+
* **Load all or nothing**: yes
|
9
|
+
* **Resume supported**: no
|
10
|
+
|
11
|
+
## Configuration
|
12
|
+
|
13
|
+
- **type**: specify this plugin as `flexml` .
|
14
|
+
- **root**: root property to start fetching each entries, specify in *path/to/node* style (string, required)
|
15
|
+
- **schema**: specify the attribute of table and data type (required)
|
16
|
+
- **name**: name of the attribute (string, required)
|
17
|
+
- **type**: type of the attribute (string, required)
|
18
|
+
- **attribute**: if specified, value of this attribute will be the output, otherwise child will be the output (string, optional)
|
19
|
+
- **xpath**: child element to select (string, required)
|
20
|
+
|
21
|
+
## Example
|
22
|
+
|
23
|
+
### Configuration
|
24
|
+
|
25
|
+
```yaml
|
26
|
+
parser:
|
27
|
+
type: flexml
|
28
|
+
root: Team/Players/Player
|
29
|
+
schema:
|
30
|
+
- { name: name, type: string, attribute: name }
|
31
|
+
- { name: age, type: long, attribute: age }
|
32
|
+
- { name: about, type: string, xpath: About }
|
33
|
+
- { name: facebook, type: string, xpath: "SocialMedia[@type='facebook']", attribute: url }
|
34
|
+
- { name: twitter, type: string, xpath: "SocialMedia[@type='twitter']", attribute: url }
|
35
|
+
```
|
36
|
+
|
37
|
+
### XML
|
38
|
+
|
39
|
+
```xml
|
40
|
+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
41
|
+
<Team>
|
42
|
+
<Players>
|
43
|
+
<Player name="Locatelli" age="23">
|
44
|
+
<About>
|
45
|
+
Manuel Locatelli Cavaliere OMRI (born 8 January 1998) is an Italian professional footballer who plays as a midfielder for Serie A club Juventus, on loan from Serie A club Sassuolo, and the Italy national team.
|
46
|
+
</About>
|
47
|
+
<SocialMedia type="facebook" url="https://www.facebook.com/locamanuel73"/>
|
48
|
+
<SocialMedia type="twitter" url="https://twitter.com/locamanuel73"/>
|
49
|
+
</Player>
|
50
|
+
</Players>
|
51
|
+
</Team>
|
52
|
+
```
|
@@ -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.1.1"
|
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}
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
16
|
spec.require_paths = ["lib"]
|
17
17
|
|
18
|
-
spec.add_dependency "rexml", "~> 3.1"
|
18
|
+
spec.add_dependency "rexml", "~> 3.1.9"
|
19
19
|
spec.add_development_dependency "bundler", "~> 1.0"
|
20
20
|
spec.add_development_dependency 'embulk', ['>= 0.9.15']
|
21
21
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/embulk/parser/flexml.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'rexml/document'
|
2
2
|
|
3
|
+
include REXML
|
4
|
+
|
3
5
|
module Embulk
|
4
6
|
module Parser
|
5
|
-
include REXML
|
6
|
-
|
7
7
|
class Flexml < ParserPlugin
|
8
8
|
Plugin.register_parser("flexml", self)
|
9
9
|
|
@@ -38,8 +38,6 @@ module Embulk
|
|
38
38
|
values = @task[:schema].map do |f, c|
|
39
39
|
row = if c.has_key?("xpath")
|
40
40
|
XPath.first(e, c["xpath"])
|
41
|
-
elsif c.has_key?("element")
|
42
|
-
e.element(c["element"])
|
43
41
|
else
|
44
42
|
e
|
45
43
|
end
|
@@ -55,7 +53,7 @@ module Embulk
|
|
55
53
|
@page_builder.add(values)
|
56
54
|
end
|
57
55
|
rescue Exception => e
|
58
|
-
|
56
|
+
Embulk.logger.error "Failed to parse xml: #{e.message}"
|
59
57
|
end
|
60
58
|
end
|
61
59
|
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
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.1.1
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
18
|
+
version: 3.1.9
|
19
19
|
name: rexml
|
20
20
|
prerelease: false
|
21
21
|
type: :runtime
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.1.9
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|