stone 0.1.0 → 0.1.1

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/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.1.1 2008-04-16
2
+
3
+ * Added result ordering to Resource.all
4
+
1
5
  == 0.1.0 2008-04-15
2
6
 
3
7
  * Initial release
data/config/hoe.rb CHANGED
@@ -58,7 +58,7 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
58
58
 
59
59
  # == Optional
60
60
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
61
- p.extra_deps = [['english', '>= 0.2.0'], ['validatable', '>= 1.6.7'], ['facets', '>= 2.4.1'], ['fastercsv', '>= 1.2.3']]
61
+ p.extra_deps = [['english', '>= 0.2.0'], ['validatable', '>= 1.6.7'], ['facets', '>= 2.4.1']]
62
62
 
63
63
  #p.spec_extras = {} # A hash of extra values to set in the gemspec.
64
64
 
@@ -198,8 +198,18 @@ module Stone
198
198
  objs << o[1]
199
199
  end
200
200
  else
201
+ if conditions[:order]
202
+ order = conditions[:order].to_a.flatten
203
+ conditions.delete(:order)
204
+ end
201
205
  objs = find(conditions, self.to_s.make_key)
202
206
  end
207
+ if order
208
+ raise "Order should be passed with :asc or :desc, got #{order[1].inspect}" \
209
+ unless [:asc,:desc].include? order[1]
210
+ objs.sort! {|x,y| x.send(order[0]) <=> y.send(order[0])}
211
+ objs.reverse! if order[1] == :desc
212
+ end
203
213
  objs
204
214
  end
205
215
 
data/lib/stone/version.rb CHANGED
@@ -2,7 +2,7 @@ module Stone #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Author
2
- created_at: 2008-04-14T22:09:02-07:00
2
+ created_at: 2008-04-16T10:16:10-07:00
3
3
  email: nick@cladby.com
4
4
  errors: !ruby/object:Validatable::Errors
5
5
  errors: {}
6
6
 
7
- favorite_number: 27
7
+ favorite_number: 2
8
8
  id: 1
9
9
  name: Nick DeMonner
10
10
  times_validated_hash:
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Author
2
- created_at: 2008-04-14T22:09:02-07:00
2
+ created_at: 2008-04-16T10:16:10-07:00
3
3
  email: heyo@something.com
4
4
  errors: !ruby/object:Validatable::Errors
5
5
  errors: {}
6
6
 
7
- favorite_number: 47
7
+ favorite_number: 9
8
8
  id: 2
9
9
  name: Mike McMichaels
10
10
  times_validated_hash:
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Author
2
- created_at: 2008-04-14T22:09:02-07:00
2
+ created_at: 2008-04-16T10:16:10-07:00
3
3
  email: weyo@something.com
4
4
  errors: !ruby/object:Validatable::Errors
5
5
  errors: {}
6
6
 
7
- favorite_number: 30
7
+ favorite_number: 33
8
8
  id: 3
9
9
  name: Mary Poppins
10
10
  times_validated_hash:
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Author
2
- created_at: 2008-04-14T22:09:02-07:00
2
+ created_at: 2008-04-16T10:16:10-07:00
3
3
  email: nick@gmail.com
4
4
  errors: !ruby/object:Validatable::Errors
5
5
  errors: {}
6
6
 
7
- favorite_number: 49
7
+ favorite_number: 15
8
8
  id: 4
9
9
  name: Nick Hicklesby
10
10
  times_validated_hash:
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Author
2
- created_at: 2008-04-14T22:09:02-07:00
2
+ created_at: 2008-04-16T10:16:10-07:00
3
3
  email: chariot_guy@hotmail.com
4
4
  errors: !ruby/object:Validatable::Errors
5
5
  errors: {}
6
6
 
7
- favorite_number: 40
7
+ favorite_number: 24
8
8
  id: 5
9
9
  name: Ben Hurr
10
10
  times_validated_hash:
@@ -186,5 +186,14 @@ describe Stone::Resource do
186
186
  authors = Author.all(:name.matches => /o/, :created_at.lt => DateTime.now>>1)
187
187
  authors.size.should == 2
188
188
  end
