plucky 0.4.1 → 0.4.2
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.
- data/lib/plucky.rb +5 -9
- data/lib/plucky/criteria_hash.rb +1 -1
- data/lib/plucky/extensions/symbol.rb +1 -1
- data/lib/plucky/pagination.rb +6 -0
- data/lib/plucky/version.rb +1 -2
- data/test/plucky/test_criteria_hash.rb +6 -2
- data/test/test_symbol_operator.rb +9 -3
- metadata +16 -8
data/lib/plucky.rb
CHANGED
@@ -2,17 +2,13 @@
|
|
2
2
|
require 'set'
|
3
3
|
require 'mongo'
|
4
4
|
require 'plucky/extensions'
|
5
|
+
require 'plucky/criteria_hash'
|
6
|
+
require 'plucky/options_hash'
|
7
|
+
require 'plucky/query'
|
8
|
+
require 'plucky/pagination'
|
5
9
|
|
6
10
|
module Plucky
|
7
|
-
autoload :
|
8
|
-
autoload :OptionsHash, 'plucky/options_hash'
|
9
|
-
autoload :Query, 'plucky/query'
|
10
|
-
autoload :Version, 'plucky/version'
|
11
|
-
|
12
|
-
module Pagination
|
13
|
-
autoload :Decorator, 'plucky/pagination/decorator'
|
14
|
-
autoload :Paginator, 'plucky/pagination/paginator'
|
15
|
-
end
|
11
|
+
autoload :Version, 'plucky/version'
|
16
12
|
|
17
13
|
# Array of methods that actually perform queries
|
18
14
|
Methods = [
|
data/lib/plucky/criteria_hash.rb
CHANGED
@@ -120,7 +120,7 @@ module Plucky
|
|
120
120
|
case value
|
121
121
|
when Array, Set
|
122
122
|
value.map! { |v| Plucky.to_object_id(v) } if object_id?(parent_key)
|
123
|
-
parent_key == key &&
|
123
|
+
parent_key == key && ![:$or, :$and].include?(key) ? {'$in' => value.to_a} : value.to_a
|
124
124
|
when Time
|
125
125
|
value.utc
|
126
126
|
when String
|
data/lib/plucky/version.rb
CHANGED
@@ -150,10 +150,14 @@ class CriteriaHashTest < Test::Unit::TestCase
|
|
150
150
|
CriteriaHash.new(:numbers => {'$all' => [1,2,3]})[:numbers].should == {'$all' => [1,2,3]}
|
151
151
|
CriteriaHash.new(:numbers => {'$any' => [1,2,3]})[:numbers].should == {'$any' => [1,2,3]}
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
should "not turn value to $in with $or key" do
|
155
155
|
CriteriaHash.new(:$or => [{:numbers => 1}, {:numbers => 2}] )[:$or].should == [{:numbers=>1}, {:numbers=>2}]
|
156
156
|
end
|
157
|
+
|
158
|
+
should "not turn value to $in with $and key" do
|
159
|
+
CriteriaHash.new(:$and => [{:numbers => 1}, {:numbers => 2}] )[:$and].should == [{:numbers=>1}, {:numbers=>2}]
|
160
|
+
end
|
157
161
|
end
|
158
162
|
|
159
163
|
context "with set value" do
|
@@ -257,7 +261,7 @@ class CriteriaHashTest < Test::Unit::TestCase
|
|
257
261
|
c2 = CriteriaHash.new(:foo => {'$all' => [1, 4, 5]})
|
258
262
|
c1.merge(c2).should == CriteriaHash.new(:foo => {'$in' => [1, 2, 3], '$all' => [1, 4, 5]})
|
259
263
|
end
|
260
|
-
|
264
|
+
|
261
265
|
should "not update mergee" do
|
262
266
|
c1 = CriteriaHash.new(:foo => 'bar')
|
263
267
|
c2 = CriteriaHash.new(:foo => 'baz')
|
@@ -17,18 +17,24 @@ class SymbolOperatorTest < Test::Unit::TestCase
|
|
17
17
|
should "be true if field and operator are equal" do
|
18
18
|
SymbolOperator.new(:foo, 'in').should == SymbolOperator.new(:foo, 'in')
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
should "be false if fields are equal but operators are not" do
|
22
22
|
SymbolOperator.new(:foo, 'in').should_not == SymbolOperator.new(:foo, 'all')
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
should "be false if operators are equal but fields are not" do
|
26
26
|
SymbolOperator.new(:foo, 'in').should_not == SymbolOperator.new(:bar, 'in')
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
should "be false if neither are equal" do
|
30
30
|
SymbolOperator.new(:foo, 'in').should_not == SymbolOperator.new(:bar, 'all')
|
31
31
|
end
|
32
|
+
|
33
|
+
should "be false if other isn't an symbol operator" do
|
34
|
+
assert_nothing_raised do
|
35
|
+
SymbolOperator.new(:foo, 'in').should_not == 'foo.in'
|
36
|
+
end
|
37
|
+
end
|
32
38
|
end
|
33
39
|
|
34
40
|
context "<=>" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plucky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Nunemaker
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-10-08 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: mongo
|
@@ -25,12 +25,20 @@ dependencies:
|
|
25
25
|
requirements:
|
26
26
|
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
28
|
+
hash: 27
|
29
29
|
segments:
|
30
30
|
- 1
|
31
31
|
- 3
|
32
|
+
- 0
|
33
|
+
version: 1.3.0
|
34
|
+
- - <
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
hash: 3
|
37
|
+
segments:
|
32
38
|
- 1
|
33
|
-
|
39
|
+
- 5
|
40
|
+
- 0
|
41
|
+
version: 1.5.0
|
34
42
|
type: :runtime
|
35
43
|
version_requirements: *id001
|
36
44
|
description:
|
@@ -51,6 +59,7 @@ files:
|
|
51
59
|
- lib/plucky/options_hash.rb
|
52
60
|
- lib/plucky/pagination/decorator.rb
|
53
61
|
- lib/plucky/pagination/paginator.rb
|
62
|
+
- lib/plucky/pagination.rb
|
54
63
|
- lib/plucky/query.rb
|
55
64
|
- lib/plucky/version.rb
|
56
65
|
- lib/plucky.rb
|
@@ -95,10 +104,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
104
|
requirements: []
|
96
105
|
|
97
106
|
rubyforge_project:
|
98
|
-
rubygems_version: 1.
|
107
|
+
rubygems_version: 1.8.9
|
99
108
|
signing_key:
|
100
109
|
specification_version: 3
|
101
110
|
summary: Thin layer over the ruby driver that allows you to quickly grab hold of your data (pluck it!).
|
102
111
|
test_files: []
|
103
112
|
|
104
|
-
has_rdoc:
|