samflores-couchrest 0.2.1 → 0.12.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -34
- data/Rakefile +5 -2
- data/bin/couchdir +20 -0
- data/examples/model/example.rb +13 -19
- data/examples/word_count/word_count.rb +24 -3
- data/examples/word_count/word_count_query.rb +6 -7
- data/lib/couchrest/core/database.rb +49 -126
- data/lib/couchrest/core/document.rb +25 -58
- data/lib/couchrest/core/model.rb +612 -0
- data/lib/couchrest/core/server.rb +10 -47
- data/lib/couchrest/core/validations.rb +328 -0
- data/lib/couchrest/monkeypatches.rb +0 -95
- data/lib/couchrest.rb +10 -57
- data/spec/couchrest/core/database_spec.rb +68 -183
- data/spec/couchrest/core/design_spec.rb +1 -1
- data/spec/couchrest/core/document_spec.rb +104 -285
- data/spec/couchrest/core/model_spec.rb +855 -0
- data/spec/couchrest/helpers/pager_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -13
- metadata +17 -83
- data/examples/word_count/word_count_views.rb +0 -26
- data/lib/couchrest/core/response.rb +0 -16
- data/lib/couchrest/mixins/attachments.rb +0 -31
- data/lib/couchrest/mixins/callbacks.rb +0 -483
- data/lib/couchrest/mixins/design_doc.rb +0 -64
- data/lib/couchrest/mixins/document_queries.rb +0 -48
- data/lib/couchrest/mixins/extended_attachments.rb +0 -68
- data/lib/couchrest/mixins/extended_document_mixins.rb +0 -6
- data/lib/couchrest/mixins/properties.rb +0 -125
- data/lib/couchrest/mixins/validation.rb +0 -234
- data/lib/couchrest/mixins/views.rb +0 -168
- data/lib/couchrest/mixins.rb +0 -4
- data/lib/couchrest/more/casted_model.rb +0 -28
- data/lib/couchrest/more/extended_document.rb +0 -217
- data/lib/couchrest/more/property.rb +0 -40
- data/lib/couchrest/support/blank.rb +0 -42
- data/lib/couchrest/support/class.rb +0 -191
- data/lib/couchrest/validation/auto_validate.rb +0 -163
- data/lib/couchrest/validation/contextual_validators.rb +0 -78
- data/lib/couchrest/validation/validation_errors.rb +0 -118
- data/lib/couchrest/validation/validators/absent_field_validator.rb +0 -74
- data/lib/couchrest/validation/validators/confirmation_validator.rb +0 -99
- data/lib/couchrest/validation/validators/format_validator.rb +0 -117
- data/lib/couchrest/validation/validators/formats/email.rb +0 -66
- data/lib/couchrest/validation/validators/formats/url.rb +0 -43
- data/lib/couchrest/validation/validators/generic_validator.rb +0 -120
- data/lib/couchrest/validation/validators/length_validator.rb +0 -134
- data/lib/couchrest/validation/validators/method_validator.rb +0 -89
- data/lib/couchrest/validation/validators/numeric_validator.rb +0 -104
- data/lib/couchrest/validation/validators/required_field_validator.rb +0 -109
- data/spec/couchrest/core/server_spec.rb +0 -35
- data/spec/couchrest/more/casted_extended_doc_spec.rb +0 -40
- data/spec/couchrest/more/casted_model_spec.rb +0 -98
- data/spec/couchrest/more/extended_doc_attachment_spec.rb +0 -130
- data/spec/couchrest/more/extended_doc_spec.rb +0 -509
- data/spec/couchrest/more/extended_doc_view_spec.rb +0 -207
- data/spec/couchrest/more/property_spec.rb +0 -130
- data/spec/couchrest/support/class_spec.rb +0 -59
- data/spec/fixtures/more/article.rb +0 -34
- data/spec/fixtures/more/card.rb +0 -20
- data/spec/fixtures/more/course.rb +0 -14
- data/spec/fixtures/more/event.rb +0 -6
- data/spec/fixtures/more/invoice.rb +0 -17
- data/spec/fixtures/more/person.rb +0 -8
- data/spec/fixtures/more/question.rb +0 -6
- data/spec/fixtures/more/service.rb +0 -12
data/spec/spec_helper.rb
CHANGED
@@ -1,26 +1,20 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "spec" # Satisfies Autotest and anyone else not using the Rake tasks
|
3
3
|
|
4
|
-
require File.
|
5
|
-
# check the following file to see how to use the spec'd features.
|
4
|
+
require File.dirname(__FILE__) + '/../lib/couchrest'
|
6
5
|
|
7
6
|
unless defined?(FIXTURE_PATH)
|
8
|
-
FIXTURE_PATH = File.
|
9
|
-
SCRATCH_PATH = File.
|
7
|
+
FIXTURE_PATH = File.dirname(__FILE__) + '/fixtures'
|
8
|
+
SCRATCH_PATH = File.dirname(__FILE__) + '/tmp'
|
10
9
|
|
11
10
|
COUCHHOST = "http://127.0.0.1:5984"
|
12
|
-
TESTDB
|
13
|
-
TEST_SERVER = CouchRest.new
|
14
|
-
TEST_SERVER.default_database = TESTDB
|
15
|
-
end
|
16
|
-
|
17
|
-
class Basic < CouchRest::ExtendedDocument
|
18
|
-
use_database TEST_SERVER.default_database
|
11
|
+
TESTDB = 'couchrest-test'
|
19
12
|
end
|
20
13
|
|
21
14
|
def reset_test_db!
|
22
|
-
cr =
|
15
|
+
cr = CouchRest.new(COUCHHOST)
|
23
16
|
db = cr.database(TESTDB)
|
24
|
-
db.
|
17
|
+
db.delete! rescue nil
|
18
|
+
db = cr.create_db(TESTDB) rescue nin
|
25
19
|
db
|
26
20
|
end
|
metadata
CHANGED
@@ -1,21 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: samflores-couchrest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J. Chris Anderson
|
8
|
-
- Matt Aimonetti
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
11
|
|
13
12
|
date: 2008-11-22 00:00:00 -08:00
|
14
|
-
default_executable:
|
13
|
+
default_executable: couchdir
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: json
|
18
|
-
type: :runtime
|
19
17
|
version_requirement:
|
20
18
|
version_requirements: !ruby/object:Gem::Requirement
|
21
19
|
requirements:
|
@@ -25,7 +23,6 @@ dependencies:
|
|
25
23
|
version:
|
26
24
|
- !ruby/object:Gem::Dependency
|
27
25
|
name: rest-client
|
28
|
-
type: :runtime
|
29
26
|
version_requirement:
|
30
27
|
version_requirements: !ruby/object:Gem::Requirement
|
31
28
|
requirements:
|
@@ -35,7 +32,6 @@ dependencies:
|
|
35
32
|
version:
|
36
33
|
- !ruby/object:Gem::Dependency
|
37
34
|
name: mime-types
|
38
|
-
type: :runtime
|
39
35
|
version_requirement:
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
37
|
requirements:
|
@@ -43,10 +39,19 @@ dependencies:
|
|
43
39
|
- !ruby/object:Gem::Version
|
44
40
|
version: "1.15"
|
45
41
|
version:
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: extlib
|
44
|
+
version_requirement:
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.9.6
|
50
|
+
version:
|
46
51
|
description: CouchRest provides a simple interface on top of CouchDB's RESTful HTTP API, as well as including some utility scripts for managing views and attachments.
|
47
52
|
email: jchris@apache.org
|
48
|
-
executables:
|
49
|
-
|
53
|
+
executables:
|
54
|
+
- couchdir
|
50
55
|
extensions: []
|
51
56
|
|
52
57
|
extra_rdoc_files:
|
@@ -58,6 +63,7 @@ files:
|
|
58
63
|
- README.md
|
59
64
|
- Rakefile
|
60
65
|
- THANKS.md
|
66
|
+
- bin/couchdir
|
61
67
|
- examples/model
|
62
68
|
- examples/model/example.rb
|
63
69
|
- examples/word_count
|
@@ -74,7 +80,6 @@ files:
|
|
74
80
|
- examples/word_count/views/word_count/count-reduce.js
|
75
81
|
- examples/word_count/word_count.rb
|
76
82
|
- examples/word_count/word_count_query.rb
|
77
|
-
- examples/word_count/word_count_views.rb
|
78
83
|
- lib/couchrest
|
79
84
|
- lib/couchrest/commands
|
80
85
|
- lib/couchrest/commands/generate.rb
|
@@ -83,47 +88,14 @@ files:
|
|
83
88
|
- lib/couchrest/core/database.rb
|
84
89
|
- lib/couchrest/core/design.rb
|
85
90
|
- lib/couchrest/core/document.rb
|
86
|
-
- lib/couchrest/core/
|
91
|
+
- lib/couchrest/core/model.rb
|
87
92
|
- lib/couchrest/core/server.rb
|
93
|
+
- lib/couchrest/core/validations.rb
|
88
94
|
- lib/couchrest/core/view.rb
|
89
95
|
- lib/couchrest/helper
|
90
96
|
- lib/couchrest/helper/pager.rb
|
91
97
|
- lib/couchrest/helper/streamer.rb
|
92
|
-
- lib/couchrest/mixins
|
93
|
-
- lib/couchrest/mixins/attachments.rb
|
94
|
-
- lib/couchrest/mixins/callbacks.rb
|
95
|
-
- lib/couchrest/mixins/design_doc.rb
|
96
|
-
- lib/couchrest/mixins/document_queries.rb
|
97
|
-
- lib/couchrest/mixins/extended_attachments.rb
|
98
|
-
- lib/couchrest/mixins/extended_document_mixins.rb
|
99
|
-
- lib/couchrest/mixins/properties.rb
|
100
|
-
- lib/couchrest/mixins/validation.rb
|
101
|
-
- lib/couchrest/mixins/views.rb
|
102
|
-
- lib/couchrest/mixins.rb
|
103
98
|
- lib/couchrest/monkeypatches.rb
|
104
|
-
- lib/couchrest/more
|
105
|
-
- lib/couchrest/more/casted_model.rb
|
106
|
-
- lib/couchrest/more/extended_document.rb
|
107
|
-
- lib/couchrest/more/property.rb
|
108
|
-
- lib/couchrest/support
|
109
|
-
- lib/couchrest/support/blank.rb
|
110
|
-
- lib/couchrest/support/class.rb
|
111
|
-
- lib/couchrest/validation
|
112
|
-
- lib/couchrest/validation/auto_validate.rb
|
113
|
-
- lib/couchrest/validation/contextual_validators.rb
|
114
|
-
- lib/couchrest/validation/validation_errors.rb
|
115
|
-
- lib/couchrest/validation/validators
|
116
|
-
- lib/couchrest/validation/validators/absent_field_validator.rb
|
117
|
-
- lib/couchrest/validation/validators/confirmation_validator.rb
|
118
|
-
- lib/couchrest/validation/validators/format_validator.rb
|
119
|
-
- lib/couchrest/validation/validators/formats
|
120
|
-
- lib/couchrest/validation/validators/formats/email.rb
|
121
|
-
- lib/couchrest/validation/validators/formats/url.rb
|
122
|
-
- lib/couchrest/validation/validators/generic_validator.rb
|
123
|
-
- lib/couchrest/validation/validators/length_validator.rb
|
124
|
-
- lib/couchrest/validation/validators/method_validator.rb
|
125
|
-
- lib/couchrest/validation/validators/numeric_validator.rb
|
126
|
-
- lib/couchrest/validation/validators/required_field_validator.rb
|
127
99
|
- lib/couchrest.rb
|
128
100
|
- spec/couchrest
|
129
101
|
- spec/couchrest/core
|
@@ -131,53 +103,15 @@ files:
|
|
131
103
|
- spec/couchrest/core/database_spec.rb
|
132
104
|
- spec/couchrest/core/design_spec.rb
|
133
105
|
- spec/couchrest/core/document_spec.rb
|
134
|
-
- spec/couchrest/core/
|
106
|
+
- spec/couchrest/core/model_spec.rb
|
135
107
|
- spec/couchrest/helpers
|
136
108
|
- spec/couchrest/helpers/pager_spec.rb
|
137
109
|
- spec/couchrest/helpers/streamer_spec.rb
|
138
|
-
- spec/couchrest/more
|
139
|
-
- spec/couchrest/more/casted_extended_doc_spec.rb
|
140
|
-
- spec/couchrest/more/casted_model_spec.rb
|
141
|
-
- spec/couchrest/more/extended_doc_attachment_spec.rb
|
142
|
-
- spec/couchrest/more/extended_doc_spec.rb
|
143
|
-
- spec/couchrest/more/extended_doc_view_spec.rb
|
144
|
-
- spec/couchrest/more/property_spec.rb
|
145
|
-
- spec/couchrest/support
|
146
|
-
- spec/couchrest/support/class_spec.rb
|
147
110
|
- spec/fixtures
|
148
111
|
- spec/fixtures/attachments
|
149
112
|
- spec/fixtures/attachments/couchdb.png
|
150
113
|
- spec/fixtures/attachments/README
|
151
114
|
- spec/fixtures/attachments/test.html
|
152
|
-
- spec/fixtures/couchapp
|
153
|
-
- spec/fixtures/couchapp/_attachments
|
154
|
-
- spec/fixtures/couchapp/_attachments/index.html
|
155
|
-
- spec/fixtures/couchapp/doc.json
|
156
|
-
- spec/fixtures/couchapp/foo
|
157
|
-
- spec/fixtures/couchapp/foo/bar.txt
|
158
|
-
- spec/fixtures/couchapp/foo/test.json
|
159
|
-
- spec/fixtures/couchapp/test.json
|
160
|
-
- spec/fixtures/couchapp/views
|
161
|
-
- spec/fixtures/couchapp/views/example-map.js
|
162
|
-
- spec/fixtures/couchapp/views/example-reduce.js
|
163
|
-
- spec/fixtures/couchapp-test
|
164
|
-
- spec/fixtures/couchapp-test/my-app
|
165
|
-
- spec/fixtures/couchapp-test/my-app/_attachments
|
166
|
-
- spec/fixtures/couchapp-test/my-app/_attachments/index.html
|
167
|
-
- spec/fixtures/couchapp-test/my-app/foo
|
168
|
-
- spec/fixtures/couchapp-test/my-app/foo/bar.txt
|
169
|
-
- spec/fixtures/couchapp-test/my-app/views
|
170
|
-
- spec/fixtures/couchapp-test/my-app/views/example-map.js
|
171
|
-
- spec/fixtures/couchapp-test/my-app/views/example-reduce.js
|
172
|
-
- spec/fixtures/more
|
173
|
-
- spec/fixtures/more/article.rb
|
174
|
-
- spec/fixtures/more/card.rb
|
175
|
-
- spec/fixtures/more/course.rb
|
176
|
-
- spec/fixtures/more/event.rb
|
177
|
-
- spec/fixtures/more/invoice.rb
|
178
|
-
- spec/fixtures/more/person.rb
|
179
|
-
- spec/fixtures/more/question.rb
|
180
|
-
- spec/fixtures/more/service.rb
|
181
115
|
- spec/fixtures/views
|
182
116
|
- spec/fixtures/views/lib.js
|
183
117
|
- spec/fixtures/views/test_view
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'couchrest'
|
3
|
-
|
4
|
-
couch = CouchRest.new("http://127.0.0.1:5984")
|
5
|
-
db = couch.database('word-count-example')
|
6
|
-
|
7
|
-
word_count = {
|
8
|
-
:map => 'function(doc){
|
9
|
-
var words = doc.text.split(/\W/);
|
10
|
-
words.forEach(function(word){
|
11
|
-
if (word.length > 0) emit([word,doc.title],1);
|
12
|
-
});
|
13
|
-
}',
|
14
|
-
:reduce => 'function(key,combine){
|
15
|
-
return sum(combine);
|
16
|
-
}'
|
17
|
-
}
|
18
|
-
|
19
|
-
db.delete db.get("_design/word_count") rescue nil
|
20
|
-
|
21
|
-
db.save({
|
22
|
-
"_id" => "_design/word_count",
|
23
|
-
:views => {
|
24
|
-
:words => word_count
|
25
|
-
}
|
26
|
-
})
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module CouchRest
|
2
|
-
module Mixins
|
3
|
-
module Attachments
|
4
|
-
|
5
|
-
# saves an attachment directly to couchdb
|
6
|
-
def put_attachment(name, file, options={})
|
7
|
-
raise ArgumentError, "doc must be saved" unless self.rev
|
8
|
-
raise ArgumentError, "doc.database required to put_attachment" unless database
|
9
|
-
result = database.put_attachment(self, name, file, options)
|
10
|
-
self['_rev'] = result['rev']
|
11
|
-
result['ok']
|
12
|
-
end
|
13
|
-
|
14
|
-
# returns an attachment's data
|
15
|
-
def fetch_attachment(name)
|
16
|
-
raise ArgumentError, "doc must be saved" unless self.rev
|
17
|
-
raise ArgumentError, "doc.database required to put_attachment" unless database
|
18
|
-
database.fetch_attachment(self, name)
|
19
|
-
end
|
20
|
-
|
21
|
-
# deletes an attachment directly from couchdb
|
22
|
-
def delete_attachment(name)
|
23
|
-
raise ArgumentError, "doc.database required to delete_attachment" unless database
|
24
|
-
result = database.delete_attachment(self, name)
|
25
|
-
self['_rev'] = result['rev']
|
26
|
-
result['ok']
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|