jsonpath 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,6 +48,10 @@ class JsonPath
48
48
  enum_on(object).to_a
49
49
  end
50
50
 
51
+ def first(object)
52
+ enum_on(object).first
53
+ end
54
+
51
55
  def enum_on(object)
52
56
  JsonPath::Enumerable.new(self, object)
53
57
  end
@@ -1,3 +1,3 @@
1
1
  class JsonPath
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -86,6 +86,10 @@ describe "JsonPath" do
86
86
  JsonPath.new('$..book[(@.length-2)]').on(@object).to_a.should == [@object['store']['book'][2]]
87
87
  end
88
88
 
89
+ it "should support first" do
90
+ JsonPath.new('$..book[(@.length-2)]').first(@object) == @object['store']['book'][2]
91
+ end
92
+
89
93
  it "should correct retrieve the right number of all nodes" do
90
94
  JsonPath.new('$..*').on(@object).to_a.size.should == 29
91
95
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonpath
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Hull