analysand 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/.travis.yml +1 -1
- data/CHANGELOG +10 -0
- data/analysand.gemspec +1 -1
- data/lib/analysand/errors.rb +12 -0
- data/lib/analysand/streaming_view_response.rb +16 -0
- data/lib/analysand/version.rb +1 -1
- data/lib/analysand/view_response.rb +4 -0
- data/lib/analysand/writing.rb +1 -1
- data/spec/analysand/a_response.rb +2 -2
- data/spec/analysand/change_watcher_spec.rb +2 -2
- data/spec/analysand/database_spec.rb +0 -6
- data/spec/analysand/database_writing_spec.rb +1 -1
- data/spec/analysand/instance_spec.rb +1 -1
- data/spec/analysand/view_response_spec.rb +18 -0
- data/spec/analysand/view_streaming_spec.rb +6 -1
- metadata +156 -94
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8530353cf2a187253a38f68e81c92c4db6269f1b
|
4
|
+
data.tar.gz: 2805780572de1e5df3581a7720e76591af57e9cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7e983135f366396eb9767c9af43b656d81f5d3002512fc7069567af881ce18595f6209a228c3b1674ea36ee8562f6952f5a766c153d809373c7d56eb73a41d60
|
7
|
+
data.tar.gz: 81d3c799ce2eda121427df8678d0a81ad3474e333633cd20772e91aa2c23e9784826312b6b67903c02250016e2b164110616ab920613eaf8fea7f13b4b59ddc1
|
data/.travis.yml
CHANGED
data/CHANGELOG
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
Issue numbers refer to issues on Analysand's Github tracker:
|
2
2
|
https://github.com/yipdw/analysand/issues
|
3
3
|
|
4
|
+
3.1.0 (2015-02-03)
|
5
|
+
------------------
|
6
|
+
|
7
|
+
* New: StreamingViewResponse#keys (#6)
|
8
|
+
|
9
|
+
3.0.2 (2014-12-01)
|
10
|
+
-----------------
|
11
|
+
|
12
|
+
* Change Celluloid dependency to ~> 0.16.0.
|
13
|
+
|
4
14
|
3.0.1 (2014-01-14)
|
5
15
|
------------------
|
6
16
|
|
data/analysand.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.required_ruby_version = '>= 1.9'
|
19
19
|
|
20
|
-
gem.add_dependency 'celluloid', '~> 0.
|
20
|
+
gem.add_dependency 'celluloid', '~> 0.16.0'
|
21
21
|
gem.add_dependency 'celluloid-io'
|
22
22
|
gem.add_dependency 'http_parser.rb'
|
23
23
|
gem.add_dependency 'json'
|
data/lib/analysand/errors.rb
CHANGED
@@ -10,6 +10,18 @@ module Analysand
|
|
10
10
|
ex.response = response
|
11
11
|
end
|
12
12
|
end
|
13
|
+
|
14
|
+
# Like #ex, but customized for bulk operations. (CouchDB's bulk_docs can
|
15
|
+
# return 2xx even on failure; you need to inspect the response body to
|
16
|
+
# figure out what happened.)
|
17
|
+
#
|
18
|
+
# klass - the exception class
|
19
|
+
# response - the response object that caused the error
|
20
|
+
def bulk_ex(klass, response)
|
21
|
+
klass.new("Bulk operation failed (some records reported failure)").tap do |ex|
|
22
|
+
ex.response = response
|
23
|
+
end
|
24
|
+
end
|
13
25
|
end
|
14
26
|
|
15
27
|
class InvalidURIError < StandardError
|
@@ -55,6 +55,22 @@ module Analysand
|
|
55
55
|
each { |r| yield r['doc'] if r.has_key?('doc') }
|
56
56
|
end
|
57
57
|
|
58
|
+
# Public: Yields document keys from the view stream.
|
59
|
+
#
|
60
|
+
# Note that #keys and #rows advance the same stream, so expect to miss half
|
61
|
+
# your rows if you do something like
|
62
|
+
#
|
63
|
+
# resp.keys.zip(resp.rows)
|
64
|
+
#
|
65
|
+
# If this is a problem for you, let me know and we can work out a solution.
|
66
|
+
def keys
|
67
|
+
to_enum(:get_keys)
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_keys
|
71
|
+
each { |r| yield r['key'] if r.has_key?('key') }
|
72
|
+
end
|
73
|
+
|
58
74
|
def total_rows
|
59
75
|
read until @generator.total_rows
|
60
76
|
|
data/lib/analysand/version.rb
CHANGED
data/lib/analysand/writing.rb
CHANGED
@@ -29,7 +29,7 @@ module Analysand
|
|
29
29
|
|
30
30
|
def bulk_docs!(docs, credentials = nil, options = {})
|
31
31
|
bulk_docs(docs, credentials, options).tap do |resp|
|
32
|
-
raise
|
32
|
+
raise bulk_ex(BulkOperationFailed, resp) unless resp.success?
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -12,13 +12,13 @@ shared_examples_for 'a response' do
|
|
12
12
|
it 'returns true if response code is 409' do
|
13
13
|
response.stub(:code => '409')
|
14
14
|
|
15
|
-
response.
|
15
|
+
expect(response.conflict?).to eq(true)
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'returns false if response code is 200' do
|
19
19
|
response.stub(:code => '200')
|
20
20
|
|
21
|
-
response.
|
21
|
+
expect(response.conflict?).to eq(false)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -52,7 +52,7 @@ module Analysand
|
|
52
52
|
it 'passes credentials' do
|
53
53
|
watcher = TestWatcher.new(db, admin_credentials)
|
54
54
|
|
55
|
-
watcher.connection_ok.
|
55
|
+
expect(watcher.connection_ok).to eq(true)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -96,7 +96,7 @@ module Analysand
|
|
96
96
|
db.put('foo', { 'foo' => 'bar' }, admin_credentials)
|
97
97
|
waiter.wait
|
98
98
|
|
99
|
-
watcher.changes.select { |r| r['id'] == 'foo' }.length.
|
99
|
+
expect(watcher.changes.select { |r| r['id'] == 'foo' }.length).to eq(1)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
@@ -354,7 +354,7 @@ module Analysand
|
|
354
354
|
end
|
355
355
|
|
356
356
|
it 'raises Analysand::BulkOperationFailed' do
|
357
|
-
lambda { db.bulk_docs!([doc1, doc2]) }.should raise_error(Analysand::BulkOperationFailed)
|
357
|
+
lambda { db.bulk_docs!([doc1, doc2]) }.should raise_error(Analysand::BulkOperationFailed, /bulk operation failed/i)
|
358
358
|
end
|
359
359
|
end
|
360
360
|
end
|
@@ -40,5 +40,23 @@ module Analysand
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
describe '#keys' do
|
45
|
+
describe 'if the view includes docs' do
|
46
|
+
subject { ViewResponse.new(double(:body => resp_with_docs)) }
|
47
|
+
|
48
|
+
it 'returns the value of the "key" key in each row' do
|
49
|
+
subject.keys.should == ['foo']
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'if the view does not include docs' do
|
54
|
+
subject { ViewResponse.new(double(:body => resp_without_docs)) }
|
55
|
+
|
56
|
+
it 'returns []' do
|
57
|
+
subject.keys.should == ['foo']
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
43
61
|
end
|
44
62
|
end
|
@@ -61,7 +61,12 @@ module Analysand
|
|
61
61
|
it 'yields docs' do
|
62
62
|
resp = get_view(:include_docs => true, :stream => true)
|
63
63
|
|
64
|
-
resp.docs.take(10).all? { |d| d.has_key?('_id') }.
|
64
|
+
expect(resp.docs.take(10).all? { |d| d.has_key?('_id') }).to eq(true)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'yields keys' do
|
68
|
+
resp = get_view(:include_docs => false, :stream => true)
|
69
|
+
expect(resp.keys.take(10).each { |k| k }).to eq(['abc123'] * 10)
|
65
70
|
end
|
66
71
|
|
67
72
|
it 'returns rows as soon as possible' do
|
metadata
CHANGED
@@ -1,130 +1,194 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: analysand
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- David Yip
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
version_requirements: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 0.16.0
|
15
19
|
name: celluloid
|
16
20
|
prerelease: false
|
17
|
-
requirement:
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 0.16.0
|
22
26
|
type: :runtime
|
23
|
-
|
24
|
-
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
25
33
|
name: celluloid-io
|
26
34
|
prerelease: false
|
27
|
-
requirement:
|
28
|
-
requirements:
|
29
|
-
-
|
30
|
-
-
|
31
|
-
|
32
|
-
version: "0"
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
33
40
|
type: :runtime
|
34
|
-
|
35
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
36
47
|
name: http_parser.rb
|
37
48
|
prerelease: false
|
38
|
-
requirement:
|
39
|
-
requirements:
|
40
|
-
-
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
41
54
|
type: :runtime
|
42
|
-
|
43
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
44
61
|
name: json
|
45
62
|
prerelease: false
|
46
|
-
requirement:
|
47
|
-
requirements:
|
48
|
-
-
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
49
68
|
type: :runtime
|
50
|
-
|
51
|
-
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
52
75
|
name: json-stream
|
53
76
|
prerelease: false
|
54
|
-
requirement:
|
55
|
-
requirements:
|
56
|
-
-
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
57
82
|
type: :runtime
|
58
|
-
|
59
|
-
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
60
89
|
name: net-http-persistent
|
61
90
|
prerelease: false
|
62
|
-
requirement:
|
63
|
-
requirements:
|
64
|
-
-
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
65
96
|
type: :runtime
|
66
|
-
|
67
|
-
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
68
103
|
name: rack
|
69
104
|
prerelease: false
|
70
|
-
requirement:
|
71
|
-
requirements:
|
72
|
-
-
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
73
110
|
type: :runtime
|
74
|
-
|
75
|
-
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
76
117
|
name: yajl-ruby
|
77
118
|
prerelease: false
|
78
|
-
requirement:
|
79
|
-
requirements:
|
80
|
-
-
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
81
124
|
type: :runtime
|
82
|
-
|
83
|
-
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
84
131
|
name: rake
|
85
132
|
prerelease: false
|
86
|
-
requirement:
|
87
|
-
requirements:
|
88
|
-
-
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
89
138
|
type: :development
|
90
|
-
|
91
|
-
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
92
145
|
name: rspec
|
93
146
|
prerelease: false
|
94
|
-
requirement:
|
95
|
-
requirements:
|
96
|
-
-
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
97
152
|
type: :development
|
98
|
-
|
99
|
-
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
100
159
|
name: vcr
|
101
160
|
prerelease: false
|
102
|
-
requirement:
|
103
|
-
requirements:
|
104
|
-
-
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
105
166
|
type: :development
|
106
|
-
|
107
|
-
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
108
173
|
name: webmock
|
109
174
|
prerelease: false
|
110
|
-
requirement:
|
111
|
-
requirements:
|
112
|
-
-
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
113
180
|
type: :development
|
114
|
-
version_requirements: *id013
|
115
181
|
description: A terrible burden for a couch
|
116
|
-
email:
|
182
|
+
email:
|
117
183
|
- yipdw@member.fsf.org
|
118
|
-
executables:
|
184
|
+
executables:
|
119
185
|
- analysand
|
120
186
|
extensions: []
|
121
|
-
|
122
187
|
extra_rdoc_files: []
|
123
|
-
|
124
|
-
|
125
|
-
- .
|
126
|
-
- .
|
127
|
-
- .travis.yml
|
188
|
+
files:
|
189
|
+
- ".gitignore"
|
190
|
+
- ".rspec"
|
191
|
+
- ".travis.yml"
|
128
192
|
- CHANGELOG
|
129
193
|
- Gemfile
|
130
194
|
- LICENSE
|
@@ -175,30 +239,28 @@ files:
|
|
175
239
|
- spec/support/test_parameters.rb
|
176
240
|
homepage: https://github.com/yipdw/analysand
|
177
241
|
licenses: []
|
178
|
-
|
179
242
|
metadata: {}
|
180
|
-
|
181
243
|
post_install_message:
|
182
244
|
rdoc_options: []
|
183
|
-
|
184
|
-
require_paths:
|
245
|
+
require_paths:
|
185
246
|
- lib
|
186
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
-
requirements:
|
247
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
248
|
+
requirements:
|
188
249
|
- - ">="
|
189
|
-
- !ruby/object:Gem::Version
|
190
|
-
version:
|
191
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
-
requirements:
|
193
|
-
-
|
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'
|
194
257
|
requirements: []
|
195
|
-
|
196
258
|
rubyforge_project:
|
197
|
-
rubygems_version: 2.
|
259
|
+
rubygems_version: 2.4.5
|
198
260
|
signing_key:
|
199
261
|
specification_version: 4
|
200
262
|
summary: A CouchDB client of dubious worth
|
201
|
-
test_files:
|
263
|
+
test_files:
|
202
264
|
- spec/analysand/a_response.rb
|
203
265
|
- spec/analysand/change_watcher_spec.rb
|
204
266
|
- spec/analysand/database_spec.rb
|