mordor 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mordor/resource.rb +4 -2
- data/mordor.gemspec +2 -2
- data/spec/mordor/resource_spec.rb +15 -0
- metadata +4 -4
data/lib/mordor/resource.rb
CHANGED
@@ -72,8 +72,8 @@ module Mordor
|
|
72
72
|
end
|
73
73
|
|
74
74
|
module ClassMethods
|
75
|
-
def all
|
76
|
-
Collection.new(self, collection.find)
|
75
|
+
def all(options = {})
|
76
|
+
Collection.new(self, collection.find({}, options).to_a)
|
77
77
|
end
|
78
78
|
|
79
79
|
def collection
|
@@ -116,6 +116,8 @@ module Mordor
|
|
116
116
|
start = day.to_datetime.to_date.to_time
|
117
117
|
end_of_day = (day.to_date + 1).to_datetime.to_date.to_time
|
118
118
|
end
|
119
|
+
hash = {:at => {'$gte' => start, '$lt' => end_of_day}}
|
120
|
+
pp hash
|
119
121
|
cursor = collection.find(:at => {'$gte' => start, '$lt' => end_of_day})
|
120
122
|
Collection.new(self, cursor)
|
121
123
|
end
|
data/mordor.gemspec
CHANGED
@@ -2,8 +2,8 @@ Gem::Specification.new do |s|
|
|
2
2
|
s.name = "mordor"
|
3
3
|
|
4
4
|
# Do not set the version and date field manually, this is done by the release script
|
5
|
-
s.version = "0.1.
|
6
|
-
s.date = "2011-11-
|
5
|
+
s.version = "0.1.2"
|
6
|
+
s.date = "2011-11-11"
|
7
7
|
|
8
8
|
s.summary = "mordor"
|
9
9
|
s.description = <<-eos
|
@@ -128,6 +128,21 @@ describe "with respect to resources" do
|
|
128
128
|
collection.should_not be_nil
|
129
129
|
collection.size.should == 2
|
130
130
|
end
|
131
|
+
|
132
|
+
it "should be possible to limit the number of returned resources" do
|
133
|
+
TestResource.all.should_not be_nil
|
134
|
+
TestResource.all.size.should == 0
|
135
|
+
|
136
|
+
resource = TestResource.new({:first => "first", :second => "second"})
|
137
|
+
resource.save.should be_true
|
138
|
+
|
139
|
+
resource2 = TestResource.new({:first => "first", :second => "second"})
|
140
|
+
resource2.save.should be_true
|
141
|
+
|
142
|
+
collection = TestResource.all(:limit => 1)
|
143
|
+
collection.should_not be_nil
|
144
|
+
collection.size.should == 1
|
145
|
+
end
|
131
146
|
end
|
132
147
|
|
133
148
|
context "with respect to collections" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mordor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jan-Willem Koelewijn
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-11-
|
19
|
+
date: 2011-11-11 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|