analysand 3.1.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -2
- data/CHANGELOG +9 -0
- data/Gemfile +1 -0
- data/README +1 -2
- data/lib/analysand/database.rb +3 -0
- data/lib/analysand/http.rb +1 -1
- data/lib/analysand/version.rb +1 -1
- data/spec/analysand/database_spec.rb +16 -0
- data/spec/analysand/database_writing_spec.rb +24 -10
- data/spec/analysand/view_streaming_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/support/net_http_access.rb +22 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eca0af883835f83b39acdbea7d71f0d4104ceee7
|
4
|
+
data.tar.gz: 999a46fa6aea95401a270f499acfd809a19f1748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9b9fd4d5b3652bbc976d17b00b9980b265d4b51896495a60a76cfd89305e23781605a8000ff2e9922683c789e196aee3091e260526045d6561580ce132db50d
|
7
|
+
data.tar.gz: abac9b899a43da636747aae1edd7b2d1f0453d574786a7c2ee839d788d22825a3e693a667490f2391af783221be53f48950ef420cfc699139da77bebcc2f9059
|
data/.travis.yml
CHANGED
data/CHANGELOG
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
Issue numbers refer to issues on Analysand's Github tracker:
|
2
2
|
https://github.com/yipdw/analysand/issues
|
3
3
|
|
4
|
+
4.0.0 (2015-02-03)
|
5
|
+
------------------
|
6
|
+
|
7
|
+
Breaking changes:
|
8
|
+
|
9
|
+
Analysand::Database methods no longer perform any escaping on document IDs.
|
10
|
+
You will have to modify your code to use CGI.escape, Rack::Utils::escape_path,
|
11
|
+
etc. when passing in document IDs. (#7)
|
12
|
+
|
4
13
|
3.1.0 (2015-02-03)
|
5
14
|
------------------
|
6
15
|
|
data/Gemfile
CHANGED
data/README
CHANGED
@@ -31,11 +31,10 @@ of specific admin and non-admin users for its test suite.
|
|
31
31
|
See spec/support/test_parameters.rb for usernames, passwords, and connection
|
32
32
|
information.
|
33
33
|
|
34
|
-
|
34
|
+
Elsewhere on the Web:
|
35
35
|
|
36
36
|
* Travis CI: https://travis-ci.org/#!/yipdw/analysand
|
37
37
|
* Code Climate: https://codeclimate.com/github/yipdw/analysand
|
38
|
-
* Gemnasium: https://gemnasium.com/yipdw/analysand
|
39
38
|
|
40
39
|
4. License
|
41
40
|
|
data/lib/analysand/database.rb
CHANGED
@@ -229,6 +229,9 @@ module Analysand
|
|
229
229
|
#
|
230
230
|
# vdb.copy('source', "destination?rev=#{rev}", credentials)
|
231
231
|
#
|
232
|
+
# NOTE: CouchDB 1.5.0 and 1.6.1 expect an _unescaped_ destination document
|
233
|
+
# ID.
|
234
|
+
#
|
232
235
|
#
|
233
236
|
# Acceptable credentials
|
234
237
|
# ======================
|
data/lib/analysand/http.rb
CHANGED
@@ -59,7 +59,7 @@ module Analysand
|
|
59
59
|
# @private
|
60
60
|
def _req(klass, doc_id, credentials, query, headers, body, block)
|
61
61
|
uri = self.uri.dup
|
62
|
-
uri.path +=
|
62
|
+
uri.path += doc_id
|
63
63
|
uri.query = build_query(query) unless query.empty?
|
64
64
|
|
65
65
|
req = klass.new(uri.request_uri)
|
data/lib/analysand/version.rb
CHANGED
@@ -69,6 +69,15 @@ module Analysand
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
describe '#get' do
|
73
|
+
it 'retrieves documents with URI-escaped IDs' do
|
74
|
+
doc_id = CGI.escape('10067--http://ark.cdlib.org/ark:/13030/kt067nc38g')
|
75
|
+
net_http_put!(db, doc_id, { 'foo' => 'bar' })
|
76
|
+
|
77
|
+
db.get(doc_id).body['foo'].should == 'bar'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
72
81
|
describe '#get!' do
|
73
82
|
before do
|
74
83
|
clean_databases!
|
@@ -76,6 +85,13 @@ module Analysand
|
|
76
85
|
db.put!('foo', { 'foo' => 'bar' })
|
77
86
|
end
|
78
87
|
|
88
|
+
it 'retrieves documents with URI-escaped IDs' do
|
89
|
+
doc_id = CGI.escape('10067--http://ark.cdlib.org/ark:/13030/kt067nc38g')
|
90
|
+
net_http_put!(db, doc_id, { 'foo' => 'bar' })
|
91
|
+
|
92
|
+
db.get!(doc_id).body['foo'].should == 'bar'
|
93
|
+
end
|
94
|
+
|
79
95
|
describe 'if the response code is 200' do
|
80
96
|
it 'returns the document' do
|
81
97
|
db.get!('foo').body['foo'].should == 'bar'
|
@@ -75,10 +75,15 @@ module Analysand
|
|
75
75
|
resp.should be_success
|
76
76
|
end
|
77
77
|
|
78
|
-
it '
|
79
|
-
|
78
|
+
it 'does not double-escape document IDs' do
|
79
|
+
doc_id = CGI.escape('10067--http://ark.cdlib.org/ark:/13030/kt067nc38g')
|
80
|
+
put(doc_id, doc)
|
81
|
+
|
82
|
+
# Now we attempt to grab the escaped doc ID via good old HTTP. If #put
|
83
|
+
# doesn't double-escape, this should not result in a 404.
|
84
|
+
resp = net_http_get(db, doc_id)
|
80
85
|
|
81
|
-
|
86
|
+
expect(resp.code.to_i).to eq(200)
|
82
87
|
end
|
83
88
|
|
84
89
|
it 'handles URN-like IDs' do
|
@@ -397,10 +402,13 @@ module Analysand
|
|
397
402
|
db.get('bar')['foo'].should == 'bar'
|
398
403
|
end
|
399
404
|
|
400
|
-
it '
|
401
|
-
|
405
|
+
it 'copies documents with IDs that need to be escaped' do
|
406
|
+
target_doc_id = '10067--http://ark.cdlib.org/ark:/13030/kt067nc38g'
|
407
|
+
|
408
|
+
db.copy(doc_id, target_doc_id)
|
402
409
|
|
403
|
-
db.
|
410
|
+
resp = net_http_get(db, CGI.escape(target_doc_id))
|
411
|
+
expect(resp.code.to_i).to eq(200)
|
404
412
|
end
|
405
413
|
end
|
406
414
|
|
@@ -435,11 +443,17 @@ module Analysand
|
|
435
443
|
resp.should be_success
|
436
444
|
end
|
437
445
|
|
438
|
-
it '
|
439
|
-
|
446
|
+
it 'deletes documents with IDs that need to be escaped' do
|
447
|
+
doc_id = CGI.escape('10067--http://ark.cdlib.org/ark:/13030/kt067nc38g')
|
448
|
+
resp = net_http_put!(db, doc_id, {})
|
449
|
+
rev = JSON.parse(resp.body)['rev']
|
440
450
|
|
441
|
-
resp = db.delete(
|
442
|
-
|
451
|
+
resp = db.delete(doc_id, rev)
|
452
|
+
|
453
|
+
# DELETE normally returns 200, but a CouchDB server can also return 202
|
454
|
+
# if it is configured to operate in delayed commit mode. This test
|
455
|
+
# accepts either as success.
|
456
|
+
expect(resp.code).to match(/\A20[02]\Z/)
|
443
457
|
end
|
444
458
|
end
|
445
459
|
|
@@ -69,7 +69,7 @@ module Analysand
|
|
69
69
|
expect(resp.keys.take(10).each { |k| k }).to eq(['abc123'] * 10)
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
xit 'returns rows as soon as possible' do
|
73
73
|
# first, make sure the view's built
|
74
74
|
db.head('_design/doc/_view/a_view', admin_credentials)
|
75
75
|
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,7 @@ $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
|
2
2
|
|
3
3
|
require File.expand_path('../support/database_access', __FILE__)
|
4
4
|
require File.expand_path('../support/example_isolation', __FILE__)
|
5
|
+
require File.expand_path('../support/net_http_access', __FILE__)
|
5
6
|
require File.expand_path('../support/test_parameters', __FILE__)
|
6
7
|
|
7
8
|
require 'celluloid/autostart' # for ChangeWatcher specs
|
@@ -10,6 +11,7 @@ require 'vcr'
|
|
10
11
|
RSpec.configure do |config|
|
11
12
|
config.include DatabaseAccess
|
12
13
|
config.include ExampleIsolation
|
14
|
+
config.include NetHttpAccess
|
13
15
|
config.include TestParameters
|
14
16
|
|
15
17
|
config.around do |example|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
##
|
4
|
+
# Methods to do GET and PUT without any of the extra stuff in Analysand::Http
|
5
|
+
# or Analysand::Response.
|
6
|
+
module NetHttpAccess
|
7
|
+
def net_http_get(db, doc_id)
|
8
|
+
Net::HTTP.get_response(URI.join(db.uri, doc_id))
|
9
|
+
end
|
10
|
+
|
11
|
+
def net_http_put!(db, doc_id, doc)
|
12
|
+
uri = URI.join(db.uri, doc_id)
|
13
|
+
req = Net::HTTP::Put.new(uri)
|
14
|
+
req.body = doc.to_json
|
15
|
+
|
16
|
+
resp = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
17
|
+
http.request(req)
|
18
|
+
end
|
19
|
+
|
20
|
+
resp.tap { |r| raise unless Net::HTTPSuccess === r }
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: analysand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Yip
|
@@ -236,6 +236,7 @@ files:
|
|
236
236
|
- spec/spec_helper.rb
|
237
237
|
- spec/support/database_access.rb
|
238
238
|
- spec/support/example_isolation.rb
|
239
|
+
- spec/support/net_http_access.rb
|
239
240
|
- spec/support/test_parameters.rb
|
240
241
|
homepage: https://github.com/yipdw/analysand
|
241
242
|
licenses: []
|
@@ -280,4 +281,5 @@ test_files:
|
|
280
281
|
- spec/spec_helper.rb
|
281
282
|
- spec/support/database_access.rb
|
282
283
|
- spec/support/example_isolation.rb
|
284
|
+
- spec/support/net_http_access.rb
|
283
285
|
- spec/support/test_parameters.rb
|