dolly 1.1.7 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -0
  3. data/lib/dolly.rb +1 -23
  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 +26 -69
  8. data/lib/dolly/configuration.rb +35 -10
  9. data/lib/dolly/connection.rb +91 -22
  10. data/lib/dolly/depracated_database.rb +24 -0
  11. data/lib/dolly/document.rb +32 -206
  12. data/lib/dolly/document_creation.rb +20 -0
  13. data/lib/dolly/document_state.rb +65 -0
  14. data/lib/dolly/document_type.rb +28 -0
  15. data/lib/dolly/exceptions.rb +21 -0
  16. data/lib/dolly/identity_properties.rb +29 -0
  17. data/lib/dolly/properties.rb +31 -0
  18. data/lib/dolly/property.rb +58 -47
  19. data/lib/dolly/property_manager.rb +47 -0
  20. data/lib/dolly/property_set.rb +18 -0
  21. data/lib/dolly/query.rb +39 -67
  22. data/lib/dolly/query_arguments.rb +35 -0
  23. data/lib/dolly/request.rb +12 -107
  24. data/lib/dolly/request_header.rb +26 -0
  25. data/lib/dolly/timestamp.rb +24 -0
  26. data/lib/dolly/version.rb +1 -1
  27. data/lib/{dolly → railties}/railtie.rb +2 -1
  28. data/lib/refinements/string_refinements.rb +28 -0
  29. data/lib/tasks/db.rake +4 -3
  30. data/test/bulk_document_test.rb +8 -5
  31. data/test/document_test.rb +137 -53
  32. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  33. data/test/dummy/log/test.log +46417 -46858
  34. data/test/test_helper.rb +14 -20
  35. metadata +42 -145
  36. data/Rakefile +0 -11
  37. data/lib/dolly/bulk_error.rb +0 -16
  38. data/lib/dolly/db_config.rb +0 -20
  39. data/lib/dolly/interpreter.rb +0 -5
  40. data/lib/dolly/logger.rb +0 -9
  41. data/lib/dolly/name_space.rb +0 -28
  42. data/lib/dolly/timestamps.rb +0 -21
  43. data/lib/exceptions/dolly.rb +0 -47
  44. data/test/collection_test.rb +0 -59
  45. data/test/configuration_test.rb +0 -9
  46. data/test/dummy/README.rdoc +0 -28
  47. data/test/dummy/Rakefile +0 -6
  48. data/test/dummy/app/assets/javascripts/application.js +0 -13
  49. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  50. data/test/dummy/app/controllers/application_controller.rb +0 -5
  51. data/test/dummy/app/helpers/application_helper.rb +0 -2
  52. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  53. data/test/dummy/bin/bundle +0 -3
  54. data/test/dummy/bin/rails +0 -4
  55. data/test/dummy/bin/rake +0 -4
  56. data/test/dummy/config.ru +0 -4
  57. data/test/dummy/config/application.rb +0 -27
  58. data/test/dummy/config/boot.rb +0 -5
  59. data/test/dummy/config/couchdb.yml +0 -13
  60. data/test/dummy/config/environment.rb +0 -5
  61. data/test/dummy/config/environments/development.rb +0 -29
  62. data/test/dummy/config/environments/production.rb +0 -80
  63. data/test/dummy/config/environments/test.rb +0 -36
  64. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  65. data/test/dummy/config/initializers/inflections.rb +0 -16
  66. data/test/dummy/config/initializers/mime_types.rb +0 -5
  67. data/test/dummy/config/initializers/secret_token.rb +0 -12
  68. data/test/dummy/config/initializers/session_store.rb +0 -3
  69. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  70. data/test/dummy/config/locales/en.yml +0 -23
  71. data/test/dummy/config/routes.rb +0 -56
  72. data/test/dummy/lib/couch_rest_adapter/railtie.rb +0 -10
  73. data/test/dummy/public/404.html +0 -58
  74. data/test/dummy/public/422.html +0 -58
  75. data/test/dummy/public/500.html +0 -57
  76. data/test/dummy/public/favicon.ico +0 -0
  77. data/test/factories/factories.rb +0 -8
  78. data/test/request_test.rb +0 -25
@@ -1,37 +1,31 @@
1
- # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
1
+ require 'test/unit'
2
+ require 'webmock/test_unit'
3
+ require 'mocha/test_unit'
4
+ require 'securerandom'
3
5
 
4
- require 'fakeweb'
5
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
6
- require "rails/test_help"
7
-
8
- Rails.backtrace_cleaner.remove_silencers!
6
+ # Load gem files
7
+ Dir["#{File.dirname(__FILE__)}/../lib/dolly/**/*.rb"].each { |f| require f }
8
+ Dir["#{File.dirname(__FILE__)}/../lib/refinements/**/*.rb"].each { |f| require f }
9
+ Dir["#{File.dirname(__FILE__)}/../dolly.rb"].each { |f| require f }
9
10
 
10
11
  # Load support files
11
12
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
13
 
13
- # Load fixtures from the engine
14
- if ActiveSupport::TestCase.method_defined?(:fixture_path=)
15
- ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
16
- end
17
-
18
-
19
- class ActiveSupport::TestCase
14
+ class Test::Unit::TestCase
20
15
  DEFAULT_DB = 'test'
21
16
 
22
17
  setup :global_setup
23
18
 
24
19
  def global_setup
25
- FakeWeb.allow_net_connect = false
20
+ response = { uuids: [SecureRandom.uuid] }.to_json
26
21
 
27
- response = { uuids: [SecureRandom.uuid] }
28
- FakeWeb.register_uri(:get, %r|http://.*:5984/_uuids.*|, body: response.to_json)
22
+ stub_request(:get, %r{http://.*:5984/_uuids.*}).
23
+ to_return(status: 200, body: response, headers: { 'Content-Type': 'application/json'})
29
24
  end
30
25
 
31
26
  protected
27
+
32
28
  def base_path
33
- %r|http://.*:5984/#{DEFAULT_DB}|
29
+ %r{http://.*:5984/#{DEFAULT_DB}}
34
30
  end
35
-
36
31
  end
37
-
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.7
4
+ version: 3.0.0
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: 2017-05-02 00:00:00.000000000 Z
11
+ date: 2019-06-20 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,69 +101,42 @@ 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
151
110
  - lib/dolly/configuration.rb
152
111
  - lib/dolly/connection.rb
153
- - lib/dolly/db_config.rb
112
+ - lib/dolly/depracated_database.rb
154
113
  - lib/dolly/document.rb
155
- - lib/dolly/interpreter.rb
156
- - lib/dolly/logger.rb
157
- - 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/properties.rb
158
120
  - lib/dolly/property.rb
121
+ - lib/dolly/property_manager.rb
122
+ - lib/dolly/property_set.rb
159
123
  - lib/dolly/query.rb
160
- - lib/dolly/railtie.rb
124
+ - lib/dolly/query_arguments.rb
161
125
  - lib/dolly/request.rb
162
- - lib/dolly/timestamps.rb
126
+ - lib/dolly/request_header.rb
127
+ - lib/dolly/timestamp.rb
163
128
  - lib/dolly/version.rb
164
- - lib/exceptions/dolly.rb
129
+ - lib/railties/railtie.rb
130
+ - lib/refinements/string_refinements.rb
165
131
  - lib/tasks/db.rake
166
132
  - test/bulk_document_test.rb
167
- - test/collection_test.rb
168
- - test/configuration_test.rb
169
133
  - test/document_test.rb
170
- - test/dummy/README.rdoc
171
- - test/dummy/Rakefile
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
134
+ - test/dummy/config/initializers/filter_parameter_logging.rb
197
135
  - test/dummy/log/test.log
198
- - test/dummy/public/404.html
199
- - test/dummy/public/422.html
200
- - test/dummy/public/500.html
201
- - test/dummy/public/favicon.ico
202
- - test/factories/factories.rb
203
- - test/request_test.rb
204
136
  - test/support/test.txt
205
137
  - test/test_helper.rb
206
- homepage: ''
207
- licenses:
208
- - MIT
138
+ homepage: https://www.amco.me
139
+ licenses: []
209
140
  metadata: {}
210
141
  post_install_message:
211
142
  rdoc_options: []
@@ -223,48 +154,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
154
  version: '0'
224
155
  requirements: []
225
156
  rubyforge_project:
226
- rubygems_version: 2.5.1
157
+ rubygems_version: 2.6.13
227
158
  signing_key:
228
159
  specification_version: 4
229
160
  summary: will write something
230
161
  test_files:
231
- - test/bulk_document_test.rb
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
162
+ - test/dummy/config/initializers/filter_parameter_logging.rb
260
163
  - test/dummy/log/test.log
261
- - test/dummy/public/404.html
262
- - test/dummy/public/422.html
263
- - test/dummy/public/500.html
264
- - test/dummy/public/favicon.ico
265
- - test/dummy/Rakefile
266
- - test/dummy/README.rdoc
267
- - test/factories/factories.rb
268
- - test/request_test.rb
164
+ - test/bulk_document_test.rb
269
165
  - test/support/test.txt
270
166
  - test/test_helper.rb
167
+ - 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,9 +0,0 @@
1
- module Dolly
2
- class Logger < DelegateClass(::Logger)
3
- def initialize config
4
- logger = ::Logger.new(config.log_path)
5
- logger.progname = Dolly.name
6
- super logger
7
- end
8
- end
9
- 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