jgrep 1.3.0 → 1.3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/jgrep +27 -7
- data/jgrep.gemspec +2 -2
- metadata +3 -2
data/bin/jgrep
CHANGED
@@ -28,6 +28,10 @@ begin
|
|
28
28
|
options[:file] = filename
|
29
29
|
end
|
30
30
|
|
31
|
+
opts.on("-q", "--quiet", "Quiet; don't write to stdout. Exit with zero status if match found.") do
|
32
|
+
options[:quiet] = true
|
33
|
+
end
|
34
|
+
|
31
35
|
opts.on("-v", "--verbose", "Verbose output") do
|
32
36
|
JGrep::verbose_on
|
33
37
|
end
|
@@ -68,27 +72,43 @@ begin
|
|
68
72
|
|
69
73
|
unless options[:field]
|
70
74
|
result = JGrep::jgrep((json), expression, nil, options[:start])
|
71
|
-
unless result == []
|
75
|
+
unless result == [] or options[:quiet] == true
|
72
76
|
(options[:flat] == false) ? puts(JSON.pretty_generate(result)) : puts(result.to_json)
|
73
77
|
end
|
74
|
-
|
78
|
+
if result.length == 0
|
79
|
+
exit 1
|
80
|
+
end
|
75
81
|
else
|
76
82
|
if options[:field].is_a? Array
|
77
83
|
JGrep::validate_filters(options[:field])
|
78
|
-
|
84
|
+
result = JGrep::jgrep((json), expression, options[:field], options[:start])
|
85
|
+
unless result == [] or options[:quiet] == true
|
86
|
+
puts(JSON.pretty_generate(result))
|
87
|
+
end
|
79
88
|
|
80
89
|
else
|
81
90
|
JGrep::validate_filters(options[:field])
|
82
91
|
result = JGrep::jgrep((json), expression, options[:field], options[:start])
|
83
92
|
unless result.first.is_a?(Hash) || result.flatten.first.is_a?(Hash)
|
84
|
-
|
93
|
+
unless options[:quiet] == true
|
94
|
+
result.map{|x| puts x unless x.nil?}
|
95
|
+
end
|
85
96
|
else
|
86
|
-
|
97
|
+
unless options[:quiet] == true
|
98
|
+
puts(JSON.pretty_generate(result))
|
99
|
+
end
|
100
|
+
end
|
101
|
+
unless result.length > 0
|
102
|
+
exit 1
|
87
103
|
end
|
88
104
|
end
|
89
105
|
end
|
90
106
|
|
91
107
|
rescue Exception => e
|
92
|
-
|
93
|
-
|
108
|
+
if e.is_a?(SystemExit)
|
109
|
+
exit e.status
|
110
|
+
else
|
111
|
+
STDERR.puts "Error - #{e}"
|
112
|
+
exit 1
|
113
|
+
end
|
94
114
|
end
|
data/jgrep.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "jgrep"
|
3
|
-
s.version = "1.3.0"
|
3
|
+
s.version = "1.3.0.1"
|
4
4
|
|
5
5
|
s.authors = ["P Loubser"]
|
6
|
-
s.date = %q{2011-08-
|
6
|
+
s.date = %q{2011-08-05}
|
7
7
|
s.default_executable = "jgrep"
|
8
8
|
s.add_dependency('json')
|
9
9
|
s.description = "Compare a list of json documents to a simple logical language and returns matches as output"
|
metadata
CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 1
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 1.3.0.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- P Loubser
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-05 00:00:00 +01:00
|
18
19
|
default_executable: jgrep
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|