couch_potato 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,9 +1,20 @@
1
1
  ## Changes
2
2
 
3
+ ### 0.5.3
4
+ * added CouchPotato::Database.load! (langalex)
5
+
6
+ ### 0.5.2
7
+ * added CouchPotato::Database#first and #first! methods (langalex)
8
+ * added workaround for BigCouch/Cloudant to not add null reduce functions to views (langalex)
9
+ * don't add _attachments if there are none (langalex)
10
+
11
+ ### 0.5.1
12
+ * fixed issues with tzinfo gem (Bernd Ahlers)
13
+
3
14
  ### 0.5.0
4
- * time zone support (Time properties are now converted to current Time.zone)
5
- * lazy property initialization (performance!)
6
- * active_model is now the default validation framework
15
+ * time zone support (Time properties are now converted to current Time.zone) (langalex)
16
+ * lazy property initialization (performance!) (langalex)
17
+ * active_model is now the default validation framework (langalex)
7
18
 
8
19
  ### 0.4.0
9
20
  * ruby 1.9.2 compatibility (langalex)
data/README.md CHANGED
@@ -254,11 +254,17 @@ If you have larger structures and you only want to load some attributes you can
254
254
  view :all, :key => :created_at, :properties => [:name], :type => :properties
255
255
  end
256
256
 
257
- CouchPotato.database.view(User.everyone).first.name # => "joe"
258
- CouchPotato.database.view(User.everyone).first.bio # => nil
257
+ CouchPotato.database.view(User.everyone).first.name # => "joe"
258
+ CouchPotato.database.view(User.everyone).first.bio # => nil
259
259
 
260
- CouchPotato.database.first(User.everyone).name # => "joe" # convenience function, returns nil if nothing found
261
- CouchPotato.database.first!(User.everyone) # would raise CouchPotato::NotFound if nothing was found
260
+ CouchPotato.database.first(User.everyone).name # => "joe" # convenience function, returns nil if nothing found
261
+ CouchPotato.database.first!(User.everyone) # would raise CouchPotato::NotFound if nothing was found
262
+
263
+ If you want Rails to automatically show a 404 page when `CouchPotato::NotFound` is raised add this to your `ApplicationController`:
264
+
265
+ rescue_from CouchPotato::NotFound {
266
+ render(:file => '404.html', :status => :not_found, :layout => false)
267
+ }
262
268
 
263
269
  You can also pass in custom map/reduce functions with the custom view spec:
264
270
 
@@ -110,6 +110,10 @@ module CouchPotato
110
110
  end
111
111
  end
112
112
  alias_method :load, :load_document
113
+
114
+ def load!(id)
115
+ load(id) || raise(CouchPotato::NotFound)
116
+ end
113
117
 
114
118
  def inspect #:nodoc:
115
119
  "#<CouchPotato::Database @root=\"#{couchrest_database.root}\">"
@@ -1,3 +1,3 @@
1
1
  module CouchPotato
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -64,7 +64,17 @@ describe CouchPotato::Database, 'load' do
64
64
  db = CouchPotato::Database.new(stub('couchrest db', :info => nil, :get => Parent::Child.json_create({JSON.create_id => 'Parent::Child'})))
65
65
  db.load('1').class.should == Parent::Child
66
66
  end
67
-
67
+ end
68
+
69
+ describe CouchPotato::Database, 'load!' do
70
+ it "should raise an error if no document found" do
71
+ couchrest_db = stub('couchrest db', :info => nil)
72
+ couchrest_db.stub(:get).and_raise(RestClient::ResourceNotFound)
73
+ db = CouchPotato::Database.new(couchrest_db)
74
+ lambda {
75
+ db.load! '1'
76
+ }.should raise_error(CouchPotato::NotFound)
77
+ end
68
78
  end
69
79
 
70
80
  describe CouchPotato::Database, 'save_document' do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: couch_potato
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.2
5
+ version: 0.5.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Alexander Lang
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-18 00:00:00 +02:00
13
+ date: 2011-04-27 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency