mongo_inspired_compare 0.0.3 → 0.0.4

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: fb2f1467451d788851b248b0dac9ed146ccd58a3
4
- data.tar.gz: e5dec85ca82a88cbdb506cda180e2caaf94d567a
3
+ metadata.gz: 246b1a23ad1ffa7cb2cd56a2d197cd8b2efd744c
4
+ data.tar.gz: 7549dd194bcc20de9559ac758525efd8c4b9b779
5
5
  SHA512:
6
- metadata.gz: be0e7d866206ff118b193c07ec6ab9bd0b8e922281ae4c7a10390fcf59bc060382c3b29519351d1cc34a5eac1d526adb337db66acad5d8a2d16113a957d08b60
7
- data.tar.gz: 8788cc7f73d93378841962ab2b87ca6ab2ff9e5def1f8d7d83a5c3dc3a9826a9a071f2c542f1f5662cbbd8613048eb92fea410ab85fd5bdd4d94e156f0e8ccf9
6
+ metadata.gz: 28f5f64ceb3b97a5fc27412891c388a4d593b009f6d9c8878ed3f597ddaa89e05714bc19a8476c8e0639bcec41b40ab3b286ac9d70ab04dc54f9e45cfd7ff3f3
7
+ data.tar.gz: e9a8495675614a4e9292d5966e3ce673ce55d19bce2d871647bcd0bc751460c83187db23042d9a78d756758133eed5e638293f2ac40814676d03c14a325724d8
@@ -83,6 +83,11 @@ class MongoInspiredCompare
83
83
  end
84
84
  end
85
85
 
86
+
87
+ def self.compare_object( obj, filter )
88
+ filter.all? {|k,v| MongoInspiredCompare.compare( obj[k], v)}
89
+ end
90
+
86
91
  private
87
92
  def self.numerical( str )
88
93
  (str and str.strip =~ /^[\-\d\.]+$/) ? str.to_f : nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_inspired_compare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Do
@@ -18,7 +18,6 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - lib/mongo_inspired_compare.rb
21
- - test_mongo_inspired_compare.rb
22
21
  homepage: https://github.com/davehdo/mongo_inspired_compare
23
22
  licenses:
24
23
  - MIT
@@ -1,43 +0,0 @@
1
- require "./lib/mongo_inspired_compare.rb"
2
-
3
- def expect( val, criterion, to_return )
4
-
5
- puts "> MongoInspiredCompare.compare( #{ val.inspect }, #{ criterion} )"
6
- puts "=> #{ actually_returned = MongoInspiredCompare.compare( val, criterion) }\n\n"
7
-
8
- puts "===================== expected #{ to_return }" unless to_return == actually_returned
9
- end
10
-
11
-
12
- puts "\n## Basic Comparisons"
13
- expect( 5, 5, true)
14
-
15
- expect( 5, 6, false)
16
-
17
-
18
- puts "\n## Basic Operators"
19
- expect( 5, {"$gte" => 5}, true)
20
-
21
- expect( 5, {"$lt" => 5}, false)
22
-
23
- expect( 5, {"$in" => [1, 2, 3, 4, 5]}, true)
24
-
25
- expect( 5, {"$nin" => [1, 2, 3, 4, 5]}, false)
26
-
27
- puts "\n## Nesting"
28
-
29
- expect( 5, {"$in" => [{"$lt" => 5}, {"$gte" => 5}]}, true)
30
-
31
- puts "\n## And/or Operators"
32
-
33
- expect( 5, {"$or" => [{"$lt" => 5}, {"$gte" => 5}]}, true)
34
-
35
- expect( 5, {"$and" => [{"$lt" => 5}, {"$gte" => 5}]}, false)
36
-
37
-
38
- puts "\n## Invariance"
39
- expect( "5", {"$gte" => 5}, true)
40
-
41
- expect( "5x", {"$gte" => 5}, false)
42
-
43
-