mongo_doc 0.6.6 → 0.6.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.
- data/README.textile +1 -1
- data/VERSION +1 -1
- data/features/step_definitions/query_steps.rb +4 -1
- data/features/using_criteria.feature +6 -0
- data/lib/mongo_doc/contexts/mongo.rb +9 -5
- data/lib/mongo_doc.rb +1 -1
- data/mongo_doc.gemspec +3 -5
- data/spec/contexts/mongo_spec.rb +6 -0
- metadata +4 -6
- data/TODO +0 -40
data/README.textile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.7
|
@@ -10,6 +10,10 @@ When "I also want a $number query with criteria $criteria" do |number, criteria|
|
|
10
10
|
instance_variable_set("@#{number}", eval("query.#{criteria}"))
|
11
11
|
end
|
12
12
|
|
13
|
+
When /^I requery$/ do
|
14
|
+
# do nothing
|
15
|
+
end
|
16
|
+
|
13
17
|
Then /^the query result is equal to the document '(.*)'$/ do |name|
|
14
18
|
doc = instance_variable_get("@#{name}")
|
15
19
|
query.should == doc
|
@@ -63,4 +67,3 @@ end
|
|
63
67
|
Then /^the (.+) query (is|is not) (empty|blank)$/ do |number, is, empty|
|
64
68
|
instance_variable_get("@#{number}").send("#{empty}?").should == (is == 'is')
|
65
69
|
end
|
66
|
-
|
@@ -123,6 +123,12 @@ Feature: MongoDoc::Base
|
|
123
123
|
Then the first query result is the document 'contractor'
|
124
124
|
And the last query result is the document 'rocketeer'
|
125
125
|
|
126
|
+
Scenario: Criteria can be reused
|
127
|
+
Given I query contacts with criteria in('interests' => ['ruby', 'rails']).order_by([[:name, :desc]])
|
128
|
+
And the first query result is the document 'rocketeer'
|
129
|
+
When I requery
|
130
|
+
Then the first query result is the document 'rocketeer'
|
131
|
+
|
126
132
|
Scenario: Using skip on results
|
127
133
|
When I query contacts with criteria all('interests' => ['ruby', 'rails']).skip(1)
|
128
134
|
Then the size of the query result is 2
|
@@ -55,7 +55,7 @@ module MongoDoc
|
|
55
55
|
#
|
56
56
|
# An +Integer+ count of documents.
|
57
57
|
def count
|
58
|
-
@count ||= collection.find(selector,
|
58
|
+
@count ||= collection.find(selector, find_options).count
|
59
59
|
end
|
60
60
|
|
61
61
|
# Gets an array of distinct values for the supplied field across the
|
@@ -75,7 +75,7 @@ module MongoDoc
|
|
75
75
|
#
|
76
76
|
# <tt>context.blank?</tt>
|
77
77
|
def empty?
|
78
|
-
collection.find_one(selector,
|
78
|
+
collection.find_one(selector, find_options).nil?
|
79
79
|
end
|
80
80
|
alias blank? empty?
|
81
81
|
|
@@ -92,7 +92,7 @@ module MongoDoc
|
|
92
92
|
#
|
93
93
|
# An enumerable +Cursor+.
|
94
94
|
def execute(paginating = false)
|
95
|
-
cursor = collection.find(selector,
|
95
|
+
cursor = collection.find(selector, find_options)
|
96
96
|
if cursor
|
97
97
|
@count = cursor.count if paginating
|
98
98
|
cursor
|
@@ -163,7 +163,7 @@ module MongoDoc
|
|
163
163
|
def last
|
164
164
|
sorting = options[:sort] || [[:_id, :asc]]
|
165
165
|
options[:sort] = sorting.collect { |option| [ option[0], option[1].invert ] }
|
166
|
-
collection.find_one(selector,
|
166
|
+
collection.find_one(selector, find_options)
|
167
167
|
end
|
168
168
|
|
169
169
|
MAX_REDUCE = "function(obj, prev) { if (prev.max == 'start') { prev.max = obj.[field]; } " +
|
@@ -216,7 +216,7 @@ module MongoDoc
|
|
216
216
|
#
|
217
217
|
# The first document in the collection.
|
218
218
|
def one
|
219
|
-
collection.find_one(selector,
|
219
|
+
collection.find_one(selector, find_options)
|
220
220
|
end
|
221
221
|
|
222
222
|
alias first one
|
@@ -267,6 +267,10 @@ module MongoDoc
|
|
267
267
|
end
|
268
268
|
end
|
269
269
|
end
|
270
|
+
|
271
|
+
def find_options
|
272
|
+
options.except(:cache, :enslave)
|
273
|
+
end
|
270
274
|
end
|
271
275
|
end
|
272
276
|
end
|
data/lib/mongo_doc.rb
CHANGED
data/mongo_doc.gemspec
CHANGED
@@ -5,17 +5,16 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongo_doc}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Les Hill"]
|
12
|
-
s.date = %q{2010-07-
|
12
|
+
s.date = %q{2010-07-10}
|
13
13
|
s.description = %q{ODM for MongoDB}
|
14
14
|
s.email = %q{leshill@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
"README.textile"
|
18
|
-
"TODO"
|
17
|
+
"README.textile"
|
19
18
|
]
|
20
19
|
s.files = [
|
21
20
|
".document",
|
@@ -28,7 +27,6 @@ Gem::Specification.new do |s|
|
|
28
27
|
"LICENSE",
|
29
28
|
"README.textile",
|
30
29
|
"Rakefile",
|
31
|
-
"TODO",
|
32
30
|
"VERSION",
|
33
31
|
"examples/simple_document.rb",
|
34
32
|
"examples/simple_object.rb",
|
data/spec/contexts/mongo_spec.rb
CHANGED
@@ -69,6 +69,12 @@ describe "MongoDoc::Contexts::Mongo" do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
context "#execute" do
|
72
|
+
it "uses filtered options" do
|
73
|
+
collection.should_receive(:find).with({},{})
|
74
|
+
criteria.cache
|
75
|
+
context.execute
|
76
|
+
end
|
77
|
+
|
72
78
|
it "uses find" do
|
73
79
|
collection.should_receive(:find)
|
74
80
|
context.execute
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_doc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 7
|
10
|
+
version: 0.6.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Les Hill
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-10 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -145,7 +145,6 @@ extensions: []
|
|
145
145
|
extra_rdoc_files:
|
146
146
|
- LICENSE
|
147
147
|
- README.textile
|
148
|
-
- TODO
|
149
148
|
files:
|
150
149
|
- .document
|
151
150
|
- .gitignore
|
@@ -157,7 +156,6 @@ files:
|
|
157
156
|
- LICENSE
|
158
157
|
- README.textile
|
159
158
|
- Rakefile
|
160
|
-
- TODO
|
161
159
|
- VERSION
|
162
160
|
- examples/simple_document.rb
|
163
161
|
- examples/simple_object.rb
|
data/TODO
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
As of 2010-03-06
|
2
|
-
|
3
|
-
Associations
|
4
|
-
------------
|
5
|
-
|
6
|
-
Pull associations out of attributes and refactor
|
7
|
-
|
8
|
-
Criteria
|
9
|
-
--------
|
10
|
-
|
11
|
-
Make critieria module; include into CriteriaProxy, Association?
|
12
|
-
page, per_page, paginate shuould be wrapped or not?
|
13
|
-
|
14
|
-
Contexts
|
15
|
-
--------
|
16
|
-
|
17
|
-
Extract Mongo context as module, Document#collection => klass.collection Collection#collection => klass
|
18
|
-
|
19
|
-
Documentation
|
20
|
-
-------------
|
21
|
-
|
22
|
-
How to get started with Rails
|
23
|
-
|
24
|
-
Dynamic Attributes
|
25
|
-
------------------
|
26
|
-
|
27
|
-
Document#[] => reads attribute
|
28
|
-
Document#[]= => writes attribute
|
29
|
-
Document#dynamic_attributes => key, value for each dynamic attribute
|
30
|
-
Document#dynamic_attribute_names => list of dynamic attribute names
|
31
|
-
|
32
|
-
Validations
|
33
|
-
-----------
|
34
|
-
|
35
|
-
validates_hash_keys :has_hash_name, :in => [array of names]
|
36
|
-
|
37
|
-
|
38
|
-
Q
|
39
|
-
-
|
40
|
-
What is Criteria#ids
|