jgrep 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/jgrep +1 -1
- data/jgrep.gemspec +1 -1
- data/lib/jgrep.rb +8 -6
- metadata +2 -2
data/bin/jgrep
CHANGED
data/jgrep.gemspec
CHANGED
data/lib/jgrep.rb
CHANGED
@@ -4,6 +4,7 @@ require 'parser/parser.rb'
|
|
4
4
|
require 'parser/scanner.rb'
|
5
5
|
require 'rubygems'
|
6
6
|
require 'json'
|
7
|
+
require 'pp'
|
7
8
|
|
8
9
|
module JGrep
|
9
10
|
|
@@ -20,11 +21,6 @@ module JGrep
|
|
20
21
|
end
|
21
22
|
return result
|
22
23
|
|
23
|
-
rescue NameError => e
|
24
|
-
var = e.to_s
|
25
|
-
STDERR.puts "Error. #{var.match(/`(.*)'/)} was not found in documents"
|
26
|
-
exit 1
|
27
|
-
|
28
24
|
rescue JSON::ParserError => e
|
29
25
|
STDERR.puts "Error. Invalid JSON given"
|
30
26
|
exit 1
|
@@ -33,6 +29,8 @@ module JGrep
|
|
33
29
|
|
34
30
|
#Correctly format values so we can do the correct type of comparison
|
35
31
|
def self.format(kvalue, value)
|
32
|
+
puts kvalue
|
33
|
+
puts value
|
36
34
|
if kvalue =~ /^\d+$/ || value =~ /^\d+$/
|
37
35
|
return Integer(kvalue), Integer(value)
|
38
36
|
elsif kvalue =~ /^\d+.\d+$/ || value =~ /^\d+.\d+$/
|
@@ -122,7 +120,11 @@ module JGrep
|
|
122
120
|
when /not|\!/
|
123
121
|
result << "!"
|
124
122
|
when "statement"
|
125
|
-
|
123
|
+
op = token[1].match(/.*<=|>=|=|<|>/)
|
124
|
+
left = token[1].split(op[0]).first.split(".").last
|
125
|
+
right = token[1].split(op[0]).last
|
126
|
+
new_statement = left + op[0] + right
|
127
|
+
# new_statement = token[1].split(/<=|>=|=|<|>/).first.split(".").last + token[1].split(/<=|>=|=|<|>/).last
|
126
128
|
result << has_object?(doc, new_statement)
|
127
129
|
end
|
128
130
|
end
|