jgrep 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/jgrep +1 -1
  2. data/jgrep.gemspec +1 -1
  3. data/lib/jgrep.rb +8 -6
  4. metadata +2 -2
data/bin/jgrep CHANGED
@@ -48,7 +48,7 @@ begin
48
48
  end
49
49
  end
50
50
  unless r.nil?
51
- (!r.is_a?(Array) || !r.is_a?(Hash)) ? puts(r) : puts(JSON.pretty_generate(r))
51
+ (!r.is_a?(Array) && !r.is_a?(Hash)) ? puts(r) : puts(JSON.pretty_generate(r))
52
52
  end
53
53
  end
54
54
  end
data/jgrep.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "jgrep"
3
- s.version = "1.0.1"
3
+ s.version = "1.0.2"
4
4
 
5
5
  s.authors = ["P Loubser"]
6
6
  s.date = %q{2011-07-19}
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
- new_statement = token[1].split(".").last
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 1
9
- version: 1.0.1
8
+ - 2
9
+ version: 1.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - P Loubser