dolly 1.1.4 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +78 -0
  3. data/lib/dolly.rb +4 -2
  4. data/lib/dolly/attachment.rb +29 -0
  5. data/lib/dolly/bulk_document.rb +27 -26
  6. data/lib/dolly/class_methods_delegation.rb +15 -0
  7. data/lib/dolly/collection.rb +32 -65
  8. data/lib/dolly/configuration.rb +43 -0
  9. data/lib/dolly/connection.rb +101 -22
  10. data/lib/dolly/depracated_database.rb +24 -0
  11. data/lib/dolly/document.rb +48 -198
  12. data/lib/dolly/document_creation.rb +20 -0
  13. data/lib/dolly/document_state.rb +66 -0
  14. data/lib/dolly/document_type.rb +47 -0
  15. data/lib/dolly/exceptions.rb +32 -0
  16. data/lib/dolly/identity_properties.rb +29 -0
  17. data/lib/dolly/mango.rb +124 -0
  18. data/lib/dolly/mango_index.rb +65 -0
  19. data/lib/dolly/properties.rb +36 -0
  20. data/lib/dolly/property.rb +58 -47
  21. data/lib/dolly/property_manager.rb +47 -0
  22. data/lib/dolly/property_set.rb +23 -0
  23. data/lib/dolly/query.rb +37 -67
  24. data/lib/dolly/query_arguments.rb +35 -0
  25. data/lib/dolly/request.rb +12 -94
  26. data/lib/dolly/request_header.rb +26 -0
  27. data/lib/dolly/timestamp.rb +24 -0
  28. data/lib/dolly/version.rb +1 -1
  29. data/lib/dolly/view_query.rb +14 -0
  30. data/lib/{dolly → railties}/railtie.rb +2 -1
  31. data/lib/refinements/hash_refinements.rb +27 -0
  32. data/lib/refinements/string_refinements.rb +28 -0
  33. data/lib/tasks/db.rake +20 -4
  34. data/test/bulk_document_test.rb +8 -5
  35. data/test/document_test.rb +132 -95
  36. data/test/document_type_test.rb +28 -0
  37. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  38. data/test/dummy/log/test.log +111132 -0
  39. data/test/inheritance_test.rb +23 -0
  40. data/test/mango_index_test.rb +64 -0
  41. data/test/mango_test.rb +273 -0
  42. data/test/test_helper.rb +63 -18
  43. data/test/view_query_test.rb +27 -0
  44. metadata +57 -141
  45. data/Rakefile +0 -11
  46. data/lib/dolly/bulk_error.rb +0 -16
  47. data/lib/dolly/db_config.rb +0 -20
  48. data/lib/dolly/interpreter.rb +0 -5
  49. data/lib/dolly/name_space.rb +0 -28
  50. data/lib/dolly/timestamps.rb +0 -21
  51. data/lib/exceptions/dolly.rb +0 -38
  52. data/test/collection_test.rb +0 -59
  53. data/test/dummy/README.rdoc +0 -28
  54. data/test/dummy/Rakefile +0 -6
  55. data/test/dummy/app/assets/javascripts/application.js +0 -13
  56. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  57. data/test/dummy/app/controllers/application_controller.rb +0 -5
  58. data/test/dummy/app/helpers/application_helper.rb +0 -2
  59. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  60. data/test/dummy/bin/bundle +0 -3
  61. data/test/dummy/bin/rails +0 -4
  62. data/test/dummy/bin/rake +0 -4
  63. data/test/dummy/config.ru +0 -4
  64. data/test/dummy/config/application.rb +0 -27
  65. data/test/dummy/config/boot.rb +0 -5
  66. data/test/dummy/config/couchdb.yml +0 -13
  67. data/test/dummy/config/environment.rb +0 -5
  68. data/test/dummy/config/environments/development.rb +0 -29
  69. data/test/dummy/config/environments/production.rb +0 -80
  70. data/test/dummy/config/environments/test.rb +0 -36
  71. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  72. data/test/dummy/config/initializers/inflections.rb +0 -16
  73. data/test/dummy/config/initializers/mime_types.rb +0 -5
  74. data/test/dummy/config/initializers/secret_token.rb +0 -12
  75. data/test/dummy/config/initializers/session_store.rb +0 -3
  76. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  77. data/test/dummy/config/locales/en.yml +0 -23
  78. data/test/dummy/config/routes.rb +0 -56
  79. data/test/dummy/lib/couch_rest_adapter/railtie.rb +0 -10
  80. data/test/dummy/public/404.html +0 -58
  81. data/test/dummy/public/422.html +0 -58
  82. data/test/dummy/public/500.html +0 -57
  83. data/test/dummy/public/favicon.ico +0 -0
  84. data/test/factories/factories.rb +0 -8
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ class Foo < Dolly::Document
4
+ end
5
+
6
+ class ViewQueryTest < Test::Unit::TestCase
7
+
8
+ def setup
9
+ all_docs = [ {foo: 'Foo B', bar: 'Bar B', type: 'foo_bar'}, {foo: 'Foo A', bar: 'Bar A', type: 'foo_bar'}]
10
+ @multi_type_resp = build_view_collation_response all_docs
11
+
12
+ stub_request(:get, "http://localhost:5984/test/_design/doc/_view/id?include_docs=true").
13
+ to_return(body: @multi_type_resp.to_json)
14
+
15
+ end
16
+
17
+ test 'raw_view' do
18
+ assert_equal(Foo.raw_view('doc', 'id'), @multi_type_resp)
19
+ assert_equal(Foo.raw_view('doc', 'id')[:rows].any?, true)
20
+ assert_equal(Foo.raw_view('doc', 'id')[:total_rows].nil?, false)
21
+ end
22
+
23
+ test 'view_value' do
24
+ expected = @multi_type_resp[:rows].flat_map{|res| res[:value]}
25
+ assert_equal(Foo.view_value('doc', 'id'), expected)
26
+ end
27
+ end
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
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - javierg
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-26 00:00:00.000000000 Z
11
+ date: 2020-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: railties
14
+ name: oj
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,49 +25,35 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: httparty
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rails
28
+ name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ">="
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '0'
33
+ version: '2.0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ">="
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: '2.0'
55
41
  - !ruby/object:Gem::Dependency
