jsonpathv2 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 201b3003cb94eb5886d93deaa0461d4870a9aa4b
4
- data.tar.gz: 349b5bf6214dca4bfae76d07ca44b936aa2e0d4b
3
+ metadata.gz: f23e4231290ad706db184bb34ab670e849963295
4
+ data.tar.gz: c8855a86cff8cc2fa40054f782bc006bd7b42f3d
5
5
  SHA512:
6
- metadata.gz: 094045c7c6e8cc3b7ad100e5094aaa15dfc42c4a9932872d66f5ac41ab6001d171753e1218ecad046f6b91074a208e7fad7a7c3330b5bb2ea5d0c210adc4d036
7
- data.tar.gz: b343a18a2c68bec865368d9ae763b634760f9f6659183a415f47133e8f7b7b3f21b5448f81773f7cc7307a5e5b8cba950345a025fc7ccb97acd3c1bf457a69ab
6
+ metadata.gz: da31e03333972e227a8ec457c03cba2fe35efb714245ee8427f479f8414e0e9dad11973ea309d2895e598f8c75e1833fce5c5f6d8c41903c36bbfa1de0418ba6
7
+ data.tar.gz: c3750c04010e7fd14e78e8b9b88cbca3cd9e057b71a181692519854551b634786a78813f4e51695788ca9c933e2814d0901eff86facc54019d4b32c30f57ba46
data/ROADMAP.md CHANGED
@@ -1,6 +1,9 @@
1
1
  Roadmap for JsonPath
2
2
  ====================
3
3
 
4
+ *0.1.0*
5
+
6
+ * Get rid of eval. Or replace it with something sensible.
4
7
 
5
8
  *0.0.3*
6
9
  -------
@@ -29,7 +29,7 @@ class JsonPath
29
29
  handle_wildecard(node, expr, context, key, pos, &blk)
30
30
  else
31
31
  if pos == (@path.size - 1) && node && allow_eval?
32
- yield_value(blk, context, key) if eval("node #{@path[pos]}")
32
+ yield_value(blk, context, key) if instance_eval("node #{@path[pos]}")
33
33
  end
34
34
  end
35
35
 
@@ -116,9 +116,13 @@ class JsonPath
116
116
  return nil unless allow_eval? && @_current_node
117
117
 
118
118
  identifiers = /@?(\.(\w+))+/.match(exp)
119
+ # puts JsonPath.on(@_current_node, "#{identifiers}") unless identifiers.nil? ||
120
+ # @_current_node
121
+ # .methods
122
+ # .include?(identifiers[2].to_sym)
119
123
 
120
- if !identifiers.nil? &&
121
- !@_current_node.methods.include?(identifiers[2].to_sym)
124
+ unless identifiers.nil? ||
125
+ @_current_node.methods.include?(identifiers[2].to_sym)
122
126
 
123
127
  exp_to_eval = exp.dup
124
128
  exp_to_eval[identifiers[0]] = identifiers[0].split('.').map do |el|
@@ -126,12 +130,13 @@ class JsonPath
126
130
  end.join
127
131
 
128
132
  begin
129
- return eval(exp_to_eval)
133
+ return instance_eval(exp_to_eval)
130
134
  # if eval failed because of bad arguments or missing methods
131
135
  rescue StandardError
132
136
  return default
133
137
  end
134
138
  end
139
+
135
140
  # otherwise eval as is
136
141
  # TODO: this eval is wrong, because hash accessor could be nil and nil
137
142
  # cannot be compared with anything, for instance,
@@ -139,7 +144,7 @@ class JsonPath
139
144
  # node, but it's only in several nodes I wrapped this eval into rescue
140
145
  # returning false when error, but this eval should be refactored.
141
146
  begin
142
- eval(exp.gsub(/@/, '@_current_node'))
147
+ instance_eval(exp.gsub(/@/, '@_current_node'))
143
148
  rescue
144
149
  false
145
150
  end
@@ -1,3 +1,3 @@
1
1
  class JsonPath
2
- VERSION = '0.0.6'.freeze
2
+ VERSION = '0.0.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonpathv2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gergely Brautigam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-02 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json