riak-client 1.4.2 → 1.4.3

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: ead2288b6e4cf47a182c33bb8f7d9305b3f8bf81
4
- data.tar.gz: 84f40a4b0c078fa3d8660d942c47987b9a79e1b6
3
+ metadata.gz: 6dbee3629c0d7cc2798d8daf842413b38dd480f8
4
+ data.tar.gz: 1bcedfd574e6912f7da1372b7889a94a88767e06
5
5
  SHA512:
6
- metadata.gz: d60099de09cdd2b8dd511eaed9482cd4ab8e35088b5946343afab8871e7414c571090cde02075e62176a312421270539ba7df646c5d44f66803fac1d85daf756
7
- data.tar.gz: 4e1513258ca94ac6032f0eda704df463104eb892a03c3d7fe0bd7288a157190a6a8ce4b867a863d28b194278ef3d84e81ad8f8a7f2385e74063a024dc6ebaae1
6
+ metadata.gz: 0b34ddb04c2868d5373f2bac8087453664d502b3cca06660908f87f81f10102264496e9119b7d522cbc72f14c5a125fb42fefb2d08dc26b08dd0cb0039464be6
7
+ data.tar.gz: 6a62183303ee95d343c028ef76d2570ffafdb168089c3456803eb58e45d6811540058ba884b45156a0c9290603da54affb53aa8739b222199720a3ef1fa22bf2
data/Gemfile CHANGED
@@ -2,7 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
  gem 'bundler'
5
- gem 'rake'
6
5
 
7
6
  group :guard do
8
7
  gem 'guard-rspec'
@@ -86,7 +86,6 @@ p results # => ["Please Please Me", "With The Beatles", "A Hard Day's Night",
86
86
  # "The Beatles", "Yellow Submarine", "Abbey Road", "Let It Be"]
87
87
  ```
88
88
 
89
-
90
89
  ## Riak Search Examples
91
90
 
92
91
  For more information about Riak Search, see [the Basho wiki](http://wiki.basho.com/Riak-Search.html).
@@ -155,11 +154,11 @@ object = bucket.get_or_new 'cobb.salad'
155
154
 
156
155
  # Indexes end with the "_bin" suffix to indicate they're binary or string
157
156
  # indexes. They can have multiple values.
158
- object.indexes[:ingredients_bin] = %w{lettuce tomato bacon egg chives}
157
+ object.indexes['ingredients_bin'] = %w{lettuce tomato bacon egg chives}
159
158
 
160
159
  # Indexes ending with the "_int" suffix are indexed as integers. They can
161
160
  # have multiple values too.
162
- object.indexes[:calories_int] = [220]
161
+ object.indexes['calories_int'] = [220]
163
162
 
164
163
  # You must re-save the object to store indexes.
165
164
  object.store
@@ -202,6 +201,59 @@ q.has_next_page? # => true
202
201
  q2 = q.next_page
203
202
  ```
204
203
 