56
- name: bundler
42
+ name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '1.3'
47
+ version: '10.0'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '1.3'
54
+ version: '10.0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: rake
56
+ name: test-unit-full
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
@@ -81,49 +67,21 @@ dependencies:
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
- name: fakeweb
70
+ name: webmock
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  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
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
73
+ - - ">="
102
74
  - !ruby/object:Gem::Version
103
- version: '4.2'
75
+ version: '0'
104
76
  type: :development
105
77
  prerelease: false
106
78
  version_requirements: !ruby/object:Gem::Requirement
107
79
  requirements:
108
- - - "~>"
80
+ - - ">="
109
81
  - !ruby/object:Gem::Version
110
- version: '4.2'
82
+ version: '0'
111
83
  - !ruby/object:Gem::Dependency
112
84
  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
85
  requirement: !ruby/object:Gem::Requirement
128
86
  requirements:
129
87
  - - ">="
@@ -143,65 +101,51 @@ executables: []
143
101
  extensions: []
144
102
  extra_rdoc_files: []
145
103
  files:
146
- - Rakefile
104
+ - README.md
147
105
  - lib/dolly.rb
106
+ - lib/dolly/attachment.rb
148
107
  - lib/dolly/bulk_document.rb
149
- - lib/dolly/bulk_error.rb
108
+ - lib/dolly/class_methods_delegation.rb
150
109
  - lib/dolly/collection.rb
110
+ - lib/dolly/configuration.rb
151
111
  - lib/dolly/connection.rb
152
- - lib/dolly/db_config.rb
112
+ - lib/dolly/depracated_database.rb
153
113
  - lib/dolly/document.rb
154
- - lib/dolly/interpreter.rb
155
- - lib/dolly/name_space.rb
114
+ - lib/dolly/document_creation.rb
115
+ - lib/dolly/document_state.rb
116
+ - lib/dolly/document_type.rb
117
+ - lib/dolly/exceptions.rb
118
+ - lib/dolly/identity_properties.rb
119
+ - lib/dolly/mango.rb
120
+ - lib/dolly/mango_index.rb
121
+ - lib/dolly/properties.rb
156
122
  - lib/dolly/property.rb
123
+ - lib/dolly/property_manager.rb
124
+ - lib/dolly/property_set.rb
157
125
  - lib/dolly/query.rb
158
- - lib/dolly/railtie.rb
126
+ - lib/dolly/query_arguments.rb
159
127
  - lib/dolly/request.rb
160
- - lib/dolly/timestamps.rb
128
+ - lib/dolly/request_header.rb
129
+ - lib/dolly/timestamp.rb
161
130
  - lib/dolly/version.rb
162
- - lib/exceptions/dolly.rb
131
+ - lib/dolly/view_query.rb
132
+ - lib/railties/railtie.rb
133
+ - lib/refinements/hash_refinements.rb
134
+ - lib/refinements/string_refinements.rb
163
135
  - lib/tasks/db.rake
164
136
  - test/bulk_document_test.rb
165
- - test/collection_test.rb
166
137
  - test/document_test.rb
