dpla-analysand 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/CHANGELOG +67 -0
- data/Gemfile +8 -0
- data/LICENSE +22 -0
- data/README +48 -0
- data/Rakefile +22 -0
- data/analysand.gemspec +33 -0
- data/bin/analysand +27 -0
- data/lib/analysand.rb +3 -0
- data/lib/analysand/bulk_response.rb +14 -0
- data/lib/analysand/change_watcher.rb +280 -0
- data/lib/analysand/config_response.rb +25 -0
- data/lib/analysand/connection_testing.rb +52 -0
- data/lib/analysand/database.rb +322 -0
- data/lib/analysand/errors.rb +60 -0
- data/lib/analysand/http.rb +90 -0
- data/lib/analysand/instance.rb +255 -0
- data/lib/analysand/reading.rb +26 -0
- data/lib/analysand/response.rb +35 -0
- data/lib/analysand/response_headers.rb +18 -0
- data/lib/analysand/session_response.rb +16 -0
- data/lib/analysand/status_code_predicates.rb +25 -0
- data/lib/analysand/streaming_view_response.rb +90 -0
- data/lib/analysand/version.rb +3 -0
- data/lib/analysand/view_response.rb +24 -0
- data/lib/analysand/view_streaming/builder.rb +142 -0
- data/lib/analysand/viewing.rb +95 -0
- data/lib/analysand/writing.rb +71 -0
- data/script/setup_database.rb +45 -0
- data/spec/analysand/a_response.rb +70 -0
- data/spec/analysand/change_watcher_spec.rb +102 -0
- data/spec/analysand/database_spec.rb +243 -0
- data/spec/analysand/database_writing_spec.rb +488 -0
- data/spec/analysand/instance_spec.rb +205 -0
- data/spec/analysand/response_spec.rb +26 -0
- data/spec/analysand/view_response_spec.rb +44 -0
- data/spec/analysand/view_streaming/builder_spec.rb +73 -0
- data/spec/analysand/view_streaming_spec.rb +122 -0
- data/spec/fixtures/vcr_cassettes/get_config.yml +40 -0
- data/spec/fixtures/vcr_cassettes/get_many_config.yml +40 -0
- data/spec/fixtures/vcr_cassettes/head_request_with_etag.yml +40 -0
- data/spec/fixtures/vcr_cassettes/reload_config.yml +114 -0
- data/spec/fixtures/vcr_cassettes/unauthorized_put_config.yml +43 -0
- data/spec/fixtures/vcr_cassettes/view.yml +40 -0
- data/spec/smoke/database_thread_spec.rb +59 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/support/database_access.rb +40 -0
- data/spec/support/example_isolation.rb +86 -0
- data/spec/support/test_parameters.rb +39 -0
- metadata +283 -0
@@ -0,0 +1,86 @@
|
|
1
|
+
require File.expand_path('../test_parameters', __FILE__)
|
2
|
+
|
3
|
+
##
|
4
|
+
# CouchDB doesn't implement a commit/rollback scheme like other databases, but
|
5
|
+
# it would nevertheless still sometimes be nice to be able to isolate
|
6
|
+
# datastore changes made between tests.
|
7
|
+
#
|
8
|
+
# This module provides methods to drop and create databases, which provides a
|
9
|
+
# slow-yet-effective way of achieving said isolation. Examples:
|
10
|
+
#
|
11
|
+
# describe Something do
|
12
|
+
# let(:database_uri) { 'http://localhost:5984' }
|
13
|
+
# let(:database_name) { 'something' }
|
14
|
+
#
|
15
|
+
# before do
|
16
|
+
# clean_databases!
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# describe AnotherThing do
|
21
|
+
# let(:database_uri) { 'http://localhost:5984' }
|
22
|
+
# let(:database_names) { ['another', 'database'] }
|
23
|
+
#
|
24
|
+
# before do
|
25
|
+
# clean_databases!
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# If both database_name and database_names are specified in the same example
|
30
|
+
# group, the latter will have precedence.
|
31
|
+
#
|
32
|
+
#
|
33
|
+
# Clean databases come with a performance cost
|
34
|
+
# ============================================
|
35
|
+
#
|
36
|
+
# Dropping and creating databases has a real performance cost, so it is
|
37
|
+
# advised that you only use this when absolutely necessary. Databases are
|
38
|
+
# only cleaned when
|
39
|
+
#
|
40
|
+
# clean_databases!
|
41
|
+
#
|
42
|
+
# is included in an example group's before block.
|
43
|
+
module ExampleIsolation
|
44
|
+
def clean_databases!
|
45
|
+
drop_databases!
|
46
|
+
create_databases!
|
47
|
+
end
|
48
|
+
|
49
|
+
def drop_databases!
|
50
|
+
affected_databases.each do |db|
|
51
|
+
uri = instance_uri + "/#{db}"
|
52
|
+
credentials = admin_credentials
|
53
|
+
|
54
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
55
|
+
req = Net::HTTP::Delete.new(uri.path)
|
56
|
+
req.basic_auth(admin_username, admin_password)
|
57
|
+
|
58
|
+
http.request(req)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_databases!
|
64
|
+
affected_databases.each do |db|
|
65
|
+
uri = instance_uri + "/#{db}"
|
66
|
+
credentials = admin_credentials
|
67
|
+
|
68
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
69
|
+
req = Net::HTTP::Put.new(uri.path)
|
70
|
+
req.basic_auth(admin_username, admin_password)
|
71
|
+
|
72
|
+
http.request(req)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def affected_databases
|
78
|
+
if respond_to?(:database_name)
|
79
|
+
[database_name]
|
80
|
+
elsif respond_to?(:database_names)
|
81
|
+
database_names
|
82
|
+
end.flatten
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# vim:ts=2:sw=2:et:tw=78
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module TestParameters
|
4
|
+
def admin_username
|
5
|
+
'admin'
|
6
|
+
end
|
7
|
+
|
8
|
+
def admin_password
|
9
|
+
'admin'
|
10
|
+
end
|
11
|
+
|
12
|
+
def admin_credentials
|
13
|
+
{ :username => admin_username, :password => admin_password }
|
14
|
+
end
|
15
|
+
|
16
|
+
def member1_username
|
17
|
+
'member1'
|
18
|
+
end
|
19
|
+
|
20
|
+
def member1_password
|
21
|
+
'member1'
|
22
|
+
end
|
23
|
+
|
24
|
+
def member1_credentials
|
25
|
+
{ :username => member1_username, :password => member1_password }
|
26
|
+
end
|
27
|
+
|
28
|
+
def instance_uri
|
29
|
+
URI('http://localhost:5984')
|
30
|
+
end
|
31
|
+
|
32
|
+
def database_name
|
33
|
+
'analysand_test'
|
34
|
+
end
|
35
|
+
|
36
|
+
def database_uri
|
37
|
+
URI("#{instance_uri}/#{database_name}")
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,283 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dpla-analysand
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Yip
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: celluloid
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.16.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.16.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: celluloid-io
|
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: http_parser.rb
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json-stream
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: net-http-persistent
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rack
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: yajl-ruby
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: vcr
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: webmock
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description: A terrible burden for a couch
|
182
|
+
email:
|
183
|
+
- yipdw@member.fsf.org
|
184
|
+
executables:
|
185
|
+
- analysand
|
186
|
+
extensions: []
|
187
|
+
extra_rdoc_files: []
|
188
|
+
files:
|
189
|
+
- .gitignore
|
190
|
+
- .rspec
|
191
|
+
- .travis.yml
|
192
|
+
- CHANGELOG
|
193
|
+
- Gemfile
|
194
|
+
- LICENSE
|
195
|
+
- README
|
196
|
+
- Rakefile
|
197
|
+
- analysand.gemspec
|
198
|
+
- bin/analysand
|
199
|
+
- lib/analysand.rb
|
200
|
+
- lib/analysand/bulk_response.rb
|
201
|
+
- lib/analysand/change_watcher.rb
|
202
|
+
- lib/analysand/config_response.rb
|
203
|
+
- lib/analysand/connection_testing.rb
|
204
|
+
- lib/analysand/database.rb
|
205
|
+
- lib/analysand/errors.rb
|
206
|
+
- lib/analysand/http.rb
|
207
|
+
- lib/analysand/instance.rb
|
208
|
+
- lib/analysand/reading.rb
|
209
|
+
- lib/analysand/response.rb
|
210
|
+
- lib/analysand/response_headers.rb
|
211
|
+
- lib/analysand/session_response.rb
|
212
|
+
- lib/analysand/status_code_predicates.rb
|
213
|
+
- lib/analysand/streaming_view_response.rb
|
214
|
+
- lib/analysand/version.rb
|
215
|
+
- lib/analysand/view_response.rb
|
216
|
+
- lib/analysand/view_streaming/builder.rb
|
217
|
+
- lib/analysand/viewing.rb
|
218
|
+
- lib/analysand/writing.rb
|
219
|
+
- script/setup_database.rb
|
220
|
+
- spec/analysand/a_response.rb
|
221
|
+
- spec/analysand/change_watcher_spec.rb
|
222
|
+
- spec/analysand/database_spec.rb
|
223
|
+
- spec/analysand/database_writing_spec.rb
|
224
|
+
- spec/analysand/instance_spec.rb
|
225
|
+
- spec/analysand/response_spec.rb
|
226
|
+
- spec/analysand/view_response_spec.rb
|
227
|
+
- spec/analysand/view_streaming/builder_spec.rb
|
228
|
+
- spec/analysand/view_streaming_spec.rb
|
229
|
+
- spec/fixtures/vcr_cassettes/get_config.yml
|
230
|
+
- spec/fixtures/vcr_cassettes/get_many_config.yml
|
231
|
+
- spec/fixtures/vcr_cassettes/head_request_with_etag.yml
|
232
|
+
- spec/fixtures/vcr_cassettes/reload_config.yml
|
233
|
+
- spec/fixtures/vcr_cassettes/unauthorized_put_config.yml
|
234
|
+
- spec/fixtures/vcr_cassettes/view.yml
|
235
|
+
- spec/smoke/database_thread_spec.rb
|
236
|
+
- spec/spec_helper.rb
|
237
|
+
- spec/support/database_access.rb
|
238
|
+
- spec/support/example_isolation.rb
|
239
|
+
- spec/support/test_parameters.rb
|
240
|
+
homepage: https://github.com/yipdw/analysand
|
241
|
+
licenses: []
|
242
|
+
metadata: {}
|
243
|
+
post_install_message:
|
244
|
+
rdoc_options: []
|
245
|
+
require_paths:
|
246
|
+
- lib
|
247
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
248
|
+
requirements:
|
249
|
+
- - '>='
|
250
|
+
- !ruby/object:Gem::Version
|
251
|
+
version: '1.9'
|
252
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
253
|
+
requirements:
|
254
|
+
- - '>='
|
255
|
+
- !ruby/object:Gem::Version
|
256
|
+
version: '0'
|
257
|
+
requirements: []
|
258
|
+
rubyforge_project:
|
259
|
+
rubygems_version: 2.0.14
|
260
|
+
signing_key:
|
261
|
+
specification_version: 4
|
262
|
+
summary: A CouchDB client of dubious worth
|
263
|
+
test_files:
|
264
|
+
- spec/analysand/a_response.rb
|
265
|
+
- spec/analysand/change_watcher_spec.rb
|
266
|
+
- spec/analysand/database_spec.rb
|
267
|
+
- spec/analysand/database_writing_spec.rb
|
268
|
+
- spec/analysand/instance_spec.rb
|
269
|
+
- spec/analysand/response_spec.rb
|
270
|
+
- spec/analysand/view_response_spec.rb
|
271
|
+
- spec/analysand/view_streaming/builder_spec.rb
|
272
|
+
- spec/analysand/view_streaming_spec.rb
|
273
|
+
- spec/fixtures/vcr_cassettes/get_config.yml
|
274
|
+
- spec/fixtures/vcr_cassettes/get_many_config.yml
|
275
|
+
- spec/fixtures/vcr_cassettes/head_request_with_etag.yml
|
276
|
+
- spec/fixtures/vcr_cassettes/reload_config.yml
|
277
|
+
- spec/fixtures/vcr_cassettes/unauthorized_put_config.yml
|
278
|
+
- spec/fixtures/vcr_cassettes/view.yml
|
279
|
+
- spec/smoke/database_thread_spec.rb
|
280
|
+
- spec/spec_helper.rb
|
281
|
+
- spec/support/database_access.rb
|
282
|
+
- spec/support/example_isolation.rb
|
283
|
+
- spec/support/test_parameters.rb
|