189
+
190
+ it "should allow for ordering of query results" do
191
+ authors = Author.all(:created_at.lt => DateTime.now>>1, :order => {:created_at => :desc})
192
+ authors.last.name.should == "Nick DeMonner"
193
+ end
194
+
195
+ it "should only accept :asc or :desc for ordering" do
196
+ lambda {Author.all(:created_at.lt => DateTime.now>>1, :order => {:created_at => :cool})}.should raise_error
197
+ end
189
198
 
190
199
  end
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>Stone: Dead-Simple Data Persistence</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/stone"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/stone" class="numbers">0.1.0</a>
36
+ <a href="http://rubyforge.org/projects/stone" class="numbers">0.1.1</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;stone&#8217;</h1>
39
39
 
@@ -239,6 +239,10 @@ your data gets persisted to files within <code>myapp/datastore/</code>.</p>
239
239
  <span class="comment"># brings back all authors whose email contains &quot;gmail.com&quot;, and who </span>
240
240
  <span class="comment"># were created before today</span>
241
241
  <span class="constant">Author</span><span class="punct">.</span><span class="ident">all</span><span class="punct">(</span><span class="symbol">:email</span><span class="punct">.</span><span class="ident">includes</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">gmail.com</span><span class="punct">&quot;,</span> <span class="symbol">:created_at</span><span class="punct">.</span><span class="ident">lt</span> <span class="punct">=&gt;</span> <span class="constant">DateTime</span><span class="punct">.</span><span class="ident">now</span><span class="punct">)</span>
242
+
243
+ <span class="comment"># brings back all Authors created before today, and orders them descending</span>
244
+ <span class="comment"># from most recent to least</span>
245
+ <span class="constant">Author</span><span class="punct">.</span><span class="ident">all</span><span class="punct">(</span><span class="symbol">:created_at</span><span class="punct">.</span><span class="ident">lt</span> <span class="punct">=&gt;</span> <span class="constant">DateTime</span><span class="punct">.</span><span class="ident">now</span><span class="punct">,</span> <span class="symbol">:order</span> <span class="punct">=&gt;</span> <span class="punct">{</span><span class="symbol">:created_at</span> <span class="punct">=&gt;</span> <span class="symbol">:desc</span><span class="punct">})</span>
242
246
  </pre></li>
243
247
  </ul>
244
248
 
@@ -381,7 +385,7 @@ commit. =D</p>
381
385
 
382
386
  <p>Comments are welcome. Join me in the <span class="caps">IRC</span> channel #stone on freenode.</p>
383
387
  <p class="coda">
384
- Nick DeMonner, 14th April 2008<br>
388
+ Nick DeMonner, 16th April 2008<br>
385
389
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
386
390
  </p>
387
391
  </div>
data/website/index.txt CHANGED
@@ -148,6 +148,10 @@ h3(#gppd). Get, Post, Put, and Delete
148
148
  # brings back all authors whose email contains "gmail.com", and who
149
149
  # were created before today
150
150
  Author.all(:email.includes => "gmail.com", :created_at.lt => DateTime.now)
151
+
152
+ # brings back all Authors created before today, and orders them descending
153
+ # from most recent to least
154
+ Author.all(:created_at.lt => DateTime.now, :order => {:created_at => :desc})
151
155
  </pre>
152
156
 
153
157
  * Posting
@@ -102,8 +102,9 @@ pre, code {
102
102
  .expr { color: #daefa3; }
103
103
 
104
104
  #version {
105
+ width:250px;
105
106
  float: right;
106
- text-align: right;
107
+ text-align: center;
107
108
  font-family: sans-serif;
108
109
  font-weight: normal;
109
110
  background-color: #cb6b4e;
@@ -114,6 +115,7 @@ pre, code {
114
115
  }
115
116
 
116
117
  #version .numbers {
118
+ text-align:center;
117
119
  display: block;
118
120
  font-size: 4em;
119
121
  line-height: 0.8em;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick DeMonner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-15 00:00:00 -07:00
12
+ date: 2008-04-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -39,15 +39,6 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.4.1
41
41
  version:
42
- - !ruby/object:Gem::Dependency
43
- name: fastercsv
44
- version_requirement:
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 1.2.3
50
- version:
51
42
  description: Super-simple data persistence layer created for small applications.
52
43
  email:
53
44
  - nick@cladby.com