leenookx-json-mangler 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/features/test_comparisons/2level_extraction.json +1 -1
- data/json-mangler.gemspec +4 -3
- data/lib/json-mangler/json_extractor.rb +24 -9
- metadata +4 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -1 +1 @@
|
|
1
|
-
{ "results": {"
|
1
|
+
{ "results": {"title": "A test document", "author": "My Name", "published": "1999", "keywords": ["rubbish", "nonsense"]} }
|
data/json-mangler.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{json-mangler}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["lee nookx"]
|
@@ -51,10 +51,11 @@ Gem::Specification.new do |s|
|
|
51
51
|
"lib/json-mangler/json_mangler.rb",
|
52
52
|
"test/test_json_mangler.rb"
|
53
53
|
]
|
54
|
+
s.has_rdoc = true
|
54
55
|
s.homepage = %q{http://github.com/leenookx/json-mangler}
|
55
56
|
s.rdoc_options = ["--charset=UTF-8"]
|
56
57
|
s.require_paths = ["lib"]
|
57
|
-
s.rubygems_version = %q{1.3.
|
58
|
+
s.rubygems_version = %q{1.3.1}
|
58
59
|
s.summary = %q{JSON data format mangling tools.}
|
59
60
|
s.test_files = [
|
60
61
|
"test/test_json_mangler.rb"
|
@@ -62,7 +63,7 @@ Gem::Specification.new do |s|
|
|
62
63
|
|
63
64
|
if s.respond_to? :specification_version then
|
64
65
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
65
|
-
s.specification_version =
|
66
|
+
s.specification_version = 2
|
66
67
|
|
67
68
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
68
69
|
else
|
@@ -74,16 +74,22 @@ class JSONExtractor
|
|
74
74
|
res = parse_value
|
75
75
|
|
76
76
|
# If we're in data matching mode and the data associated
|
77
|
-
# will this object matches what we are looking for
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
77
|
+
# will this object matches what we are looking for, but
|
78
|
+
# make sure that we don't re-force the capture if one is
|
79
|
+
# already in progress.
|
80
|
+
if @mode == 2 and res == @searchval
|
81
|
+
if !@force_capture
|
82
|
+
if @capture_depth > 0
|
83
|
+
# Set the 'upward' depth to be captured.
|
84
|
+
@current_depth = @capture_depth
|
85
|
+
|
86
|
+
# Force the capturing of this object.
|
87
|
+
@force_capture = true
|
88
|
+
else
|
89
|
+
capture = true
|
90
|
+
end
|
85
91
|
else
|
86
|
-
|
92
|
+
@current_depth = @current_depth - 1
|
87
93
|
end
|
88
94
|
end
|
89
95
|
|
@@ -103,12 +109,19 @@ class JSONExtractor
|
|
103
109
|
end
|
104
110
|
end
|
105
111
|
|
112
|
+
# Are there more pairs associated with this
|
113
|
+
# object?
|
106
114
|
more_pairs = @input.scan(/\s*,\s*/)
|
107
115
|
if more_pairs
|
116
|
+
# yes, so write out a comma.
|
108
117
|
output << ", "
|
109
118
|
else
|
119
|
+
# Do we need to force capturing of the entire
|
120
|
+
# object?
|
110
121
|
if @force_capture and @current_depth == 0
|
111
122
|
last_pos = @input.pos
|
123
|
+
|
124
|
+
puts "Full object capture: " + start_pos.to_s + " -> " + last_pos.to_s
|
112
125
|
|
113
126
|
cur_pos = start_pos
|
114
127
|
@input.pos = cur_pos
|
@@ -119,6 +132,7 @@ class JSONExtractor
|
|
119
132
|
|
120
133
|
@force_capture = false
|
121
134
|
else
|
135
|
+
# No, we need to 'descend' further
|
122
136
|
@current_depth = @current_depth - 1
|
123
137
|
end
|
124
138
|
end
|
@@ -164,6 +178,7 @@ class JSONExtractor
|
|
164
178
|
# If we're in data matching mode and this matches the
|
165
179
|
# value that we are searching for...
|
166
180
|
if @mode == 2 and string == @searchval and @capture_depth > 0
|
181
|
+
puts "marked"
|
167
182
|
@force_capture = true
|
168
183
|
@current_depth = @capture_depth
|
169
184
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leenookx-json-mangler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lee nookx
|
@@ -56,9 +56,8 @@ files:
|
|
56
56
|
- lib/json-mangler/json_extractor.rb
|
57
57
|
- lib/json-mangler/json_mangler.rb
|
58
58
|
- test/test_json_mangler.rb
|
59
|
-
has_rdoc:
|
59
|
+
has_rdoc: true
|
60
60
|
homepage: http://github.com/leenookx/json-mangler
|
61
|
-
licenses:
|
62
61
|
post_install_message:
|
63
62
|
rdoc_options:
|
64
63
|
- --charset=UTF-8
|
@@ -79,9 +78,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
78
|
requirements: []
|
80
79
|
|
81
80
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.2.0
|
83
82
|
signing_key:
|
84
|
-
specification_version:
|
83
|
+
specification_version: 2
|
85
84
|
summary: JSON data format mangling tools.
|
86
85
|
test_files:
|
87
86
|
- test/test_json_mangler.rb
|