riak-client 1.4.2 → 1.4.3
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 +4 -4
- data/Gemfile +0 -1
- data/README.markdown +55 -3
- data/RELEASE_NOTES.md +18 -1
- data/lib/riak/util/escape.rb +3 -1
- data/lib/riak/version.rb +1 -1
- data/spec/riak/escape_spec.rb +5 -1
- data/spec/riak/http_backend_spec.rb +17 -0
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 6dbee3629c0d7cc2798d8daf842413b38dd480f8
         | 
| 4 | 
            +
              data.tar.gz: 1bcedfd574e6912f7da1372b7889a94a88767e06
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0b34ddb04c2868d5373f2bac8087453664d502b3cca06660908f87f81f10102264496e9119b7d522cbc72f14c5a125fb42fefb2d08dc26b08dd0cb0039464be6
         | 
| 7 | 
            +
              data.tar.gz: 6a62183303ee95d343c028ef76d2570ffafdb168089c3456803eb58e45d6811540058ba884b45156a0c9290603da54affb53aa8739b222199720a3ef1fa22bf2
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.markdown
    CHANGED
    
    | @@ -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[ | 
| 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[ | 
| 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:
         | 
    
        data/RELEASE_NOTES.md
    CHANGED
    
    | @@ -1,6 +1,23 @@ | |
| 1 1 | 
             
            # Riak Ruby Client Release Notes
         | 
| 2 2 |  | 
| 3 | 
            -
            ## 1.4. | 
| 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 |  | 
    
        data/lib/riak/util/escape.rb
    CHANGED
    
    | @@ -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). | 
| 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
         | 
    
        data/lib/riak/version.rb
    CHANGED
    
    
    
        data/spec/riak/escape_spec.rb
    CHANGED
    
    | @@ -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. | 
| 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- | 
| 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. | 
| 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.
         |