fluent-plugin-xml 0.1.0 → 0.1.4

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
  SHA256:
3
- metadata.gz: 82cb37760c1f1b28b37252e41ab995047a1d2203a010f11cd80572e1fc86d839
4
- data.tar.gz: 0321a1a46423c70842dc5f505a0ea51eb1969eff7c73a3b0f41aa4b59cb25f43
3
+ metadata.gz: bd2ba740a530d4365e67a5e68b1c282889417b741c88c8e7cb8d17c5b0f691fa
4
+ data.tar.gz: 87a3c1412d3f58de86b2b4599a153ff6c0058a509e0b69495f435af38fa4543d
5
5
  SHA512:
6
- metadata.gz: cb36d6fc424c0a561077392bf29b562236e7588bfe568e4d4b54069a82510c973e5a35732525257ff8fd04ea59c0f336edb791d0d0489aae4c460a56f5caa548
7
- data.tar.gz: 7eda4c6e3c63524653c36ca723ba22a3b9af4a4c31e6a06003aba3543c7cf9aee605a3f6e8dac455ff8ec693fc75c5bc0bb19641c0c6f1cbac1a5bbf9f186433
6
+ metadata.gz: dbae6ac8b259c4385e77863989a15f3aba11d1351ba99b7f8834332aca738d7faa8f299276b8f6db09cc4197c4f73a227131f3c538f410b7a3a9a58c7e709da1
7
+ data.tar.gz: afc8809ee2e90ca34a8ad9b93efdb1b460fc709640254fe28331416c55aa1a38f5a7e1192d70711e3014ceed608482ae01ccaa9ec20367ea012eea27ce14df4f
@@ -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 = "fluent-plugin-xml"
6
- spec.version = "0.1.0"
6
+ spec.version = "0.1.4"
7
7
  spec.authors = ["Rémy DUTHU"]
8
8
  spec.email = ["remyduthu@icloud.com"]
9
9
 
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
 
16
16
  require 'fluent/plugin/parser'
17
- require 'rexml/document'
17
+ require 'nokogiri'
18
18
 
19
19
  module Fluent
20
20
  module Plugin
@@ -36,7 +36,8 @@ module Fluent
36
36
  def parse(text)
37
37
  begin
38
38
  # Open the XML document
39
- doc = REXML::Document.new(text)
39
+ doc = Nokogiri.XML(text)
40
+ doc.remove_namespaces!
40
41
 
41
42
  # Create an empty record which assigns default values for missing
42
43
  # keys. See: https://stackoverflow.com/a/3339168.
@@ -63,9 +64,8 @@ module Fluent
63
64
  end
64
65
 
65
66
  yield(time, record)
66
- rescue Exception => e
67
- $log.warn 'XML parser error: ', e
68
- $log.debug_backtrace(e.backtrace)
67
+ rescue StandardError
68
+ yield(nil, nil)
69
69
  end
70
70
  end
71
71
 
@@ -89,13 +89,14 @@ module Fluent
89
89
  end
90
90
 
91
91
  def get_field_value(doc, xpath)
92
- element = doc.elements[xpath[0]]
93
- return if element.nil?
94
-
95
- attribute = element.attributes[xpath[1]]
96
- return if attribute.nil?
92
+ begin
93
+ elements = doc.xpath(xpath[0])
94
+ throw if elements.nil?
97
95
 
98
- return attribute
96
+ return elements.first[xpath[1]]
97
+ rescue StandardError
98
+ return
99
+ end
99
100
  end
100
101
 
101
102
  def deep_each_pair(hash, parents = [])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémy DUTHU
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-16 00:00:00.000000000 Z
11
+ date: 2021-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  requirements: []
109
- rubygems_version: 3.0.3
109
+ rubygems_version: 3.0.3.1
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: A Fluentd parser plugin to extract attributes from XML data