couchrest 0.33 → 0.34
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.md +8 -127
- data/Rakefile +20 -36
- data/THANKS.md +2 -1
- data/history.txt +25 -0
- data/lib/couchrest.rb +5 -4
- data/lib/couchrest/core/database.rb +26 -21
- data/lib/couchrest/core/document.rb +4 -3
- data/lib/couchrest/helper/streamer.rb +11 -4
- data/lib/couchrest/mixins/attribute_protection.rb +74 -0
- data/lib/couchrest/mixins/callbacks.rb +187 -138
- data/lib/couchrest/mixins/collection.rb +3 -16
- data/lib/couchrest/mixins/extended_attachments.rb +1 -1
- data/lib/couchrest/mixins/extended_document_mixins.rb +1 -0
- data/lib/couchrest/mixins/properties.rb +71 -44
- data/lib/couchrest/mixins/validation.rb +18 -29
- data/lib/couchrest/more/casted_model.rb +29 -1
- data/lib/couchrest/more/extended_document.rb +73 -25
- data/lib/couchrest/more/property.rb +20 -1
- data/lib/couchrest/support/class.rb +81 -67
- data/lib/couchrest/support/rails.rb +12 -5
- data/lib/couchrest/validation/auto_validate.rb +5 -9
- data/lib/couchrest/validation/validators/confirmation_validator.rb +11 -3
- data/lib/couchrest/validation/validators/format_validator.rb +8 -3
- data/lib/couchrest/validation/validators/length_validator.rb +10 -5
- data/lib/couchrest/validation/validators/numeric_validator.rb +6 -1
- data/lib/couchrest/validation/validators/required_field_validator.rb +8 -3
- data/spec/couchrest/core/couchrest_spec.rb +48 -2
- data/spec/couchrest/core/database_spec.rb +22 -10
- data/spec/couchrest/core/document_spec.rb +9 -1
- data/spec/couchrest/helpers/streamer_spec.rb +31 -2
- data/spec/couchrest/more/attribute_protection_spec.rb +94 -0
- data/spec/couchrest/more/casted_extended_doc_spec.rb +2 -4
- data/spec/couchrest/more/casted_model_spec.rb +230 -1
- data/spec/couchrest/more/extended_doc_attachment_spec.rb +2 -2
- data/spec/couchrest/more/extended_doc_spec.rb +173 -15
- data/spec/couchrest/more/extended_doc_view_spec.rb +17 -10
- data/spec/couchrest/more/property_spec.rb +97 -3
- data/spec/fixtures/more/article.rb +4 -3
- data/spec/fixtures/more/card.rb +1 -1
- data/spec/fixtures/more/cat.rb +5 -3
- data/spec/fixtures/more/event.rb +4 -1
- data/spec/fixtures/more/invoice.rb +2 -2
- data/spec/fixtures/more/person.rb +1 -0
- data/spec/fixtures/more/user.rb +22 -0
- metadata +46 -13
|
@@ -2,6 +2,7 @@ class Article < CouchRest::ExtendedDocument
|
|
|
2
2
|
use_database DB
|
|
3
3
|
unique_id :slug
|
|
4
4
|
|
|
5
|
+
provides_collection :article_details, 'Article', 'by_date', :descending => true, :include_docs => true
|
|
5
6
|
view_by :date, :descending => true
|
|
6
7
|
view_by :user_id, :date
|
|
7
8
|
|
|
@@ -26,9 +27,9 @@ class Article < CouchRest::ExtendedDocument
|
|
|
26
27
|
|
|
27
28
|
timestamps!
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
before_save :generate_slug_from_title
|
|
30
31
|
|
|
31
32
|
def generate_slug_from_title
|
|
32
|
-
self['slug'] = title.downcase.gsub(/[^a-z0-9]/,'-').squeeze('-').gsub(/^\-|\-$/,'') if
|
|
33
|
+
self['slug'] = title.downcase.gsub(/[^a-z0-9]/,'-').squeeze('-').gsub(/^\-|\-$/,'') if new?
|
|
33
34
|
end
|
|
34
|
-
end
|
|
35
|
+
end
|
data/spec/fixtures/more/card.rb
CHANGED
data/spec/fixtures/more/cat.rb
CHANGED
|
@@ -4,8 +4,10 @@ class Cat < CouchRest::ExtendedDocument
|
|
|
4
4
|
# Set the default database to use
|
|
5
5
|
use_database DB
|
|
6
6
|
|
|
7
|
-
property :name
|
|
8
|
-
property :toys, :cast_as => ['CatToy'], :default => []
|
|
7
|
+
property :name, :accessible => true
|
|
8
|
+
property :toys, :cast_as => ['CatToy'], :default => [], :accessible => true
|
|
9
|
+
property :favorite_toy, :cast_as => 'CatToy', :accessible => true
|
|
10
|
+
property :number
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
class CatToy < Hash
|
|
@@ -14,5 +16,5 @@ class CatToy < Hash
|
|
|
14
16
|
|
|
15
17
|
property :name
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
validates_presence_of :name
|
|
18
20
|
end
|
data/spec/fixtures/more/event.rb
CHANGED
|
@@ -2,5 +2,8 @@ class Event < CouchRest::ExtendedDocument
|
|
|
2
2
|
use_database DB
|
|
3
3
|
|
|
4
4
|
property :subject
|
|
5
|
-
property :occurs_at, :cast_as => 'Time', :
|
|
5
|
+
property :occurs_at, :cast_as => 'Time', :init_method => 'parse'
|
|
6
|
+
property :end_date, :cast_as => 'Date', :init_method => 'parse'
|
|
7
|
+
|
|
8
|
+
|
|
6
9
|
end
|
|
@@ -11,7 +11,7 @@ class Invoice < CouchRest::ExtendedDocument
|
|
|
11
11
|
property :location
|
|
12
12
|
|
|
13
13
|
# Validation
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
validates_presence_of :client_name, :employee_name
|
|
15
|
+
validates_presence_of :location, :message => "Hey stupid!, you forgot the location"
|
|
16
16
|
|
|
17
17
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class User < CouchRest::ExtendedDocument
|
|
2
|
+
# Set the default database to use
|
|
3
|
+
use_database DB
|
|
4
|
+
property :name, :accessible => true
|
|
5
|
+
property :admin # this will be automatically protected
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class SpecialUser < CouchRest::ExtendedDocument
|
|
9
|
+
# Set the default database to use
|
|
10
|
+
use_database DB
|
|
11
|
+
property :name # this will not be protected
|
|
12
|
+
property :admin, :protected => true
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# There are two modes of protection
|
|
16
|
+
# 1) Declare accessible poperties, assume all the rest are protected
|
|
17
|
+
# property :name, :accessible => true
|
|
18
|
+
# property :admin # this will be automatically protected
|
|
19
|
+
#
|
|
20
|
+
# 2) Declare protected properties, assume all the rest are accessible
|
|
21
|
+
# property :name # this will not be protected
|
|
22
|
+
# property :admin, :protected => true
|
metadata
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: couchrest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: "0.
|
|
4
|
+
version: "0.34"
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- J. Chris Anderson
|
|
8
8
|
- Matt Aimonetti
|
|
9
|
+
- Marcos Tapajos
|
|
9
10
|
autorequire:
|
|
10
11
|
bindir: bin
|
|
11
12
|
cert_chain: []
|
|
12
13
|
|
|
13
|
-
date:
|
|
14
|
+
date: 2010-01-14 00:00:00 -02:00
|
|
14
15
|
default_executable:
|
|
15
16
|
dependencies:
|
|
16
17
|
- !ruby/object:Gem::Dependency
|
|
@@ -40,15 +41,14 @@ executables: []
|
|
|
40
41
|
extensions: []
|
|
41
42
|
|
|
42
43
|
extra_rdoc_files:
|
|
43
|
-
- README.md
|
|
44
44
|
- LICENSE
|
|
45
|
+
- README.md
|
|
45
46
|
- THANKS.md
|
|
46
47
|
files:
|
|
47
48
|
- LICENSE
|
|
48
49
|
- README.md
|
|
49
50
|
- Rakefile
|
|
50
51
|
- THANKS.md
|
|
51
|
-
- history.txt
|
|
52
52
|
- examples/model/example.rb
|
|
53
53
|
- examples/word_count/markov
|
|
54
54
|
- examples/word_count/views/books/chunked-map.js
|
|
@@ -60,6 +60,8 @@ files:
|
|
|
60
60
|
- examples/word_count/word_count.rb
|
|
61
61
|
- examples/word_count/word_count_query.rb
|
|
62
62
|
- examples/word_count/word_count_views.rb
|
|
63
|
+
- history.txt
|
|
64
|
+
- lib/couchrest.rb
|
|
63
65
|
- lib/couchrest/commands/generate.rb
|
|
64
66
|
- lib/couchrest/commands/push.rb
|
|
65
67
|
- lib/couchrest/core/adapters/restclient.rb
|
|
@@ -75,7 +77,9 @@ files:
|
|
|
75
77
|
- lib/couchrest/helper/streamer.rb
|
|
76
78
|
- lib/couchrest/helper/upgrade.rb
|
|
77
79
|
- lib/couchrest/middlewares/logger.rb
|
|
80
|
+
- lib/couchrest/mixins.rb
|
|
78
81
|
- lib/couchrest/mixins/attachments.rb
|
|
82
|
+
- lib/couchrest/mixins/attribute_protection.rb
|
|
79
83
|
- lib/couchrest/mixins/callbacks.rb
|
|
80
84
|
- lib/couchrest/mixins/class_proxy.rb
|
|
81
85
|
- lib/couchrest/mixins/collection.rb
|
|
@@ -86,7 +90,6 @@ files:
|
|
|
86
90
|
- lib/couchrest/mixins/properties.rb
|
|
87
91
|
- lib/couchrest/mixins/validation.rb
|
|
88
92
|
- lib/couchrest/mixins/views.rb
|
|
89
|
-
- lib/couchrest/mixins.rb
|
|
90
93
|
- lib/couchrest/monkeypatches.rb
|
|
91
94
|
- lib/couchrest/more/casted_model.rb
|
|
92
95
|
- lib/couchrest/more/extended_document.rb
|
|
@@ -107,7 +110,6 @@ files:
|
|
|
107
110
|
- lib/couchrest/validation/validators/method_validator.rb
|
|
108
111
|
- lib/couchrest/validation/validators/numeric_validator.rb
|
|
109
112
|
- lib/couchrest/validation/validators/required_field_validator.rb
|
|
110
|
-
- lib/couchrest.rb
|
|
111
113
|
- spec/couchrest/core/couchrest_spec.rb
|
|
112
114
|
- spec/couchrest/core/database_spec.rb
|
|
113
115
|
- spec/couchrest/core/design_spec.rb
|
|
@@ -115,6 +117,7 @@ files:
|
|
|
115
117
|
- spec/couchrest/core/server_spec.rb
|
|
116
118
|
- spec/couchrest/helpers/pager_spec.rb
|
|
117
119
|
- spec/couchrest/helpers/streamer_spec.rb
|
|
120
|
+
- spec/couchrest/more/attribute_protection_spec.rb
|
|
118
121
|
- spec/couchrest/more/casted_extended_doc_spec.rb
|
|
119
122
|
- spec/couchrest/more/casted_model_spec.rb
|
|
120
123
|
- spec/couchrest/more/extended_doc_attachment_spec.rb
|
|
@@ -122,8 +125,8 @@ files:
|
|
|
122
125
|
- spec/couchrest/more/extended_doc_subclass_spec.rb
|
|
123
126
|
- spec/couchrest/more/extended_doc_view_spec.rb
|
|
124
127
|
- spec/couchrest/more/property_spec.rb
|
|
125
|
-
- spec/fixtures/attachments/couchdb.png
|
|
126
128
|
- spec/fixtures/attachments/README
|
|
129
|
+
- spec/fixtures/attachments/couchdb.png
|
|
127
130
|
- spec/fixtures/attachments/test.html
|
|
128
131
|
- spec/fixtures/more/article.rb
|
|
129
132
|
- spec/fixtures/more/card.rb
|
|
@@ -134,6 +137,7 @@ files:
|
|
|
134
137
|
- spec/fixtures/more/person.rb
|
|
135
138
|
- spec/fixtures/more/question.rb
|
|
136
139
|
- spec/fixtures/more/service.rb
|
|
140
|
+
- spec/fixtures/more/user.rb
|
|
137
141
|
- spec/fixtures/views/lib.js
|
|
138
142
|
- spec/fixtures/views/test_view/lib.js
|
|
139
143
|
- spec/fixtures/views/test_view/only-map.js
|
|
@@ -144,12 +148,12 @@ files:
|
|
|
144
148
|
- utils/remap.rb
|
|
145
149
|
- utils/subset.rb
|
|
146
150
|
has_rdoc: true
|
|
147
|
-
homepage: http://github.com/
|
|
151
|
+
homepage: http://github.com/couchrest/couchrest
|
|
148
152
|
licenses: []
|
|
149
153
|
|
|
150
154
|
post_install_message:
|
|
151
|
-
rdoc_options:
|
|
152
|
-
|
|
155
|
+
rdoc_options:
|
|
156
|
+
- --charset=UTF-8
|
|
153
157
|
require_paths:
|
|
154
158
|
- lib
|
|
155
159
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
@@ -167,9 +171,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
167
171
|
requirements: []
|
|
168
172
|
|
|
169
173
|
rubyforge_project:
|
|
170
|
-
rubygems_version: 1.3.
|
|
174
|
+
rubygems_version: 1.3.5
|
|
171
175
|
signing_key:
|
|
172
176
|
specification_version: 3
|
|
173
177
|
summary: Lean and RESTful interface to CouchDB.
|
|
174
|
-
test_files:
|
|
175
|
-
|
|
178
|
+
test_files:
|
|
179
|
+
- spec/couchrest/core/couchrest_spec.rb
|
|
180
|
+
- spec/couchrest/core/database_spec.rb
|
|
181
|
+
- spec/couchrest/core/design_spec.rb
|
|
182
|
+
- spec/couchrest/core/document_spec.rb
|
|
183
|
+
- spec/couchrest/core/server_spec.rb
|
|
184
|
+
- spec/couchrest/helpers/pager_spec.rb
|
|
185
|
+
- spec/couchrest/helpers/streamer_spec.rb
|
|
186
|
+
- spec/couchrest/more/attribute_protection_spec.rb
|
|
187
|
+
- spec/couchrest/more/casted_extended_doc_spec.rb
|
|
188
|
+
- spec/couchrest/more/casted_model_spec.rb
|
|
189
|
+
- spec/couchrest/more/extended_doc_attachment_spec.rb
|
|
190
|
+
- spec/couchrest/more/extended_doc_spec.rb
|
|
191
|
+
- spec/couchrest/more/extended_doc_subclass_spec.rb
|
|
192
|
+
- spec/couchrest/more/extended_doc_view_spec.rb
|
|
193
|
+
- spec/couchrest/more/property_spec.rb
|
|
194
|
+
- spec/fixtures/more/article.rb
|
|
195
|
+
- spec/fixtures/more/card.rb
|
|
196
|
+
- spec/fixtures/more/cat.rb
|
|
197
|
+
- spec/fixtures/more/course.rb
|
|
198
|
+
- spec/fixtures/more/event.rb
|
|
199
|
+
- spec/fixtures/more/invoice.rb
|
|
200
|
+
- spec/fixtures/more/person.rb
|
|
201
|
+
- spec/fixtures/more/question.rb
|
|
202
|
+
- spec/fixtures/more/service.rb
|
|
203
|
+
- spec/fixtures/more/user.rb
|
|
204
|
+
- spec/spec_helper.rb
|
|
205
|
+
- examples/model/example.rb
|
|
206
|
+
- examples/word_count/word_count.rb
|
|
207
|
+
- examples/word_count/word_count_query.rb
|
|
208
|
+
- examples/word_count/word_count_views.rb
|