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 CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: fb756b7603b4df704ece51bc868196e6a99fd8a2
4
- data.tar.gz: 271fce3c8b81ea091e5a786857e7efecbe31c845
5
- SHA512:
6
- metadata.gz: dbcfe0f9aa777af05f6cf145b4f5ee4d744df2430bbc4f2cd726571b1e7297537983ee6e12f64e47e0b14778efdd57fbda6aea1716ea6de16d509261767bc321
7
- data.tar.gz: 8eafdc8896c2aa0f65f7a7a7365a939a2ef5bb7ebfd5dae421a0c826aa2906261dc560d026308e20f2cc58aeaa6d3388cbd338a44e825e7a4968c5d64dd92bd5
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8530353cf2a187253a38f68e81c92c4db6269f1b
4
+ data.tar.gz: 2805780572de1e5df3581a7720e76591af57e9cd
5
+ SHA512:
6
+ metadata.gz: 7e983135f366396eb9767c9af43b656d81f5d3002512fc7069567af881ce18595f6209a228c3b1674ea36ee8562f6952f5a766c153d809373c7d56eb73a41d60
7
+ data.tar.gz: 81d3c799ce2eda121427df8678d0a81ad3474e333633cd20772e91aa2c23e9784826312b6b67903c02250016e2b164110616ab920613eaf8fea7f13b4b59ddc1
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - rbx-2.2.3
3
+ - rbx-2.4.1
4
4
  - 2.0.0
5
5
  before_script:
6
6
  - "./script/setup_database.rb"
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
 
@@ -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.15.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'
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Analysand
2
- VERSION = "3.0.1"
2
+ VERSION = "3.1.0"
3
3
  end
@@ -20,5 +20,9 @@ module Analysand
20
20
  def docs
21
21
  rows.map { |r| r['doc'] }.compact
22
22
  end
23
+
24
+ def keys
25
+ rows.map { |r| r['key'] }.compact
26
+ end
23
27
  end
24
28
  end
@@ -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 ex(BulkOperationFailed, resp) unless resp.success?
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.should be_conflict
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.should_not be_conflict
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.should be_true
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.should == 1
99
+ expect(watcher.changes.select { |r| r['id'] == 'foo' }.length).to eq(1)
100
100
  end
101
101
  end
102
102
  end
@@ -55,12 +55,6 @@ module Analysand
55
55
  end
56
56
  end
57
57
 
58
- describe '#close' do
59
- it "shuts down the current thread's connection" do
60
- pending 'a good way to test this'
61
- end
62
- end
63
-
64
58
  describe '#head' do
65
59
  before do
66
60
  clean_databases!
@@ -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
@@ -164,7 +164,7 @@ module Analysand
164
164
  instance.delete_config('foo/bar', admin_credentials)
165
165
 
166
166
  resp = instance.get_config('foo/bar', admin_credentials)
167
- resp.not_found?.should be_true
167
+ expect(resp.not_found?).to eq(true)
168
168
  end
169
169
  end
170
170
 
@@ -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') }.should be_true
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.1
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
- date: 2014-01-15 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
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: &id001 !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 0.15.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
- version_requirements: *id001
24
- - !ruby/object:Gem::Dependency
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: &id002 !ruby/object:Gem::Requirement
28
- requirements:
29
- - &id003
30
- - ">="
31
- - !ruby/object:Gem::Version
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
- version_requirements: *id002
35
- - !ruby/object:Gem::Dependency
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: &id004 !ruby/object:Gem::Requirement
39
- requirements:
40
- - *id003
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
41
54
  type: :runtime
42
- version_requirements: *id004
43
- - !ruby/object:Gem::Dependency
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: &id005 !ruby/object:Gem::Requirement
47
- requirements:
48
- - *id003
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
49
68
  type: :runtime
50
- version_requirements: *id005
51
- - !ruby/object:Gem::Dependency
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: &id006 !ruby/object:Gem::Requirement
55
- requirements:
56
- - *id003
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
57
82
  type: :runtime
58
- version_requirements: *id006
59
- - !ruby/object:Gem::Dependency
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: &id007 !ruby/object:Gem::Requirement
63
- requirements:
64
- - *id003
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
65
96
  type: :runtime
66
- version_requirements: *id007
67
- - !ruby/object:Gem::Dependency
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: &id008 !ruby/object:Gem::Requirement
71
- requirements:
72
- - *id003
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
73
110
  type: :runtime
74
- version_requirements: *id008
75
- - !ruby/object:Gem::Dependency
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: &id009 !ruby/object:Gem::Requirement
79
- requirements:
80
- - *id003
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
81
124
  type: :runtime
82
- version_requirements: *id009
83
- - !ruby/object:Gem::Dependency
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: &id010 !ruby/object:Gem::Requirement
87
- requirements:
88
- - *id003
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
89
138
  type: :development
90
- version_requirements: *id010
91
- - !ruby/object:Gem::Dependency
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: &id011 !ruby/object:Gem::Requirement
95
- requirements:
96
- - *id003
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
97
152
  type: :development
98
- version_requirements: *id011
99
- - !ruby/object:Gem::Dependency
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: &id012 !ruby/object:Gem::Requirement
103
- requirements:
104
- - *id003
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
105
166
  type: :development
106
- version_requirements: *id012
107
- - !ruby/object:Gem::Dependency
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: &id013 !ruby/object:Gem::Requirement
111
- requirements:
112
- - *id003
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
- files:
125
- - .gitignore
126
- - .rspec
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: "1.9"
191
- required_rubygems_version: !ruby/object:Gem::Requirement
192
- requirements:
193
- - *id003
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.1.10
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