dpla-analysand 3.1.0.pre.dpla.1 → 4.0.0.pre.dpla.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90b8e57499d6d55a1dfabd8b3ce5e9998c2d2ad4
4
- data.tar.gz: 509ade65129c5986fe24e4b8f2a5cb5883171461
3
+ metadata.gz: bb0af98e4a48d2c5e825d30f981553f287163ded
4
+ data.tar.gz: 0acb1dfb8ebf0cb1ab7c8e56264e99a63a759ee6
5
5
  SHA512:
6
- metadata.gz: fa0aa6640a07ffa89a35f6aee54f6352d3e513abc6a43f6df053277b4ed41f453d3d4e0adbfb9b9c91eed74729ba7f57c1e758a3396e391a8e219dacc052c6fa
7
- data.tar.gz: b1c7aff36819f6a3c22e2c04c21125efa1f6fec37bc57aa80c155ea543c81b5ac70aad096ae52bc3870d9b78f31469968d322065c8757a95f409c26280d486e6
6
+ metadata.gz: 96f055679e8445e1d33e19229277a63b34e8773d7339393ffc9b13c744da973a372c9b232da3812c611a17a1e3e935d354b7a97fd72019633b6ea2a7b3911cce
7
+ data.tar.gz: ffadffb98f0c27aa0a3701e96e84d47bc585010abb7d9d989f2a117d589c93d5708734891d19d51ccee546f0388fc5d39e158a9895e97861430c5ed693f45339
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - rbx-2.4.1
4
- - 2.0.0
4
+ - 2.2.0
5
5
  before_script:
6
6
  - "./script/setup_database.rb"
7
7
  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 (?)
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 (?)
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.pre.dpla.1"
2
+ VERSION = "4.0.0.pre.dpla.1"
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpla-analysand
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.pre.dpla.1
4
+ version: 4.0.0.pre.dpla.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Yip
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-30 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid
@@ -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,5 +281,6 @@ 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
284
286
  has_rdoc: