dolly 1.1.7 → 3.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.
- checksums.yaml +5 -5
- data/README.md +78 -0
- data/lib/dolly/attachment.rb +29 -0
- data/lib/dolly/bulk_document.rb +27 -26
- data/lib/dolly/class_methods_delegation.rb +15 -0
- data/lib/dolly/collection.rb +32 -65
- data/lib/dolly/configuration.rb +35 -10
- data/lib/dolly/connection.rb +93 -22
- data/lib/dolly/depracated_database.rb +24 -0
- data/lib/dolly/document.rb +61 -208
- data/lib/dolly/document_creation.rb +27 -0
- data/lib/dolly/document_state.rb +66 -0
- data/lib/dolly/document_type.rb +47 -0
- data/lib/dolly/exceptions.rb +32 -0
- data/lib/dolly/framework_helper.rb +7 -0
- data/lib/dolly/identity_properties.rb +29 -0
- data/lib/dolly/mango.rb +156 -0
- data/lib/dolly/mango_index.rb +73 -0
- data/lib/dolly/properties.rb +36 -0
- data/lib/dolly/property.rb +76 -46
- data/lib/dolly/property_manager.rb +53 -0
- data/lib/dolly/property_set.rb +23 -0
- data/lib/dolly/query.rb +63 -75
- data/lib/dolly/query_arguments.rb +35 -0
- data/lib/dolly/request.rb +12 -107
- data/lib/dolly/request_header.rb +26 -0
- data/lib/dolly/timestamp.rb +24 -0
- data/lib/dolly/version.rb +1 -1
- data/lib/dolly/view_query.rb +21 -0
- data/lib/dolly.rb +2 -23
- data/lib/{dolly → railties}/railtie.rb +2 -1
- data/lib/refinements/hash_refinements.rb +27 -0
- data/lib/refinements/string_refinements.rb +28 -0
- data/lib/tasks/db.rake +27 -4
- data/test/bulk_document_test.rb +8 -5
- data/test/document_test.rb +130 -95
- data/test/document_type_test.rb +28 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/log/test.log +46417 -46858
- data/test/inheritance_test.rb +23 -0
- data/test/mango_index_test.rb +64 -0
- data/test/mango_test.rb +273 -0
- data/test/property_manager_test.rb +18 -0
- data/test/test_helper.rb +63 -18
- data/test/view_query_test.rb +27 -0
- metadata +67 -140
- data/Rakefile +0 -11
- data/lib/dolly/bulk_error.rb +0 -16
- data/lib/dolly/db_config.rb +0 -20
- data/lib/dolly/interpreter.rb +0 -5
- data/lib/dolly/logger.rb +0 -9
- data/lib/dolly/name_space.rb +0 -28
- data/lib/dolly/timestamps.rb +0 -21
- data/lib/exceptions/dolly.rb +0 -47
- data/test/collection_test.rb +0 -59
- data/test/configuration_test.rb +0 -9
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/config/application.rb +0 -27
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/couchdb.yml +0 -13
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -29
- data/test/dummy/config/environments/production.rb +0 -80
- data/test/dummy/config/environments/test.rb +0 -36
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -12
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -56
- data/test/dummy/config.ru +0 -4
- data/test/dummy/lib/couch_rest_adapter/railtie.rb +0 -10
- data/test/dummy/public/404.html +0 -58
- data/test/dummy/public/422.html +0 -58
- data/test/dummy/public/500.html +0 -57
- data/test/dummy/public/favicon.ico +0 -0
- data/test/factories/factories.rb +0 -8
- data/test/request_test.rb +0 -25
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dolly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- javierg
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: oj
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,49 +25,49 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: curb
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.9.8
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.9.8
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: test-unit-full
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,49 +81,21 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.3.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.3.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: factory_girl_rails
|
84
|
+
name: webmock
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- - "
|
87
|
+
- - ">="
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
89
|
+
version: '0'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
|
-
- - "
|
94
|
+
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
96
|
+
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: mocha
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0.4'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0.4'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: timecop
|
127
99
|
requirement: !ruby/object:Gem::Requirement
|
128
100
|
requirements:
|
129
101
|
- - ">="
|
@@ -143,71 +115,55 @@ executables: []
|
|
143
115
|
extensions: []
|
144
116
|
extra_rdoc_files: []
|
145
117
|
files:
|
146
|
-
-
|
118
|
+
- README.md
|
147
119
|
- lib/dolly.rb
|
120
|
+
- lib/dolly/attachment.rb
|
148
121
|
- lib/dolly/bulk_document.rb
|
149
|
-
- lib/dolly/
|
122
|
+
- lib/dolly/class_methods_delegation.rb
|
150
123
|
- lib/dolly/collection.rb
|
151
124
|
- lib/dolly/configuration.rb
|
152
125
|
- lib/dolly/connection.rb
|
153
|
-
- lib/dolly/
|
126
|
+
- lib/dolly/depracated_database.rb
|
154
127
|
- lib/dolly/document.rb
|
155
|
-
- lib/dolly/
|
156
|
-
- lib/dolly/
|
157
|
-
- lib/dolly/
|
128
|
+
- lib/dolly/document_creation.rb
|
129
|
+
- lib/dolly/document_state.rb
|
130
|
+
- lib/dolly/document_type.rb
|
131
|
+
- lib/dolly/exceptions.rb
|
132
|
+
- lib/dolly/framework_helper.rb
|
133
|
+
- lib/dolly/identity_properties.rb
|
134
|
+
- lib/dolly/mango.rb
|
135
|
+
- lib/dolly/mango_index.rb
|
136
|
+
- lib/dolly/properties.rb
|
158
137
|
- lib/dolly/property.rb
|
138
|
+
- lib/dolly/property_manager.rb
|
139
|
+
- lib/dolly/property_set.rb
|
159
140
|
- lib/dolly/query.rb
|
160
|
-
- lib/dolly/
|
141
|
+
- lib/dolly/query_arguments.rb
|
161
142
|
- lib/dolly/request.rb
|
162
|
-
- lib/dolly/
|
143
|
+
- lib/dolly/request_header.rb
|
144
|
+
- lib/dolly/timestamp.rb
|
163
145
|
- lib/dolly/version.rb
|
164
|
-
- lib/
|
146
|
+
- lib/dolly/view_query.rb
|
147
|
+
- lib/railties/railtie.rb
|
148
|
+
- lib/refinements/hash_refinements.rb
|
149
|
+
- lib/refinements/string_refinements.rb
|
165
150
|
- lib/tasks/db.rake
|
166
151
|
- test/bulk_document_test.rb
|
167
|
-
- test/collection_test.rb
|
168
|
-
- test/configuration_test.rb
|
169
152
|
- test/document_test.rb
|
170
|
-
- test/
|
171
|
-
- test/dummy/
|
172
|
-
- test/dummy/app/assets/javascripts/application.js
|
173
|
-
- test/dummy/app/assets/stylesheets/application.css
|
174
|
-
- test/dummy/app/controllers/application_controller.rb
|
175
|
-
- test/dummy/app/helpers/application_helper.rb
|
176
|
-
- test/dummy/app/views/layouts/application.html.erb
|
177
|
-
- test/dummy/bin/bundle
|
178
|
-
- test/dummy/bin/rails
|
179
|
-
- test/dummy/bin/rake
|
180
|
-
- test/dummy/config.ru
|
181
|
-
- test/dummy/config/application.rb
|
182
|
-
- test/dummy/config/boot.rb
|
183
|
-
- test/dummy/config/couchdb.yml
|
184
|
-
- test/dummy/config/environment.rb
|
185
|
-
- test/dummy/config/environments/development.rb
|
186
|
-
- test/dummy/config/environments/production.rb
|
187
|
-
- test/dummy/config/environments/test.rb
|
188
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
189
|
-
- test/dummy/config/initializers/inflections.rb
|
190
|
-
- test/dummy/config/initializers/mime_types.rb
|
191
|
-
- test/dummy/config/initializers/secret_token.rb
|
192
|
-
- test/dummy/config/initializers/session_store.rb
|
193
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
194
|
-
- test/dummy/config/locales/en.yml
|
195
|
-
- test/dummy/config/routes.rb
|
196
|
-
- test/dummy/lib/couch_rest_adapter/railtie.rb
|
153
|
+
- test/document_type_test.rb
|
154
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
197
155
|
- test/dummy/log/test.log
|
198
|
-
- test/
|
199
|
-
- test/
|
200
|
-
- test/
|
201
|
-
- test/
|
202
|
-
- test/factories/factories.rb
|
203
|
-
- test/request_test.rb
|
156
|
+
- test/inheritance_test.rb
|
157
|
+
- test/mango_index_test.rb
|
158
|
+
- test/mango_test.rb
|
159
|
+
- test/property_manager_test.rb
|
204
160
|
- test/support/test.txt
|
205
161
|
- test/test_helper.rb
|
206
|
-
|
207
|
-
|
208
|
-
|
162
|
+
- test/view_query_test.rb
|
163
|
+
homepage: https://www.amco.me
|
164
|
+
licenses: []
|
209
165
|
metadata: {}
|
210
|
-
post_install_message:
|
166
|
+
post_install_message:
|
211
167
|
rdoc_options: []
|
212
168
|
require_paths:
|
213
169
|
- lib
|
@@ -222,49 +178,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
178
|
- !ruby/object:Gem::Version
|
223
179
|
version: '0'
|
224
180
|
requirements: []
|
225
|
-
|
226
|
-
|
227
|
-
signing_key:
|
181
|
+
rubygems_version: 3.0.3
|
182
|
+
signing_key:
|
228
183
|
specification_version: 4
|
229
184
|
summary: will write something
|
230
185
|
test_files:
|
231
|
-
- test/
|
232
|
-
- test/collection_test.rb
|
233
|
-
- test/configuration_test.rb
|
234
|
-
- test/document_test.rb
|
235
|
-
- test/dummy/app/assets/javascripts/application.js
|
236
|
-
- test/dummy/app/assets/stylesheets/application.css
|
237
|
-
- test/dummy/app/controllers/application_controller.rb
|
238
|
-
- test/dummy/app/helpers/application_helper.rb
|
239
|
-
- test/dummy/app/views/layouts/application.html.erb
|
240
|
-
- test/dummy/bin/bundle
|
241
|
-
- test/dummy/bin/rails
|
242
|
-
- test/dummy/bin/rake
|
243
|
-
- test/dummy/config/application.rb
|
244
|
-
- test/dummy/config/boot.rb
|
245
|
-
- test/dummy/config/couchdb.yml
|
246
|
-
- test/dummy/config/environment.rb
|
247
|
-
- test/dummy/config/environments/development.rb
|
248
|
-
- test/dummy/config/environments/production.rb
|
249
|
-
- test/dummy/config/environments/test.rb
|
250
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
251
|
-
- test/dummy/config/initializers/inflections.rb
|
252
|
-
- test/dummy/config/initializers/mime_types.rb
|
253
|
-
- test/dummy/config/initializers/secret_token.rb
|
254
|
-
- test/dummy/config/initializers/session_store.rb
|
255
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
256
|
-
- test/dummy/config/locales/en.yml
|
257
|
-
- test/dummy/config/routes.rb
|
258
|
-
- test/dummy/config.ru
|
259
|
-
- test/dummy/lib/couch_rest_adapter/railtie.rb
|
186
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
260
187
|
- test/dummy/log/test.log
|
261
|
-
- test/
|
262
|
-
- test/
|
263
|
-
- test/
|
264
|
-
- test/
|
265
|
-
- test/
|
266
|
-
- test/
|
267
|
-
- test/factories/factories.rb
|
268
|
-
- test/request_test.rb
|
188
|
+
- test/inheritance_test.rb
|
189
|
+
- test/document_type_test.rb
|
190
|
+
- test/mango_index_test.rb
|
191
|
+
- test/bulk_document_test.rb
|
192
|
+
- test/view_query_test.rb
|
193
|
+
- test/mango_test.rb
|
269
194
|
- test/support/test.txt
|
270
195
|
- test/test_helper.rb
|
196
|
+
- test/document_test.rb
|
197
|
+
- test/property_manager_test.rb
|
data/Rakefile
DELETED
data/lib/dolly/bulk_error.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Dolly
|
2
|
-
class BulkError
|
3
|
-
attr_accessor :obj, :name, :message
|
4
|
-
|
5
|
-
def initialize options = {}
|
6
|
-
self.obj = options['obj']
|
7
|
-
self.name = options['error']
|
8
|
-
self.message = options['reason']
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_s
|
12
|
-
message
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
data/lib/dolly/db_config.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module Dolly
|
2
|
-
module DbConfig
|
3
|
-
attr_accessor :config_file
|
4
|
-
|
5
|
-
def parse_config
|
6
|
-
@config_data ||= File.read(config_file)
|
7
|
-
raise Dolly::InvalidConfigFileError unless @config_data.present?
|
8
|
-
YAML::load( ERB.new(@config_data).result )
|
9
|
-
end
|
10
|
-
|
11
|
-
def env
|
12
|
-
parse_config[Rails.env]
|
13
|
-
end
|
14
|
-
|
15
|
-
def config_file
|
16
|
-
root = Rails.root || File.expand_path("../../../test/dummy/", __FILE__)
|
17
|
-
File.join(root, 'config', 'couchdb.yml')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/dolly/interpreter.rb
DELETED
data/lib/dolly/logger.rb
DELETED
data/lib/dolly/name_space.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module Dolly
|
2
|
-
module NameSpace
|
3
|
-
|
4
|
-
def name_paramitized
|
5
|
-
underscore name.split("::").last
|
6
|
-
end
|
7
|
-
|
8
|
-
def base_id id
|
9
|
-
id = URI.unescape id
|
10
|
-
id.sub %r~^#{name_paramitized}/~, ''
|
11
|
-
end
|
12
|
-
|
13
|
-
def namespace id
|
14
|
-
return id if id =~ %r~^#{name_paramitized}/~
|
15
|
-
"#{name_paramitized}/#{id}"
|
16
|
-
end
|
17
|
-
|
18
|
-
#FROM ActiveModel::Name
|
19
|
-
def underscore(camel_cased_word)
|
20
|
-
camel_cased_word.to_s.gsub(/::/, '/').
|
21
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
22
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
23
|
-
tr("-", "_").
|
24
|
-
downcase
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
data/lib/dolly/timestamps.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Dolly
|
2
|
-
module Timestamps
|
3
|
-
|
4
|
-
def timestamps!
|
5
|
-
property :created_at, :updated_at, class_name: Time
|
6
|
-
|
7
|
-
self.timestamps[self.name] = true
|
8
|
-
|
9
|
-
self.class_eval do
|
10
|
-
|
11
|
-
def set_created_at
|
12
|
-
doc['created_at'] ||= Time.now
|
13
|
-
end
|
14
|
-
|
15
|
-
def set_updated_at
|
16
|
-
doc['updated_at'] = Time.now
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/exceptions/dolly.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
module Dolly
|
2
|
-
class ResourceNotFound < RuntimeError
|
3
|
-
def to_s
|
4
|
-
'The document was not found.'
|
5
|
-
end
|
6
|
-
end
|
7
|
-
class ServerError < RuntimeError
|
8
|
-
def initialize msg
|
9
|
-
@msg = msg
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_s
|
13
|
-
"There has been an error on the couchdb server: #{@msg.inspect}"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
class MissingDesignError < RuntimeError
|
17
|
-
def to_s
|
18
|
-
'Design document is missing. Add it into couchdb.yml as design:name.'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
class InvalidConfigFileError < RuntimeError
|
22
|
-
|
23
|
-
def initialize filename
|
24
|
-
@filename = filename
|
25
|
-
end
|
26
|
-
|
27
|
-
def to_s
|
28
|
-
"Invalid config file at #{filename}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
class InvalidProperty < RuntimeError
|
32
|
-
def to_s
|
33
|
-
"Trying to set an undefined property."
|
34
|
-
end
|
35
|
-
end
|
36
|
-
class DocumentInvalidError < RuntimeError; end
|
37
|
-
class MissingPropertyError < RuntimeError; end
|
38
|
-
class MissingRequestConfigSettings < RuntimeError
|
39
|
-
def initialize key
|
40
|
-
@key = key
|
41
|
-
end
|
42
|
-
|
43
|
-
def to_s
|
44
|
-
"Missing required #{@key} setting for Dolly::Request"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/test/collection_test.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BaseDolly < Dolly::Document; end
|
4
|
-
|
5
|
-
class FooBar < BaseDolly
|
6
|
-
property :foo, :bar
|
7
|
-
end
|
8
|
-
|
9
|
-
class CollectionTest < ActiveSupport::TestCase
|
10
|
-
|
11
|
-
def setup
|
12
|
-
@json = '{"total_rows":2,"offset":0,"rows":[{"id":"foo_bar/0","key":"foo_bar","value":1,"doc":{"_id":"foo_bar/0","_rev":"7f66379ac92eb6dfafa50c94bd795122","foo":"Foo B","bar":"Bar B","type":"foo_bar"}},{"id":"foo_bar/1","key":"foo_bar","value":1,"doc":{"_id":"foo_bar/1","_rev":"4d33cea0e55142c9ecc6a81600095469","foo":"Foo A","bar":"Bar A","type":"foo_bar"}}]}'
|
13
|
-
@collection = Dolly::Collection.new @json, FooBar
|
14
|
-
end
|
15
|
-
|
16
|
-
test 'each returns nil' do
|
17
|
-
assert_equal @collection.each { |foo| foo }, nil
|
18
|
-
end
|
19
|
-
|
20
|
-
test 'to_a returns an array' do
|
21
|
-
assert_equal true, @collection.to_a.is_a?(Array)
|
22
|
-
end
|
23
|
-
|
24
|
-
test 'count returns the number of objects in collection' do
|
25
|
-
assert_equal 2, @collection.count
|
26
|
-
end
|
27
|
-
|
28
|
-
test 'to_json returns a string of json' do
|
29
|
-
assert_equal true, @collection.to_json.is_a?(String)
|
30
|
-
end
|
31
|
-
|
32
|
-
test 'map returns an enumerator' do
|
33
|
-
assert_equal true, @collection.map.is_a?(Enumerator)
|
34
|
-
end
|
35
|
-
|
36
|
-
test 'map accepts a block and returns the correct values' do
|
37
|
-
assert_equal ["Foo B", "Foo A"], @collection.map(&:foo)
|
38
|
-
end
|
39
|
-
|
40
|
-
test 'update attributes will change expected attributes' do
|
41
|
-
@collection.update_properties! foo: 'Foo 4 All'
|
42
|
-
assert_equal ['Foo 4 All', 'Foo 4 All'], @collection.map(&:foo)
|
43
|
-
end
|
44
|
-
|
45
|
-
test 'update empty attributes' do
|
46
|
-
json = '{"total_rows":2,"offset":0,"rows":[{"id":"foo_bar/0","key":"foo_bar","value":1,"doc":{"_id":"foo_bar/0","_rev":"7f66379ac92eb6dfafa50c94bd795122","foo":null,"bar":"","type":"foo_bar"}},{"id":"foo_bar/1","key":"foo_bar","value":1,"doc":{"_id":"foo_bar/1","_rev":"4d33cea0e55142c9ecc6a81600095469","foo":"Foo A","bar":"Bar A","type":"foo_bar"}}]}'
|
47
|
-
collection = Dolly::Collection.new json, FooBar
|
48
|
-
|
49
|
-
collection.update_properties! foo: 'Foo 4 All', bar: 'stuff'
|
50
|
-
assert_equal ['Foo 4 All', 'Foo 4 All'], collection.map(&:foo)
|
51
|
-
assert_equal ['stuff', 'stuff'], collection.map(&:bar)
|
52
|
-
end
|
53
|
-
|
54
|
-
test 'update attributes will raise exception if property is missing' do
|
55
|
-
assert_raise Dolly::MissingPropertyError do
|
56
|
-
@collection.update_properties! missing: 'Ha! Ha!'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
data/test/configuration_test.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ConfigurationTest < ActiveSupport::TestCase
|
4
|
-
test 'configure allows for changes to configuration' do
|
5
|
-
assert Dolly.configure { |dolly| dolly.log_requests = true }
|
6
|
-
assert_equal true, Dolly.log_requests?
|
7
|
-
assert Dolly.reset!
|
8
|
-
end
|
9
|
-
end
|
data/test/dummy/README.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
== README
|
2
|
-
|
3
|
-
This README would normally document whatever steps are necessary to get the
|
4
|
-
application up and running.
|
5
|
-
|
6
|
-
Things you may want to cover:
|
7
|
-
|
8
|
-
* Ruby version
|
9
|
-
|
10
|
-
* System dependencies
|
11
|
-
|
12
|
-
* Configuration
|
13
|
-
|
14
|
-
* Database creation
|
15
|
-
|
16
|
-
* Database initialization
|
17
|
-
|
18
|
-
* How to run the test suite
|
19
|
-
|
20
|
-
* Services (job queues, cache servers, search engines, etc.)
|
21
|
-
|
22
|
-
* Deployment instructions
|
23
|
-
|
24
|
-
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require_tree .
|
@@ -1,13 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
-
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
-
*
|
11
|
-
*= require_self
|
12
|
-
*= require_tree .
|
13
|
-
*/
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Dummy</title>
|
5
|
-
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
6
|
-
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
data/test/dummy/bin/bundle
DELETED
data/test/dummy/bin/rails
DELETED
data/test/dummy/bin/rake
DELETED