badgerfish 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/badgerfish.gemspec +7 -6
- data/lib/badgerfish/ox_sax_parser.rb +1 -0
- data/lib/badgerfish/version.rb +1 -1
- data/test/badgerfish/test_badgerfish_ning_com.rb +141 -0
- data/test/test_badgerfish.rb +6 -137
- data/test/test_helper.rb +1 -0
- metadata +23 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2935514e764c7dc10742884cb398c7805441a59c
|
4
|
+
data.tar.gz: cd36eadc909f78e45dfefbfac9205c7d4ffc0b9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f8d5d082c241db7c9771b4fb7c55280fdbc42371667cb50f55221356b2ef440dda269fa1a21c0ab6ce9cd49f57c9bdbd0c3ecf81abd5e232fd701339e110b9f
|
7
|
+
data.tar.gz: 694d4daae83abfeb4a9a1d61806cce92b606130221024f1cfcd9eef6015ee1fd4633486c8c77c683f93eecd98e06a58862175324a756aef6314770ccad391f3f
|
data/badgerfish.gemspec
CHANGED
@@ -20,11 +20,12 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency 'ox', '~> 2.0.8'
|
22
22
|
|
23
|
-
spec.add_development_dependency '
|
24
|
-
spec.add_development_dependency '
|
25
|
-
spec.add_development_dependency '
|
26
|
-
spec.add_development_dependency '
|
27
|
-
spec.add_development_dependency '
|
28
|
-
spec.add_development_dependency 'pry
|
23
|
+
spec.add_development_dependency 'activesupport', '>= 3.2.0', '< 5.0.0'
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
+
spec.add_development_dependency 'minitest', '~> 5.0.6'
|
26
|
+
spec.add_development_dependency 'multi_json', '~> 1.7.9'
|
27
|
+
spec.add_development_dependency 'oj', '~> 2.1.4'
|
28
|
+
spec.add_development_dependency 'pry', '~> 0.9.12.2'
|
29
|
+
spec.add_development_dependency 'pry-nav', '~> 0.2.3'
|
29
30
|
spec.add_development_dependency 'rake'
|
30
31
|
end
|
data/lib/badgerfish/version.rb
CHANGED
@@ -0,0 +1,141 @@
|
|
1
|
+
module TestBadgerfishNingCom
|
2
|
+
|
3
|
+
def test_badgerfish_ning_com_nr_2
|
4
|
+
xml = '<alice>bob</alice>'
|
5
|
+
expected_json = <<-json
|
6
|
+
{
|
7
|
+
"alice":{
|
8
|
+
"$":"bob"
|
9
|
+
}
|
10
|
+
}
|
11
|
+
json
|
12
|
+
|
13
|
+
assert_badgerfish xml, expected_json
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_badgerfish_ning_com_nr_3
|
17
|
+
xml = '<alice><bob>charlie</bob><david>edgar</david></alice>'
|
18
|
+
expected_json = <<-json
|
19
|
+
{
|
20
|
+
"alice":{
|
21
|
+
"bob":{
|
22
|
+
"$":"charlie"
|
23
|
+
},
|
24
|
+
"david":{
|
25
|
+
"$":"edgar"
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
json
|
30
|
+
|
31
|
+
assert_badgerfish xml, expected_json
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_badgerfish_ning_com_nr_4
|
35
|
+
xml = '<alice><bob>charlie</bob><bob>david</bob></alice>'
|
36
|
+
expected_json = <<-json
|
37
|
+
{
|
38
|
+
"alice":{
|
39
|
+
"bob":[
|
40
|
+
{
|
41
|
+
"$":"charlie"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"$":"david"
|
45
|
+
}
|
46
|
+
]
|
47
|
+
}
|
48
|
+
}
|
49
|
+
json
|
50
|
+
|
51
|
+
assert_badgerfish xml, expected_json
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_badgerfish_ning_com_nr_5
|
55
|
+
xml = '<alice charlie="david">bob</alice>'
|
56
|
+
expected_json = <<-json
|
57
|
+
{
|
58
|
+
"alice":{
|
59
|
+
"@charlie":"david",
|
60
|
+
"$":"bob"
|
61
|
+
}
|
62
|
+
}
|
63
|
+
json
|
64
|
+
|
65
|
+
assert_badgerfish xml, expected_json
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_badgerfish_ning_com_nr_7
|
69
|
+
xml = '<alice xmlns="http://some-namespace">bob</alice>'
|
70
|
+
expected_json = <<-json
|
71
|
+
{
|
72
|
+
"alice":{
|
73
|
+
"@xmlns":{
|
74
|
+
"$":"http://some-namespace"
|
75
|
+
},
|
76
|
+
"$":"bob"
|
77
|
+
}
|
78
|
+
}
|
79
|
+
json
|
80
|
+
|
81
|
+
assert_badgerfish xml, expected_json
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_badgerfish_ning_com_nr_8
|
85
|
+
xml = <<-xml
|
86
|
+
<alice xmlns="http://some-namespace" xmlns:charlie="http://some-other-namespace">bob</alice>
|
87
|
+
xml
|
88
|
+
expected_json = <<-json
|
89
|
+
{
|
90
|
+
"alice":{
|
91
|
+
"@xmlns":{
|
92
|
+
"$":"http://some-namespace",
|
93
|
+
"charlie":"http://some-other-namespace"
|
94
|
+
},
|
95
|
+
"$":"bob"
|
96
|
+
}
|
97
|
+
}
|
98
|
+
json
|
99
|
+
|
100
|
+
assert_badgerfish xml, expected_json
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_badgerfish_ning_com_nr_9
|
104
|
+
skip("child node namespaces not supported yet")
|
105
|
+
|
106
|
+
xml = <<-xml
|
107
|
+
<alice xmlns="http://some-namespace" xmlns:charlie="http://some-other-namespace">
|
108
|
+
<bob>david</bob>
|
109
|
+
<charlie:edgar>frank</charlie:edgar>
|
110
|
+
</alice>
|
111
|
+
xml
|
112
|
+
|
113
|
+
expected_json = <<-json
|
114
|
+
{
|
115
|
+
"alice":{
|
116
|
+
"@xmlns":{
|
117
|
+
"$":"http://some-namespace",
|
118
|
+
"charlie":"http://some-other-namespace"
|
119
|
+
},
|
120
|
+
"bob":{
|
121
|
+
"@xmlns":{
|
122
|
+
"$":"http://some-namespace",
|
123
|
+
"charlie":"http://some-other-namespace"
|
124
|
+
},
|
125
|
+
"$":"david"
|
126
|
+
},
|
127
|
+
"charlie:edgar":{
|
128
|
+
"$":"frank",
|
129
|
+
"@xmlns":{
|
130
|
+
"$":"http://some-namespace",
|
131
|
+
"charlie":"http://some-other-namespace"
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
json
|
137
|
+
|
138
|
+
assert_badgerfish xml, expected_json
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
data/test/test_badgerfish.rb
CHANGED
@@ -4,143 +4,12 @@ class TestBadgerfish < Minitest::Test
|
|
4
4
|
def setup
|
5
5
|
@parser = Badgerfish::Parser.new
|
6
6
|
end
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
"$":"bob"
|
14
|
-
}
|
15
|
-
}
|
16
|
-
json
|
17
|
-
|
18
|
-
assert_badgerfish xml, expected_json
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_badgerfish_ning_com_nr_3
|
22
|
-
xml = '<alice><bob>charlie</bob><david>edgar</david></alice>'
|
23
|
-
expected_json = <<-json
|
24
|
-
{
|
25
|
-
"alice":{
|
26
|
-
"bob":{
|
27
|
-
"$":"charlie"
|
28
|
-
},
|
29
|
-
"david":{
|
30
|
-
"$":"edgar"
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
json
|
35
|
-
|
36
|
-
assert_badgerfish xml, expected_json
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_badgerfish_ning_com_nr_4
|
40
|
-
xml = '<alice><bob>charlie</bob><bob>david</bob></alice>'
|
41
|
-
expected_json = <<-json
|
42
|
-
{
|
43
|
-
"alice":{
|
44
|
-
"bob":[
|
45
|
-
{
|
46
|
-
"$":"charlie"
|
47
|
-
},
|
48
|
-
{
|
49
|
-
"$":"david"
|
50
|
-
}
|
51
|
-
]
|
52
|
-
}
|
53
|
-
}
|
54
|
-
json
|
55
|
-
|
56
|
-
assert_badgerfish xml, expected_json
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_badgerfish_ning_com_nr_5
|
60
|
-
xml = '<alice charlie="david">bob</alice>'
|
61
|
-
expected_json = <<-json
|
62
|
-
{
|
63
|
-
"alice":{
|
64
|
-
"@charlie":"david",
|
65
|
-
"$":"bob"
|
66
|
-
}
|
67
|
-
}
|
68
|
-
json
|
69
|
-
|
70
|
-
assert_badgerfish xml, expected_json
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_badgerfish_ning_com_nr_7
|
74
|
-
xml = '<alice xmlns="http://some-namespace">bob</alice>'
|
75
|
-
expected_json = <<-json
|
76
|
-
{
|
77
|
-
"alice":{
|
78
|
-
"@xmlns":{
|
79
|
-
"$":"http://some-namespace"
|
80
|
-
},
|
81
|
-
"$":"bob"
|
82
|
-
}
|
83
|
-
}
|
84
|
-
json
|
85
|
-
|
86
|
-
assert_badgerfish xml, expected_json
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_badgerfish_ning_com_nr_8
|
90
|
-
xml = <<-xml
|
91
|
-
<alice xmlns="http://some-namespace" xmlns:charlie="http://some-other-namespace">bob</alice>
|
92
|
-
xml
|
93
|
-
expected_json = <<-json
|
94
|
-
{
|
95
|
-
"alice":{
|
96
|
-
"@xmlns":{
|
97
|
-
"$":"http://some-namespace",
|
98
|
-
"charlie":"http://some-other-namespace"
|
99
|
-
},
|
100
|
-
"$":"bob"
|
101
|
-
}
|
102
|
-
}
|
103
|
-
json
|
104
|
-
|
105
|
-
assert_badgerfish xml, expected_json
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_badgerfish_ning_com_nr_9
|
109
|
-
skip("child node namespaces not supported yet")
|
110
|
-
|
111
|
-
xml = <<-xml
|
112
|
-
<alice xmlns="http://some-namespace" xmlns:charlie="http://some-other-namespace">
|
113
|
-
<bob>david</bob>
|
114
|
-
<charlie:edgar>frank</charlie:edgar>
|
115
|
-
</alice>
|
116
|
-
xml
|
117
|
-
|
118
|
-
expected_json = <<-json
|
119
|
-
{
|
120
|
-
"alice":{
|
121
|
-
"@xmlns":{
|
122
|
-
"$":"http://some-namespace",
|
123
|
-
"charlie":"http://some-other-namespace"
|
124
|
-
},
|
125
|
-
"bob":{
|
126
|
-
"@xmlns":{
|
127
|
-
"$":"http://some-namespace",
|
128
|
-
"charlie":"http://some-other-namespace"
|
129
|
-
},
|
130
|
-
"$":"david"
|
131
|
-
},
|
132
|
-
"charlie:edgar":{
|
133
|
-
"$":"frank",
|
134
|
-
"@xmlns":{
|
135
|
-
"$":"http://some-namespace",
|
136
|
-
"charlie":"http://some-other-namespace"
|
137
|
-
}
|
138
|
-
}
|
139
|
-
}
|
140
|
-
}
|
141
|
-
json
|
142
|
-
|
143
|
-
assert_badgerfish xml, expected_json
|
9
|
+
# require and include all mabmapper test modules
|
10
|
+
Dir.glob(File.expand_path '../badgerfish/test_*.rb', __FILE__).each do |filename|
|
11
|
+
require filename
|
12
|
+
TestBadgerfish.instance_eval do
|
13
|
+
include File.basename(filename, '.rb').camelize.constantize
|
144
14
|
end
|
145
|
-
|
146
15
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: badgerfish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Sievers
|
@@ -24,6 +24,26 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.0.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.0
|
34
|
+
- - <
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 5.0.0
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.2.0
|
44
|
+
- - <
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 5.0.0
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: bundler
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +160,7 @@ files:
|
|
140
160
|
- lib/badgerfish/ox_sax_parser.rb
|
141
161
|
- lib/badgerfish/parser.rb
|
142
162
|
- lib/badgerfish/version.rb
|
163
|
+
- test/badgerfish/test_badgerfish_ning_com.rb
|
143
164
|
- test/test_badgerfish.rb
|
144
165
|
- test/test_helper.rb
|
145
166
|
homepage: https://github.com/msievers/badgerfish
|
@@ -167,5 +188,6 @@ signing_key:
|
|
167
188
|
specification_version: 4
|
168
189
|
summary: Badgerfish xml to json convention for ruby
|
169
190
|
test_files:
|
191
|
+
- test/badgerfish/test_badgerfish_ning_com.rb
|
170
192
|
- test/test_badgerfish.rb
|
171
193
|
- test/test_helper.rb
|