xmlhasher 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -3
- data/.travis.yml +3 -3
- data/CHANGELOG.md +7 -0
- data/Gemfile +2 -0
- data/README.md +2 -2
- data/lib/xmlhasher.rb +4 -0
- data/lib/xmlhasher/configurable.rb +3 -1
- data/lib/xmlhasher/handler.rb +3 -1
- data/lib/xmlhasher/node.rb +28 -11
- data/lib/xmlhasher/version.rb +1 -1
- data/scripts/ci +26 -0
- data/xmlhasher.gemspec +3 -3
- metadata +18 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bde73682245b3ba9ec69944e0dedb7488786205bf38ccfe6f64ac800fbad0f7b
|
4
|
+
data.tar.gz: cbf2f1830e2a7f649376e30408f78d3ef2f26c0e6cf5b1ec6f76da9ecc0e4764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08450792f4de79c0cbd56e20e023739c5c2c095ba355048501912b1736c0efe3f455aa8ff5b880ad177fff7f92863a3bb9358335ed1012ce4f891d0bf51e3979'
|
7
|
+
data.tar.gz: 5373d3fb4e4f0b9644ed80d6d2957576dbfe0e97645f5a54f94e625721bd8142a5b583d0997677869bfd0ac3a1ee8a90ec7bf357532d538141909df09d5f7206
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.5
|
3
|
-
|
4
1
|
Style/Documentation:
|
5
2
|
Enabled: false
|
6
3
|
|
@@ -25,3 +22,9 @@ Metrics/PerceivedComplexity:
|
|
25
22
|
Style/MissingRespondToMissing:
|
26
23
|
Exclude:
|
27
24
|
- 'lib/xmlhasher.rb'
|
25
|
+
|
26
|
+
Naming/VariableNumber:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Gemspec/RequiredRubyVersion:
|
30
|
+
Enabled: <%= ENV['CI'] != 'true' %>
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
All changes to the XmlHasher gem are documented here. Releases follow semantic versioning.
|
4
4
|
|
5
|
+
## [1.0.6] - 2021-03-10
|
6
|
+
|
7
|
+
- Resolve gem build warnings .
|
8
|
+
- Run tests on CI
|
9
|
+
- Little refactoring for Node hash builder.
|
10
|
+
- Use new ruby style guide and `rubocop` gem.
|
11
|
+
|
5
12
|
## [1.0.5] - 2019-06-16
|
6
13
|
|
7
14
|
- Updated ox version.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -44,7 +44,7 @@ end
|
|
44
44
|
# alternatively, specify configuration options when instantiating a Parser
|
45
45
|
parser = XmlHasher::Parser.new(
|
46
46
|
:snakecase => true,
|
47
|
-
:ignore_namespaces => true
|
47
|
+
:ignore_namespaces => true,
|
48
48
|
:string_keys => false
|
49
49
|
)
|
50
50
|
|
@@ -86,7 +86,7 @@ Note: benchmarks were generated on a 2015 Macbook Pro using Ruby 2.5.1
|
|
86
86
|
|
87
87
|
## Requirements
|
88
88
|
|
89
|
-
* Ruby
|
89
|
+
* Ruby 2.0.0 or higher
|
90
90
|
|
91
91
|
## Copyright
|
92
92
|
Copyright (c) 2013 Gene Drabkin.
|
data/lib/xmlhasher.rb
CHANGED
@@ -14,7 +14,9 @@ module XmlHasher
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def options
|
17
|
-
XmlHasher::Configurable::KEYS.each_with_object({})
|
17
|
+
XmlHasher::Configurable::KEYS.each_with_object({}) do |key, hash|
|
18
|
+
hash[key] = instance_variable_get(:"@#{key}")
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
data/lib/xmlhasher/handler.rb
CHANGED
@@ -9,6 +9,8 @@ module XmlHasher
|
|
9
9
|
@options = options
|
10
10
|
@stack = []
|
11
11
|
@transform_cache = {}
|
12
|
+
|
13
|
+
super()
|
12
14
|
end
|
13
15
|
|
14
16
|
def to_hash
|
@@ -51,7 +53,7 @@ module XmlHasher
|
|
51
53
|
|
52
54
|
name = name.to_s.split(':').last if @options[:ignore_namespaces]
|
53
55
|
name = Util.snakecase(name) if @options[:snakecase]
|
54
|
-
name =
|
56
|
+
name = @options[:string_keys] ? name.to_s : name.to_sym
|
55
57
|
@transform_cache[orig_name] = name
|
56
58
|
name
|
57
59
|
end
|
data/lib/xmlhasher/node.rb
CHANGED
@@ -11,19 +11,36 @@ module XmlHasher
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_hash
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
node_content = content
|
15
|
+
{ name => node_content.empty? ? nil : node_content }
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def content
|
21
|
+
return text if text && !text.empty?
|
22
|
+
|
23
|
+
attributes_to_hash.merge(children_to_hash)
|
24
|
+
end
|
25
|
+
|
26
|
+
def attributes_to_hash
|
27
|
+
attributes.each_with_object({}) do |(key, value), data|
|
28
|
+
next if value.nil? || value.to_s.empty?
|
29
|
+
|
30
|
+
data[key] = value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def children_to_hash
|
35
|
+
return children.first.to_hash if children.size == 1
|
36
|
+
|
37
|
+
children.group_by(&:name).each_with_object({}) do |(key, nodes), data|
|
38
|
+
next data.merge!(nodes.first.to_hash) if nodes.length == 1
|
39
|
+
|
40
|
+
data[key] = nodes.map do |node|
|
41
|
+
node.to_hash[node.name]
|
23
42
|
end
|
24
43
|
end
|
25
|
-
h[name] = nil if h[name].empty?
|
26
|
-
h
|
27
44
|
end
|
28
45
|
end
|
29
46
|
end
|
data/lib/xmlhasher/version.rb
CHANGED
data/scripts/ci
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
|
5
|
+
init_ruby_version() {
|
6
|
+
echo "Using $(ruby -v)"
|
7
|
+
echo "$(cut -d'@' -f1 <<<"$(rvm current)")" > .ruby-version
|
8
|
+
}
|
9
|
+
|
10
|
+
run_code_quality_checks() {
|
11
|
+
if [[ "$(rvm current)" != *"2.0.0"* ]]; then
|
12
|
+
bundle exec rubocop .
|
13
|
+
fi
|
14
|
+
}
|
15
|
+
|
16
|
+
run_tests() {
|
17
|
+
bundle exec rake test
|
18
|
+
}
|
19
|
+
|
20
|
+
main() {
|
21
|
+
init_ruby_version &&
|
22
|
+
run_code_quality_checks &&
|
23
|
+
run_tests
|
24
|
+
}
|
25
|
+
|
26
|
+
main
|
data/xmlhasher.gemspec
CHANGED
@@ -23,12 +23,12 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.required_rubygems_version = '>= 1.3.6'
|
24
24
|
|
25
25
|
spec.add_dependency 'escape_utils', '~> 1.2'
|
26
|
-
spec.add_dependency 'ox', '~> 2.11
|
26
|
+
spec.add_dependency 'ox', '~> 2.11'
|
27
27
|
|
28
|
-
spec.add_development_dependency 'bundler'
|
28
|
+
spec.add_development_dependency 'bundler', '>= 1.6', '< 3'
|
29
29
|
spec.add_development_dependency 'coveralls', '~> 0.8.21'
|
30
30
|
spec.add_development_dependency 'minitest', '~> 5.10'
|
31
|
-
spec.add_development_dependency 'rake'
|
31
|
+
spec.add_development_dependency 'rake', '~> 12'
|
32
32
|
spec.add_development_dependency 'simplecov', '~> 0.14.1'
|
33
33
|
spec.add_development_dependency 'test-unit', '~> 3.2'
|
34
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmlhasher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gene Drabkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escape_utils
|
@@ -30,28 +30,34 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.11
|
33
|
+
version: '2.11'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.11
|
40
|
+
version: '2.11'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.6'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '3'
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
55
|
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
57
|
+
version: '1.6'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: coveralls
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +90,16 @@ dependencies:
|
|
84
90
|
name: rake
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
|
-
- - "
|
93
|
+
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
95
|
+
version: '12'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
|
-
- - "
|
100
|
+
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
102
|
+
version: '12'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: simplecov
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,6 +154,7 @@ files:
|
|
148
154
|
- lib/xmlhasher/parser.rb
|
149
155
|
- lib/xmlhasher/util.rb
|
150
156
|
- lib/xmlhasher/version.rb
|
157
|
+
- scripts/ci
|
151
158
|
- xmlhasher.gemspec
|
152
159
|
homepage: https://github.com/cloocher/xmlhasher
|
153
160
|
licenses:
|
@@ -168,8 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
175
|
- !ruby/object:Gem::Version
|
169
176
|
version: 1.3.6
|
170
177
|
requirements: []
|
171
|
-
|
172
|
-
rubygems_version: 2.7.6
|
178
|
+
rubygems_version: 3.1.2
|
173
179
|
signing_key:
|
174
180
|
specification_version: 4
|
175
181
|
summary: XmlHasher converts XML to Ruby Hash
|