analysand 3.1.0 → 4.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8530353cf2a187253a38f68e81c92c4db6269f1b
4
- data.tar.gz: 2805780572de1e5df3581a7720e76591af57e9cd
3
+ metadata.gz: eca0af883835f83b39acdbea7d71f0d4104ceee7
4
+ data.tar.gz: 999a46fa6aea95401a270f499acfd809a19f1748
5
5
  SHA512:
6
- metadata.gz: 7e983135f366396eb9767c9af43b656d81f5d3002512fc7069567af881ce18595f6209a228c3b1674ea36ee8562f6952f5a766c153d809373c7d56eb73a41d60
7
- data.tar.gz: 81d3c799ce2eda121427df8678d0a81ad3474e333633cd20772e91aa2c23e9784826312b6b67903c02250016e2b164110616ab920613eaf8fea7f13b4b59ddc1
6
+ metadata.gz: e9b9fd4d5b3652bbc976d17b00b9980b265d4b51896495a60a76cfd89305e23781605a8000ff2e9922683c789e196aee3091e260526045d6561580ce132db50d
7
+ data.tar.gz: abac9b899a43da636747aae1edd7b2d1f0453d574786a7c2ee839d788d22825a3e693a667490f2391af783221be53f48950ef420cfc699139da77bebcc2f9059
@@ -1,7 +1,14 @@
1
1
  language: ruby
2
2
  rvm:
3
- - rbx-2.4.1
4
- - 2.0.0
3
+ - rbx-2.5.1
4
+ - 2.2.0
5
+ env:
6
+ - RBXOPT=-Xint
7
+ - RBXOPT=
8
+ matrix:
9
+ exclude:
10
+ - rvm: 2.2.0
11
+ env: RBXOPT=-Xint
5
12
  before_script:
6
13
  - "./script/setup_database.rb"
7
14
  services:
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
@@ -5,4 +5,5 @@ gemspec
5
5
 
6
6
  platform :rbx do
7
7
  gem 'rubysl'
8
+ gem 'psych'
8
9
  end
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
- Naturally, we hang with all the cool kids:
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
 
@@ -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
  # ======================
@@ -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 += URI.escape(doc_id)
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)
@@ -1,3 +1,3 @@
1
1
  module Analysand
2
- VERSION = "3.1.0"
2
+ VERSION = "4.0.0"
3
3
  end
@@ -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 'escapes document IDs' do
79
- db.put('an ID', doc)
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
- db.get('an ID').should be_success
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 'escapes document IDs in URIs' do
401
- db.copy(doc_id, 'an ID')
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.get('an ID')['foo'].should == 'bar'
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 'escapes document IDs in URIs' do
439
- @put_resp = db.put!('an ID', doc)
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('an ID', rev)
442
- resp.should be_success
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
- it 'returns rows as soon as possible' do
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
 
@@ -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: 3.1.0
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
OSZAR »