204
+ ## Counter examples
205
+
206
+ For more information about counters in Riak, see [the Basho wiki](http://docs.basho.com/riak/latest/dev/references/http/counters/).
207
+
208
+ Counter records are automatically persisted on increment or decrement. The initial default value is 0.
209
+
210
+ ``` ruby
211
+ # Firstly, ensure that your bucket is allow_mult set to true
212
+ bucket = client.bucket "counters"
213
+ bucket.allow_mult = true
214
+
215
+ # You can create a counter by using the bucket's counter method
216
+ counter = bucket.counter("counter-key-here")
217
+ counter.increment
218
+ => nil
219
+
220
+ p counter.value
221
+ 1
222
+ => 1
223
+
224
+ # Let's increment one more time and then retrieve it from the database
225
+ counter.increment
226
+
227
+ # Retrieval is similar to creation
228
+ persisted_counter = Riak::Counter.new(bucket, "counter-key-here")
229
+
230
+ p persisted_counter.value
231
+ 2
232
+ => 2
233
+
234
+ # We can also increment by a specified number
235
+ persisted_counter.increment(20)
236
+ p persisted_counter.value
237
+ 22
238
+ => 22
239
+
240
+ # Decrement works much the same
241
+ persisted_counter.decrement
242
+ persisted_counter.value
243
+ => 21
244
+
245
+ persisted_counter.decrement(6)
246
+ persisted_counter.value
247
+ => 15
248
+
249
+ # Incrementing by anything other than integer will throw an ArgumentError
250
+ persisted_counter.increment "nonsense"
251
+ ArgumentError: Counters can only be incremented or decremented by integers.
252
+ ```
253
+
254
+ That's about it. PN Counters in Riak are distributed, so each node will receive the proper increment/decrement operation. Enjoy using them.
255
+
256
+
205
257
  ## How to Contribute
206
258
 
207
259
  * Fork the project on [Github](http://github.com/basho/riak-ruby-client). If you have already forked, use `git pull --rebase` to reapply your changes on top of the mainline. Example:
@@ -1,6 +1,23 @@
1
1
  # Riak Ruby Client Release Notes
2
2
 
3
- ## 1.4.2 Bugfix Release - TBD
3
+ ## 1.4.3 Bugfix Release - 2013-12-31
4
+
5
+ Release 1.4.3 fixes some bugs and improves documentation.
6
+
7
+ Documentation:
8
+ * Secondary Index examples in README now use string names.
9
+ * 1.4 Counter usage explained better, fixed by Srdjan "batasrki" Pejic in
10
+ https://github.com/basho/riak-ruby-client/pull/130
11
+
12
+ Bugfixes:
13
+
14
+ * Redundant `gem "rake"` in `Gemfile`.
15
+ * Escape square brackets in key names, reported and fixed by Garret Alfert in
16
+ https://github.com/basho/riak-ruby-client/issues/128 and
17
+ https://github.com/basho/riak-ruby-client/pull/129 , respectively.
18
+
19
+
20
+ ## 1.4.2 Bugfix Release - 2013-09-20
4
21
 
5
22
  Release 1.4.2 fixes a couple bugs.
6
23
 
@@ -52,7 +52,9 @@ module Riak
52
52
  # @return [String] the escaped path segment
53
53
  def escape(bucket_or_key)
54
54
  if Riak.escaper == URI
55
- Riak.escaper.escape(bucket_or_key.to_s).gsub(" ", "%20").gsub("+", "%2B").gsub('/', "%2F")
55
+ Riak.escaper.escape(bucket_or_key.to_s).
56
+ gsub(" ", "%20").gsub("+", "%2B").gsub("/", "%2F").
57
+ gsub("[", "%5B").gsub("]", "%5D")
56
58
  else #CGI
57
59
  Riak.escaper.escape(bucket_or_key.to_s).gsub("+", "%20").gsub('/', "%2F")
58
60
  end
@@ -1,3 +1,3 @@
1
1
  module Riak
2
- VERSION = "1.4.2"
2
+ VERSION = "1.4.3"
3
3
  end
@@ -48,7 +48,6 @@ describe Riak::Util::Escape do
48
48
  end
49
49
 
50
50
  it "should allow URI-safe characters" do
51
- @object.escape("bracket[one").should == "bracket[one"
52
51
  @object.escape("sean@basho").should == "sean@basho"
53
52
  end
54
53
 
@@ -56,6 +55,11 @@ describe Riak::Util::Escape do
56
55
  @object.escape("some/inner/path").should == "some%2Finner%2Fpath"
57
56
  end
58
57
 
58
+ it "should escape square brackets" do
59
+ @object.escape("bracket[one").should == "bracket%5Bone"
60
+ @object.escape("bracket]two").should == "bracket%5Dtwo"
61
+ end
62
+
59
63
  it "should convert the bucket or key to a string before escaping" do
60
64
  @object.escape(125).should == '125'
61
65
  end
@@ -49,6 +49,11 @@ describe Riak::Client::HTTPBackend do
49
49
  @backend.should_receive(:get).with([200,300], @backend.object_path('foo ', ' bar')).and_return({:headers => {"content-type" => ["application/json"]}, :body => '{"name":"Riak","company":"Basho"}'})
50
50
  @backend.fetch_object('foo ',' bar').should be_kind_of(Riak::RObject)
51
51
  end
52
+
53
+ it "should escape brackets in the bucket and key names" do
54
+ @backend.should_receive(:get).with([200,300], @backend.object_path('[foo]', '[bar]')).and_return({:headers => {"content-type" => ["application/json"]}, :body => '{"name":"Riak","company":"Basho"}'})
55
+ @backend.fetch_object('[foo]','[bar]').should be_kind_of(Riak::RObject)
56
+ end
52
57
  end
53
58
 
54
59
  context "reloading an object" do
@@ -130,6 +135,18 @@ describe Riak::Client::HTTPBackend do
130
135
  @backend.store_object(@object, :returnbody => true, :w => 2)
131
136
  end
132
137
  end
138
+
139
+ context "when the object's key contains square brackets" do
140
+ before :each do
141
+ @object.key = "[bar]"
142
+ end
143
+
144
+ it "should escape the key name" do
145
+ @backend.should_receive(:put).with([200,204,300], @backend.object_path("foo", "[bar]", {:returnbody => true}), "This is some text.", @headers).and_return({:headers => {'location' => ["/riak/foo/%5Bbar%5D"], "x-riak-vclock" => ["areallylonghashvalue"]}, :code => 204})
146
+ @backend.store_object(@object, :returnbody => true)
147
+ @object.key.should == "[bar]"
148
+ end
149
+ end
133
150
  end
134
151
 
135
152
  context "deleting an object" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riak-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Cribbs
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-20 00:00:00.000000000 Z
12
+ date: 2013-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -332,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
332
  version: '0'
333
333
  requirements: []
334
334
  rubyforge_project:
335
- rubygems_version: 2.1.0
335
+ rubygems_version: 2.0.14
336
336
  signing_key:
337
337
  specification_version: 4
338
338
  summary: riak-client is a rich client for Riak, the distributed database by Basho.