167
- - test/dummy/README.rdoc
168
- - test/dummy/Rakefile
169
- - test/dummy/app/assets/javascripts/application.js
170
- - test/dummy/app/assets/stylesheets/application.css
171
- - test/dummy/app/controllers/application_controller.rb
172
- - test/dummy/app/helpers/application_helper.rb
173
- - test/dummy/app/views/layouts/application.html.erb
174
- - test/dummy/bin/bundle
175
- - test/dummy/bin/rails
176
- - test/dummy/bin/rake
177
- - test/dummy/config.ru
178
- - test/dummy/config/application.rb
179
- - test/dummy/config/boot.rb
180
- - test/dummy/config/couchdb.yml
181
- - test/dummy/config/environment.rb
182
- - test/dummy/config/environments/development.rb
183
- - test/dummy/config/environments/production.rb
184
- - test/dummy/config/environments/test.rb
185
- - test/dummy/config/initializers/backtrace_silencers.rb
186
- - test/dummy/config/initializers/inflections.rb
187
- - test/dummy/config/initializers/mime_types.rb
188
- - test/dummy/config/initializers/secret_token.rb
189
- - test/dummy/config/initializers/session_store.rb
190
- - test/dummy/config/initializers/wrap_parameters.rb
191
- - test/dummy/config/locales/en.yml
192
- - test/dummy/config/routes.rb
193
- - test/dummy/lib/couch_rest_adapter/railtie.rb
138
+ - test/document_type_test.rb
139
+ - test/dummy/config/initializers/filter_parameter_logging.rb
194
140
  - test/dummy/log/test.log
195
- - test/dummy/public/404.html
196
- - test/dummy/public/422.html
197
- - test/dummy/public/500.html
198
- - test/dummy/public/favicon.ico
199
- - test/factories/factories.rb
141
+ - test/inheritance_test.rb
142
+ - test/mango_index_test.rb
143
+ - test/mango_test.rb
200
144
  - test/support/test.txt
201
145
  - test/test_helper.rb
202
- homepage: ''
203
- licenses:
204
- - MIT
146
+ - test/view_query_test.rb
147
+ homepage: https://www.amco.me
148
+ licenses: []
205
149
  metadata: {}
206
150
  post_install_message:
207
151
  rdoc_options: []
@@ -218,47 +162,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
162
  - !ruby/object:Gem::Version
219
163
  version: '0'
220
164
  requirements: []
221
- rubyforge_project:
222
- rubygems_version: 2.4.5
165
+ rubygems_version: 3.1.4
223
166
  signing_key:
224
167
  specification_version: 4
225
168
  summary: will write something
226
169
  test_files:
227
- - test/bulk_document_test.rb
228
- - test/collection_test.rb
229
- - test/document_test.rb
230
- - test/dummy/app/assets/javascripts/application.js
231
- - test/dummy/app/assets/stylesheets/application.css
232
- - test/dummy/app/controllers/application_controller.rb
233
- - test/dummy/app/helpers/application_helper.rb
234
- - test/dummy/app/views/layouts/application.html.erb
235
- - test/dummy/bin/bundle
236
- - test/dummy/bin/rails
237
- - test/dummy/bin/rake
238
- - test/dummy/config/application.rb
239
- - test/dummy/config/boot.rb
240
- - test/dummy/config/couchdb.yml
241
- - test/dummy/config/environment.rb
242
- - test/dummy/config/environments/development.rb
243
- - test/dummy/config/environments/production.rb
244
- - test/dummy/config/environments/test.rb
245
- - test/dummy/config/initializers/backtrace_silencers.rb
246
- - test/dummy/config/initializers/inflections.rb
247
- - test/dummy/config/initializers/mime_types.rb
248
- - test/dummy/config/initializers/secret_token.rb
249
- - test/dummy/config/initializers/session_store.rb
250
- - test/dummy/config/initializers/wrap_parameters.rb
251
- - test/dummy/config/locales/en.yml
252
- - test/dummy/config/routes.rb
253
- - test/dummy/config.ru
254
- - test/dummy/lib/couch_rest_adapter/railtie.rb
170
+ - test/dummy/config/initializers/filter_parameter_logging.rb
255
171
  - test/dummy/log/test.log
256
- - test/dummy/public/404.html
257
- - test/dummy/public/422.html
258
- - test/dummy/public/500.html
259
- - test/dummy/public/favicon.ico
260
- - test/dummy/Rakefile
261
- - test/dummy/README.rdoc
262
- - test/factories/factories.rb
172
+ - test/inheritance_test.rb
173
+ - test/document_type_test.rb
174
+ - test/mango_index_test.rb
175
+ - test/bulk_document_test.rb
176
+ - test/view_query_test.rb
177
+ - test/mango_test.rb
263
178
  - test/support/test.txt
264
179
  - test/test_helper.rb
180
+ - test/document_test.rb
data/Rakefile DELETED
@@ -1,11 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << 'lib'
6
- t.libs << 'test'
7
- t.pattern = 'test/**/*_test.rb'
8
- t.verbose = false
9
- end
10
-
11
- task default: :test
@@ -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
@@ -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
@@ -1,5 +0,0 @@
1
- module Dolly
2
- module Interpreter
3
-
4
- end
5
- end
@@ -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
@@ -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
@@ -1,38 +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
- end