mongo-parser-rb 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e5c3c9944b9b2262bf312b33c3de09ab007635c
4
- data.tar.gz: da70df6109d44a394390c39bcd917e78430a6797
3
+ metadata.gz: a3a58b44007f8b742abfe589c9182b839a70eaa9
4
+ data.tar.gz: f2e40e2eb6870f62b0daf5ac4ff7311ddd0484e9
5
5
  SHA512:
6
- metadata.gz: 8530e477fa457e89422e3804231d746b82dece1f0b7d0730273d3481aca7b216c9533bc7a2b317f1bf9e8a6655fa544c669344a98913db80354ce799426097ad
7
- data.tar.gz: c640747cd0855739e8d422f79105ff70f01f9f61d1346f7ced2a833389553d23261abea5654f6dcd122d2447314346a3bf80bba952fdea64ffde542ac8a8b0cd
6
+ metadata.gz: 7d21bbdf37312f90431e1cd9c7843ceca3a512173e77a2fe6f01c39683198f9a62d691c5c65e8e4ac8b5d9403a81f45e505c99bfb164cfa5087e9e632bf6cf18
7
+ data.tar.gz: d5b1516dba68c439e41f764577558a3c2fd438091ded9e40d819ce12d65a8733484c37bd83c4b7a03d6214414c91b853d4037249a59b5839e0812a7f594cc03b
@@ -11,6 +11,7 @@ module MongoParserRB
11
11
  @field_parts.reduce(document) do |value, field|
12
12
  case value
13
13
  when Array
14
+ return [] if value.empty?
14
15
  value[field.to_i]
15
16
  when Hash
16
17
  value[field]
@@ -1,3 +1,3 @@
1
1
  module MongoParserRB
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -27,6 +27,11 @@ class FieldTest < MiniTest::Unit::TestCase
27
27
  field = MongoParserRB::Field.new(:"something.array.0")
28
28
  assert_equal 1, field.value_in_document(:something => {:array => [1,2]})
29
29
  end
30
+
31
+ def test_returning_empty_array
32
+ field = MongoParserRB::Field.new(:"something.array.name")
33
+ assert_equal [], field.value_in_document(:something => {:array => []})
34
+ end
30
35
 
31
36
  def test_returning_hash_in_array
32
37
  field = MongoParserRB::Field.new(:"something.array.0.key")
@@ -142,6 +142,11 @@ class QueryTest < MiniTest::Unit::TestCase
142
142
  assert query.matches_document?(:custom_data => {:value => 5})
143
143
  refute query.matches_document?({})
144
144
  end
145
+
146
+ def test_nil_by_empty
147
+ query = MongoParserRB::Query.parse({:"user_event_summaries.name" => {:$ne => "second-support"}})
148
+ assert query.matches_document?({"user_event_summaries" => []})
149
+ end
145
150
 
146
151
  def test_integer_in
147
152
  query = MongoParserRB::Query.parse(:integer_key => {:$in => [1,2]})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo-parser-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben McRedmond
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-24 00:00:00.000000000 Z
11
+ date: 2014-03-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Parse and evaluate mongo queries in Ruby
14
14
  email:
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  version: '0'
53
53
  requirements: []
54
54
  rubyforge_project:
55
- rubygems_version: 2.0.14
55
+ rubygems_version: 2.0.3
56
56
  signing_key:
57
57
  specification_version: 4
58
58
  summary: Parse and evaluate mongo queries in Ruby