georgepalmer-couch_foo 0.8.2 → 0.8.3
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.rdoc +2 -2
- data/VERSION.yml +2 -2
- data/lib/couch_foo/database.rb +21 -4
- metadata +21 -23
- data/LICENSE +0 -20
data/README.rdoc
CHANGED
@@ -52,7 +52,7 @@ It is recommend that you read the quick start and performance sections in the rd
|
|
52
52
|
CouchFoo::Base.set_database(:host => "http://localhost:5984", :database => "mydatabase")
|
53
53
|
CouchFoo::Base.logger = Rails.logger
|
54
54
|
|
55
|
-
If using with Rails you will need to create an initializer to do this (until proper integration is added)
|
55
|
+
If using with Rails you will need to create an initializer to do this (until proper integration is added). Also note depending on your version of CouchDB will depend on the version of the CouchREST gem you will require - CouchDB 0.9 requires CouchREST greater than 0.2 and CouchDB 0.8 requires CouchREST between 0.16 and 0.2. You will be warned on CouchFoo initialization if this is wrong.
|
56
56
|
|
57
57
|
|
58
58
|
== Examples of usage
|
@@ -127,7 +127,7 @@ Please feel free to fork and hit me with a request to merge back in. At the mom
|
|
127
127
|
* Proper integration with rails using a couchdb.yml config file
|
128
128
|
* Example ruby script for updating indexes as an external process, and the same for database compacting
|
129
129
|
* :include for database queries
|
130
|
-
* Remove dependency from CouchRest
|
130
|
+
* Remove dependency from CouchRest - keep support for both CouchDB 0.8 and 0.9 for now. Add support for attachments and log calls to server so know performance times. General tidy up of database.rb. Add support for etags?
|
131
131
|
* inline and HABTM inline associations. Also x_id and x_type properties should be automatically defined
|
132
132
|
* compatability with willpaginate and friends
|
133
133
|
* cleanup of associations, reflection, validations classes (were modified in a rush)
|
data/VERSION.yml
CHANGED
data/lib/couch_foo/database.rb
CHANGED
@@ -9,12 +9,29 @@ module CouchFoo
|
|
9
9
|
def initialize(options, bulk_save_default, *args)
|
10
10
|
self.database = CouchRest.database(options[:host] + "/" + options[:database])
|
11
11
|
self.bulk_save_default = bulk_save_default
|
12
|
-
|
12
|
+
|
13
|
+
# Check database ok
|
14
|
+
begin
|
15
|
+
self.database_version = (JSON.parse(RestClient.get(options[:host]))["version"]).gsub(/-.+/,"").to_f
|
16
|
+
rescue Exception => e
|
17
|
+
if e.is_a?(Errno::ECONNREFUSED)
|
18
|
+
raise CouchFooError, "CouchDB not started"
|
19
|
+
else
|
20
|
+
raise CouchFooError, "Error determining CouchDB version"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Due to CouchDB view API changes in 0.9 and CouchREST only supporting newer version
|
25
|
+
if version > 0.8 && CouchRest::VERSION.to_f < 0.21
|
26
|
+
raise CouchFooError, "CouchFoo requires CouchRest > 0.2 for use with CouchDB 0.9"
|
27
|
+
elsif version < 0.9 && (CouchRest::VERSION.to_f >= 0.21 || CouchRest::VERSION.to_f <= 0.15)
|
28
|
+
raise CouchFooError, "CouchFoo requires 0.15 < CouchRest < 0.21 for use with CouchDB 0.8"
|
29
|
+
end
|
13
30
|
end
|
14
31
|
|
15
32
|
def save(doc, bulk_save = bulk_save?)
|
16
33
|
begin
|
17
|
-
response = database.
|
34
|
+
response = database.save_doc(doc, bulk_save)
|
18
35
|
check_response_ok(response)
|
19
36
|
rescue Exception => e
|
20
37
|
handle_exception(e)
|
@@ -92,7 +109,7 @@ module CouchFoo
|
|
92
109
|
def handle_exception(exception)
|
93
110
|
if exception.is_a?(RestClient::ResourceNotFound)
|
94
111
|
raise DocumentNotFound, "Couldn't find document"
|
95
|
-
elsif exception.is_a?(RestClient::RequestFailed) && exception.respond_to?(:http_code) && exception.http_code == 412
|
112
|
+
elsif exception.is_a?(RestClient::RequestFailed) && exception.respond_to?(:http_code) && (exception.http_code == 412 || exception.http_code == 409)
|
96
113
|
|
97
114
|
raise DocumentConflict, "Document has been updated whilst object loaded"
|
98
115
|
else
|
@@ -114,7 +131,7 @@ module CouchFoo
|
|
114
131
|
def database
|
115
132
|
if @active_database.nil?
|
116
133
|
if self == CouchFoo::Base
|
117
|
-
raise
|
134
|
+
raise CouchFooError, "No databases setup"
|
118
135
|
else
|
119
136
|
superclass.database
|
120
137
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: georgepalmer-couch_foo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Palmer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-21 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -58,43 +58,41 @@ executables: []
|
|
58
58
|
|
59
59
|
extensions: []
|
60
60
|
|
61
|
-
extra_rdoc_files:
|
62
|
-
|
63
|
-
- LICENSE
|
61
|
+
extra_rdoc_files: []
|
62
|
+
|
64
63
|
files:
|
65
|
-
- README.rdoc
|
66
64
|
- VERSION.yml
|
65
|
+
- README.rdoc
|
67
66
|
- lib/boolean.rb
|
67
|
+
- lib/couch_foo.rb
|
68
68
|
- lib/couch_foo
|
69
|
+
- lib/couch_foo/database.rb
|
70
|
+
- lib/couch_foo/dirty.rb
|
71
|
+
- lib/couch_foo/serialization.rb
|
72
|
+
- lib/couch_foo/associations.rb
|
69
73
|
- lib/couch_foo/associations
|
74
|
+
- lib/couch_foo/associations/has_one_association.rb
|
70
75
|
- lib/couch_foo/associations/association_collection.rb
|
71
|
-
- lib/couch_foo/associations/
|
76
|
+
- lib/couch_foo/associations/has_many_association.rb
|
72
77
|
- lib/couch_foo/associations/belongs_to_association.rb
|
78
|
+
- lib/couch_foo/associations/association_proxy.rb
|
73
79
|
- lib/couch_foo/associations/belongs_to_polymorphic_association.rb
|
74
80
|
- lib/couch_foo/associations/has_and_belongs_to_many_association.rb
|
75
|
-
- lib/couch_foo/
|
76
|
-
- lib/couch_foo/associations/has_one_association.rb
|
77
|
-
- lib/couch_foo/associations.rb
|
78
|
-
- lib/couch_foo/attribute_methods.rb
|
81
|
+
- lib/couch_foo/observer.rb
|
79
82
|
- lib/couch_foo/base.rb
|
83
|
+
- lib/couch_foo/serializers
|
84
|
+
- lib/couch_foo/serializers/xml_serializer.rb
|
85
|
+
- lib/couch_foo/serializers/json_serializer.rb
|
80
86
|
- lib/couch_foo/calculations.rb
|
81
|
-
- lib/couch_foo/
|
82
|
-
- lib/couch_foo/
|
83
|
-
- lib/couch_foo/dirty.rb
|
87
|
+
- lib/couch_foo/view_methods.rb
|
88
|
+
- lib/couch_foo/attribute_methods.rb
|
84
89
|
- lib/couch_foo/named_scope.rb
|
85
|
-
- lib/couch_foo/
|
90
|
+
- lib/couch_foo/callbacks.rb
|
86
91
|
- lib/couch_foo/reflection.rb
|
87
|
-
- lib/couch_foo/serialization.rb
|
88
|
-
- lib/couch_foo/serializers
|
89
|
-
- lib/couch_foo/serializers/json_serializer.rb
|
90
|
-
- lib/couch_foo/serializers/xml_serializer.rb
|
91
|
-
- lib/couch_foo/timestamp.rb
|
92
92
|
- lib/couch_foo/validations.rb
|
93
|
-
- lib/couch_foo/
|
94
|
-
- lib/couch_foo.rb
|
93
|
+
- lib/couch_foo/timestamp.rb
|
95
94
|
- test/couch_foo_test.rb
|
96
95
|
- test/test_helper.rb
|
97
|
-
- LICENSE
|
98
96
|
has_rdoc: true
|
99
97
|
homepage: http://github.com/georgepalmer/couch_foo
|
100
98
|
post_install_message:
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2008 George Palmer
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|