couchbase 3.0.0.alpha.1-universal-darwin-19 → 3.0.0.alpha.2-universal-darwin-19
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/.github/workflows/tests-6.0.3.yml +49 -0
- data/.github/workflows/tests.yml +47 -0
- data/.gitmodules +3 -0
- data/.idea/dictionaries/gem_terms.xml +5 -0
- data/.idea/inspectionProfiles/Project_Default.xml +1 -0
- data/.idea/vcs.xml +1 -0
- data/Gemfile +1 -0
- data/README.md +55 -2
- data/Rakefile +18 -0
- data/bin/init-cluster +62 -0
- data/bin/setup +1 -0
- data/couchbase.gemspec +3 -2
- data/examples/crud.rb +1 -2
- data/examples/managing_buckets.rb +47 -0
- data/examples/managing_collections.rb +58 -0
- data/examples/managing_query_indexes.rb +63 -0
- data/examples/query.rb +3 -2
- data/examples/query_with_consistency.rb +76 -0
- data/examples/subdocument.rb +23 -1
- data/ext/.clang-format +1 -1
- data/ext/.idea/dictionaries/couchbase_terms.xml +2 -0
- data/ext/.idea/vcs.xml +1 -0
- data/ext/CMakeLists.txt +30 -12
- data/ext/build_version.hxx.in +26 -0
- data/ext/couchbase/bucket.hxx +69 -8
- data/ext/couchbase/cluster.hxx +70 -54
- data/ext/couchbase/collections_manifest.hxx +3 -3
- data/ext/couchbase/configuration.hxx +14 -0
- data/ext/couchbase/couchbase.cxx +2044 -383
- data/ext/couchbase/{operations/document_id.hxx → document_id.hxx} +5 -4
- data/ext/couchbase/io/http_message.hxx +5 -1
- data/ext/couchbase/io/http_parser.hxx +2 -1
- data/ext/couchbase/io/http_session.hxx +6 -3
- data/ext/couchbase/io/{binary_message.hxx → mcbp_message.hxx} +15 -12
- data/ext/couchbase/io/mcbp_parser.hxx +99 -0
- data/ext/couchbase/io/{key_value_session.hxx → mcbp_session.hxx} +200 -95
- data/ext/couchbase/io/session_manager.hxx +37 -22
- data/ext/couchbase/mutation_token.hxx +2 -1
- data/ext/couchbase/operations.hxx +38 -8
- data/ext/couchbase/operations/bucket_create.hxx +138 -0
- data/ext/couchbase/operations/bucket_drop.hxx +65 -0
- data/ext/couchbase/operations/bucket_flush.hxx +65 -0
- data/ext/couchbase/operations/bucket_get.hxx +69 -0
- data/ext/couchbase/operations/bucket_get_all.hxx +62 -0
- data/ext/couchbase/operations/bucket_settings.hxx +111 -0
- data/ext/couchbase/operations/bucket_update.hxx +115 -0
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +60 -0
- data/ext/couchbase/operations/collection_create.hxx +86 -0
- data/ext/couchbase/operations/collection_drop.hxx +82 -0
- data/ext/couchbase/operations/command.hxx +10 -10
- data/ext/couchbase/operations/document_decrement.hxx +80 -0
- data/ext/couchbase/operations/document_exists.hxx +80 -0
- data/ext/couchbase/operations/{get.hxx → document_get.hxx} +4 -2
- data/ext/couchbase/operations/document_get_and_lock.hxx +64 -0
- data/ext/couchbase/operations/document_get_and_touch.hxx +64 -0
- data/ext/couchbase/operations/document_increment.hxx +80 -0
- data/ext/couchbase/operations/document_insert.hxx +74 -0
- data/ext/couchbase/operations/{lookup_in.hxx → document_lookup_in.hxx} +2 -2
- data/ext/couchbase/operations/{mutate_in.hxx → document_mutate_in.hxx} +11 -2
- data/ext/couchbase/operations/{query.hxx → document_query.hxx} +101 -6
- data/ext/couchbase/operations/document_remove.hxx +67 -0
- data/ext/couchbase/operations/document_replace.hxx +76 -0
- data/ext/couchbase/operations/{upsert.hxx → document_touch.hxx} +14 -14
- data/ext/couchbase/operations/{remove.hxx → document_unlock.hxx} +12 -10
- data/ext/couchbase/operations/document_upsert.hxx +74 -0
- data/ext/couchbase/operations/query_index_build_deferred.hxx +85 -0
- data/ext/couchbase/operations/query_index_create.hxx +134 -0
- data/ext/couchbase/operations/query_index_drop.hxx +108 -0
- data/ext/couchbase/operations/query_index_get_all.hxx +106 -0
- data/ext/couchbase/operations/scope_create.hxx +81 -0
- data/ext/couchbase/operations/scope_drop.hxx +79 -0
- data/ext/couchbase/operations/scope_get_all.hxx +72 -0
- data/ext/couchbase/protocol/client_opcode.hxx +35 -0
- data/ext/couchbase/protocol/client_request.hxx +56 -9
- data/ext/couchbase/protocol/client_response.hxx +52 -15
- data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +81 -0
- data/ext/couchbase/protocol/cmd_decrement.hxx +187 -0
- data/ext/couchbase/protocol/cmd_exists.hxx +171 -0
- data/ext/couchbase/protocol/cmd_get.hxx +31 -8
- data/ext/couchbase/protocol/cmd_get_and_lock.hxx +142 -0
- data/ext/couchbase/protocol/cmd_get_and_touch.hxx +142 -0
- data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +16 -3
- data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +16 -3
- data/ext/couchbase/protocol/cmd_get_error_map.hxx +16 -3
- data/ext/couchbase/protocol/cmd_hello.hxx +24 -8
- data/ext/couchbase/protocol/cmd_increment.hxx +187 -0
- data/ext/couchbase/protocol/cmd_info.hxx +1 -0
- data/ext/couchbase/protocol/cmd_insert.hxx +172 -0
- data/ext/couchbase/protocol/cmd_lookup_in.hxx +28 -13
- data/ext/couchbase/protocol/cmd_mutate_in.hxx +65 -13
- data/ext/couchbase/protocol/cmd_remove.hxx +59 -4
- data/ext/couchbase/protocol/cmd_replace.hxx +172 -0
- data/ext/couchbase/protocol/cmd_sasl_auth.hxx +15 -3
- data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +15 -3
- data/ext/couchbase/protocol/cmd_sasl_step.hxx +15 -3
- data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -2
- data/ext/couchbase/protocol/cmd_touch.hxx +102 -0
- data/ext/couchbase/protocol/cmd_unlock.hxx +95 -0
- data/ext/couchbase/protocol/cmd_upsert.hxx +50 -14
- data/ext/couchbase/protocol/durability_level.hxx +67 -0
- data/ext/couchbase/protocol/frame_info_id.hxx +187 -0
- data/ext/couchbase/protocol/hello_feature.hxx +137 -0
- data/ext/couchbase/protocol/server_opcode.hxx +57 -0
- data/ext/couchbase/protocol/server_request.hxx +122 -0
- data/ext/couchbase/protocol/unsigned_leb128.h +15 -15
- data/ext/couchbase/utils/byteswap.hxx +1 -2
- data/ext/couchbase/utils/url_codec.hxx +225 -0
- data/ext/couchbase/version.hxx +3 -1
- data/ext/extconf.rb +4 -1
- data/ext/test/main.cxx +37 -113
- data/ext/third_party/snappy/.appveyor.yml +36 -0
- data/ext/third_party/snappy/.gitignore +8 -0
- data/ext/third_party/snappy/.travis.yml +98 -0
- data/ext/third_party/snappy/AUTHORS +1 -0
- data/ext/third_party/snappy/CMakeLists.txt +345 -0
- data/ext/third_party/snappy/CONTRIBUTING.md +26 -0
- data/ext/third_party/snappy/COPYING +54 -0
- data/ext/third_party/snappy/NEWS +188 -0
- data/ext/third_party/snappy/README.md +148 -0
- data/ext/third_party/snappy/cmake/SnappyConfig.cmake.in +33 -0
- data/ext/third_party/snappy/cmake/config.h.in +59 -0
- data/ext/third_party/snappy/docs/README.md +72 -0
- data/ext/third_party/snappy/format_description.txt +110 -0
- data/ext/third_party/snappy/framing_format.txt +135 -0
- data/ext/third_party/snappy/snappy-c.cc +90 -0
- data/ext/third_party/snappy/snappy-c.h +138 -0
- data/ext/third_party/snappy/snappy-internal.h +315 -0
- data/ext/third_party/snappy/snappy-sinksource.cc +121 -0
- data/ext/third_party/snappy/snappy-sinksource.h +182 -0
- data/ext/third_party/snappy/snappy-stubs-internal.cc +42 -0
- data/ext/third_party/snappy/snappy-stubs-internal.h +493 -0
- data/ext/third_party/snappy/snappy-stubs-public.h.in +63 -0
- data/ext/third_party/snappy/snappy-test.cc +613 -0
- data/ext/third_party/snappy/snappy-test.h +526 -0
- data/ext/third_party/snappy/snappy.cc +1770 -0
- data/ext/third_party/snappy/snappy.h +209 -0
- data/ext/third_party/snappy/snappy_compress_fuzzer.cc +60 -0
- data/ext/third_party/snappy/snappy_uncompress_fuzzer.cc +58 -0
- data/ext/third_party/snappy/snappy_unittest.cc +1512 -0
- data/ext/third_party/snappy/testdata/alice29.txt +3609 -0
- data/ext/third_party/snappy/testdata/asyoulik.txt +4122 -0
- data/ext/third_party/snappy/testdata/baddata1.snappy +0 -0
- data/ext/third_party/snappy/testdata/baddata2.snappy +0 -0
- data/ext/third_party/snappy/testdata/baddata3.snappy +0 -0
- data/ext/third_party/snappy/testdata/fireworks.jpeg +0 -0
- data/ext/third_party/snappy/testdata/geo.protodata +0 -0
- data/ext/third_party/snappy/testdata/html +1 -0
- data/ext/third_party/snappy/testdata/html_x_4 +1 -0
- data/ext/third_party/snappy/testdata/kppkn.gtb +0 -0
- data/ext/third_party/snappy/testdata/lcet10.txt +7519 -0
- data/ext/third_party/snappy/testdata/paper-100k.pdf +600 -2
- data/ext/third_party/snappy/testdata/plrabn12.txt +10699 -0
- data/ext/third_party/snappy/testdata/urls.10K +10000 -0
- data/lib/couchbase/binary_collection.rb +33 -76
- data/lib/couchbase/binary_collection_options.rb +94 -0
- data/lib/couchbase/bucket.rb +9 -3
- data/lib/couchbase/cluster.rb +161 -23
- data/lib/couchbase/collection.rb +108 -191
- data/lib/couchbase/collection_options.rb +430 -0
- data/lib/couchbase/errors.rb +136 -134
- data/lib/couchbase/json_transcoder.rb +32 -0
- data/lib/couchbase/management/analytics_index_manager.rb +185 -9
- data/lib/couchbase/management/bucket_manager.rb +84 -33
- data/lib/couchbase/management/collection_manager.rb +166 -1
- data/lib/couchbase/management/query_index_manager.rb +261 -0
- data/lib/couchbase/management/search_index_manager.rb +291 -0
- data/lib/couchbase/management/user_manager.rb +12 -10
- data/lib/couchbase/management/view_index_manager.rb +151 -1
- data/lib/couchbase/mutation_state.rb +11 -1
- data/lib/couchbase/scope.rb +4 -4
- data/lib/couchbase/version.rb +1 -1
- metadata +113 -18
- data/.travis.yml +0 -7
- data/ext/couchbase/io/binary_parser.hxx +0 -64
- data/lib/couchbase/results.rb +0 -307
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d3590c3ec0086255c72da32955a533915946c5f1a2380a668853d474645f7e18
         | 
| 4 | 
            +
              data.tar.gz: f0eacadba27b4c5668f0fa4a02e457ad5f5338485297f23a39b038e4ef8cda3c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 18986bda3fbfb90cc77c6bc640c363f69e896e9611863e5ab608beeec24557e6e0d6c93f3241bf007909142eb97ada16046b1eb8a0227c3de43156dbea826b20
         | 
| 7 | 
            +
              data.tar.gz: 7d54ba280b68565b60a375e0f5766ea40eb34daf48c798504403b4f657a9d2bc3429ddef9bed350538f2c56667158a132db153724b9aaba9059c0e8589071fc2
         | 
| @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            name: tests-6.0.3
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            on:
         | 
| 4 | 
            +
              push:
         | 
| 5 | 
            +
                branches: [ master ]
         | 
| 6 | 
            +
              pull_request:
         | 
| 7 | 
            +
                branches: [ master ]
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            jobs:
         | 
| 10 | 
            +
              test:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                runs-on: ubuntu-latest
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                services:
         | 
| 15 | 
            +
                  couchbase:
         | 
| 16 | 
            +
                    image: couchbase:enterprise-6.0.3
         | 
| 17 | 
            +
                    ports:
         | 
| 18 | 
            +
                      - 8091-8094:8091-8094
         | 
| 19 | 
            +
                      - 11210:11210
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                steps:
         | 
| 22 | 
            +
                  - name: Install build environment
         | 
| 23 | 
            +
                    run: sudo apt-get install -y libssl-dev cmake gcc g++ curl
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  - uses: actions/checkout@v2
         | 
| 26 | 
            +
                    with:
         | 
| 27 | 
            +
                      submodules: recursive
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  - name: Set up ruby
         | 
| 30 | 
            +
                    uses: ruby/setup-ruby@v1
         | 
| 31 | 
            +
                    with:
         | 
| 32 | 
            +
                      ruby-version: 2.6
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  - name: Install dependencies
         | 
| 35 | 
            +
                    run: bundle install
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  - name: Initialize couchbase
         | 
| 38 | 
            +
                    run: ./bin/init-cluster
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  - name: Compile extension
         | 
| 41 | 
            +
                    run: bundle exec rake compile
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  - name: Display library version
         | 
| 44 | 
            +
                    run: bundle exec ruby -I lib -r couchbase -e 'pp Couchbase::VERSION'
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  - name: Run tests
         | 
| 47 | 
            +
                    run: bundle exec rake test
         | 
| 48 | 
            +
                    env:
         | 
| 49 | 
            +
                      TEST_SERVER_VERSION: 6.0.3
         | 
| @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            name: tests
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            on:
         | 
| 4 | 
            +
              push:
         | 
| 5 | 
            +
                branches: [ master ]
         | 
| 6 | 
            +
              pull_request:
         | 
| 7 | 
            +
                branches: [ master ]
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            jobs:
         | 
| 10 | 
            +
              test:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                runs-on: ubuntu-latest
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                services:
         | 
| 15 | 
            +
                  couchbase:
         | 
| 16 | 
            +
                    image: couchbase
         | 
| 17 | 
            +
                    ports:
         | 
| 18 | 
            +
                      - 8091-8094:8091-8094
         | 
| 19 | 
            +
                      - 11210:11210
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                steps:
         | 
| 22 | 
            +
                  - name: Install build environment
         | 
| 23 | 
            +
                    run: sudo apt-get install -y libssl-dev cmake gcc g++ curl
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  - uses: actions/checkout@v2
         | 
| 26 | 
            +
                    with:
         | 
| 27 | 
            +
                      submodules: recursive
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  - name: Set up ruby
         | 
| 30 | 
            +
                    uses: ruby/setup-ruby@v1
         | 
| 31 | 
            +
                    with:
         | 
| 32 | 
            +
                      ruby-version: 2.6
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  - name: Install dependencies
         | 
| 35 | 
            +
                    run: bundle install
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  - name: Initialize couchbase
         | 
| 38 | 
            +
                    run: ./bin/init-cluster
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  - name: Compile extension
         | 
| 41 | 
            +
                    run: bundle exec rake compile
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  - name: Display library version
         | 
| 44 | 
            +
                    run: bundle exec ruby -I lib -r couchbase -e 'pp Couchbase::VERSION'
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  - name: Run tests
         | 
| 47 | 
            +
                    run: bundle exec rake test
         | 
    
        data/.gitmodules
    CHANGED
    
    
| @@ -2,11 +2,16 @@ | |
| 2 2 | 
             
              <dictionary name="gem_terms">
         | 
| 3 3 | 
             
                <words>
         | 
| 4 4 | 
             
                  <w>adhoc</w>
         | 
| 5 | 
            +
                  <w>datasets</w>
         | 
| 6 | 
            +
                  <w>datastores</w>
         | 
| 5 7 | 
             
                  <w>dataverse</w>
         | 
| 8 | 
            +
                  <w>keyspace</w>
         | 
| 6 9 | 
             
                  <w>libcouchbase</w>
         | 
| 7 10 | 
             
                  <w>opcode</w>
         | 
| 11 | 
            +
                  <w>subdoc</w>
         | 
| 8 12 | 
             
                  <w>subdocument</w>
         | 
| 9 13 | 
             
                  <w>upsert</w>
         | 
| 14 | 
            +
                  <w>upserting</w>
         | 
| 10 15 | 
             
                  <w>xattr</w>
         | 
| 11 16 | 
             
                </words>
         | 
| 12 17 | 
             
              </dictionary>
         | 
| @@ -2,6 +2,7 @@ | |
| 2 2 | 
             
              <profile version="1.0">
         | 
| 3 3 | 
             
                <option name="myName" value="Project Default" />
         | 
| 4 4 | 
             
                <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
         | 
| 5 | 
            +
                <inspection_tool class="RubyInstanceMethodNamingConvention" enabled="false" level="WARNING" enabled_by_default="false" />
         | 
| 5 6 | 
             
                <inspection_tool class="RubyStringKeysInHashInspection" enabled="false" level="WARNING" enabled_by_default="false" />
         | 
| 6 7 | 
             
              </profile>
         | 
| 7 8 | 
             
            </component>
         | 
    
        data/.idea/vcs.xml
    CHANGED
    
    | @@ -6,6 +6,7 @@ | |
| 6 6 | 
             
                <mapping directory="$PROJECT_DIR$/ext/third_party/gsl" vcs="Git" />
         | 
| 7 7 | 
             
                <mapping directory="$PROJECT_DIR$/ext/third_party/http_parser" vcs="Git" />
         | 
| 8 8 | 
             
                <mapping directory="$PROJECT_DIR$/ext/third_party/json" vcs="Git" />
         | 
| 9 | 
            +
                <mapping directory="$PROJECT_DIR$/ext/third_party/snappy" vcs="Git" />
         | 
| 9 10 | 
             
                <mapping directory="$PROJECT_DIR$/ext/third_party/spdlog" vcs="Git" />
         | 
| 10 11 | 
             
              </component>
         | 
| 11 12 | 
             
            </project>
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,6 +1,59 @@ | |
| 1 | 
            -
            # Couchbase Ruby Client
         | 
| 1 | 
            +
            # Couchbase Ruby Client [](https://github.com/couchbase/couchbase-ruby-client/actions?query=workflow%3Atests)
         | 
| 2 2 |  | 
| 3 | 
            -
            This repository contains the third generation of the Couchbase SDK for Ruby (aka. SDKv3)
         | 
| 3 | 
            +
            This repository contains the third generation of the official Couchbase SDK for Ruby (aka. SDKv3)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Support and Feedback
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            If you find an issue, please file it in [our JIRA issue tracker](http://couchbase.com/issues/browse/RCBC).
         | 
| 8 | 
            +
            Also you are always welcome on [our forum](https://forums.couchbase.com/c/ruby-sdk).
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            Please attach version information to ticket/post. To obtain this information use the following command:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                $ ruby -r couchbase -e 'p Couchbase::VERSION'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            ## Installation
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            Add this line to your application's Gemfile:
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            ```ruby
         | 
| 19 | 
            +
            gem "couchbase", "3.0.0.alpha.2"
         | 
| 20 | 
            +
            ```
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            And then execute:
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                $ bundle install
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            Or install it yourself as:
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                $ gem install --pre couchbase
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            For some platforms we precompile binary packages. When, for some reason, binary package cannot be used, pass
         | 
| 31 | 
            +
            `--platform=ruby` to `gem install` command (or check `specific_platform` and `force_ruby_platform` options of Bundler).
         | 
| 32 | 
            +
            In latter case, see [Development](#development) section for build dependencies.
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            ## Development
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive
         | 
| 37 | 
            +
            prompt that will allow you to experiment.
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            Part of the library is written in C++, and requires both C and C++ compilers installed on the system. To configure build
         | 
| 40 | 
            +
            environment, it uses `cmake`. When these tools installed, the build process is easy:
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                $ rake compile
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            ## Generate Documentation
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            To generate documentation `yard` library is highly recommended.
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                $ gem install yard
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            The following steps will generate API reference for selected git tag:
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                $ rake doc
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            Now the API reference is accessible using web browser (where `VERSION` is current version of the SDK)
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                $ firefox doc/couchbase-ruby-client-VERSION/index.html
         | 
| 4 57 |  | 
| 5 58 | 
             
            ## License
         | 
| 6 59 |  | 
    
        data/Rakefile
    CHANGED
    
    | @@ -27,3 +27,21 @@ task :compile do | |
| 27 27 | 
             
                sh "ruby #{File.join(__dir__, "ext", "extconf.rb")}"
         | 
| 28 28 | 
             
              end
         | 
| 29 29 | 
             
            end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            task :doc do
         | 
| 32 | 
            +
              require "couchbase/version"
         | 
| 33 | 
            +
              input_dir = File.join(__dir__, "lib")
         | 
| 34 | 
            +
              output_dir = File.join(__dir__, "doc", "couchbase-ruby-client-#{Couchbase::VERSION[:sdk]}")
         | 
| 35 | 
            +
              rm_rf output_dir
         | 
| 36 | 
            +
              sh "yard doc --output-dir #{output_dir} #{input_dir}"
         | 
| 37 | 
            +
              puts "#{File.realpath(output_dir)}/index.html"
         | 
| 38 | 
            +
            end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            task :docs => :doc
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            task :render_git_revision do
         | 
| 43 | 
            +
              build_version_path = File.join(__dir__, 'ext', 'build_version.hxx.in')
         | 
| 44 | 
            +
              File.write(build_version_path, File.read(build_version_path).gsub('@BACKEND_GIT_REVISION@', `git rev-parse HEAD`.strip))
         | 
| 45 | 
            +
            end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            task :build => :render_git_revision
         | 
    
        data/bin/init-cluster
    ADDED
    
    | @@ -0,0 +1,62 @@ | |
| 1 | 
            +
            #!/usr/bin/env bash
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            #    Copyright 2020 Couchbase, Inc.
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            #  Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 6 | 
            +
            #  you may not use this file except in compliance with the License.
         | 
| 7 | 
            +
            #  You may obtain a copy of the License at
         | 
| 8 | 
            +
            #
         | 
| 9 | 
            +
            #      http://www.apache.org/licenses/LICENSE-2.0
         | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            #  Unless required by applicable law or agreed to in writing, software
         | 
| 12 | 
            +
            #  distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 13 | 
            +
            #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 14 | 
            +
            #  See the License for the specific language governing permissions and
         | 
| 15 | 
            +
            #  limitations under the License.
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            HOST="localhost"
         | 
| 18 | 
            +
            USERNAME="Administrator"
         | 
| 19 | 
            +
            PASSWORD="password"
         | 
| 20 | 
            +
            CREDS="${USERNAME}:${PASSWORD}"
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            sleep 1
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            set -ex
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            # Ping cluster
         | 
| 27 | 
            +
            curl -sS http://${HOST}:8091/pools
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            # Initialize Node
         | 
| 30 | 
            +
            curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/nodes/self/controller/settings \
         | 
| 31 | 
            +
                 -d 'path=%2Fopt%2Fcouchbase%2Fvar%2Flib%2Fcouchbase%2Fdata' \
         | 
| 32 | 
            +
                 -d 'index_path=%2Fopt%2Fcouchbase%2Fvar%2Flib%2Fcouchbase%2Fdata'
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            # Setup Services
         | 
| 35 | 
            +
            curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/node/controller/setupServices \
         | 
| 36 | 
            +
                 -d 'services=kv%2Cn1ql%2Cindex'
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            # Setup Memory Quotas
         | 
| 39 | 
            +
            curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/pools/default \
         | 
| 40 | 
            +
              -d 'memoryQuota=256' \
         | 
| 41 | 
            +
              -d 'indexMemoryQuota=256'
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            # Setup Administrator username and password
         | 
| 44 | 
            +
            curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/settings/web \
         | 
| 45 | 
            +
                 -d "password=${PASSWORD}" \
         | 
| 46 | 
            +
                 -d "username=${USERNAME}" \
         | 
| 47 | 
            +
                 -d "port=SAME"
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            # Setup index settings
         | 
| 50 | 
            +
            curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/settings/indexes \
         | 
| 51 | 
            +
                 -d "storageMode=plasma"
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            # Setup Bucket
         | 
| 54 | 
            +
            curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/pools/default/buckets \
         | 
| 55 | 
            +
                 -d 'flushEnabled=1' \
         | 
| 56 | 
            +
                 -d 'threadsNumber=3' \
         | 
| 57 | 
            +
                 -d 'replicaIndex=0' \
         | 
| 58 | 
            +
                 -d 'replicaNumber=0' \
         | 
| 59 | 
            +
                 -d 'evictionPolicy=valueOnly' \
         | 
| 60 | 
            +
                 -d 'ramQuotaMB=100' \
         | 
| 61 | 
            +
                 -d 'bucketType=membase' \
         | 
| 62 | 
            +
                 -d 'name=default'
         | 
    
        data/bin/setup
    CHANGED
    
    
    
        data/couchbase.gemspec
    CHANGED
    
    | @@ -23,8 +23,8 @@ Gem::Specification.new do |spec| | |
| 23 23 | 
             
              spec.email = ["sergey.avseyev@gmail.com"]
         | 
| 24 24 | 
             
              spec.summary = "SDK for Couchbase Server"
         | 
| 25 25 | 
             
              spec.description = "Modern SDK for Couchbase Server"
         | 
| 26 | 
            -
              spec.homepage = "https:// | 
| 27 | 
            -
              spec.license = " | 
| 26 | 
            +
              spec.homepage = "https://www.couchbase.com"
         | 
| 27 | 
            +
              spec.license = "Apache-2.0"
         | 
| 28 28 |  | 
| 29 29 | 
             
              spec.metadata["homepage_uri"] = spec.homepage
         | 
| 30 30 | 
             
              spec.metadata["source_code_uri"] = "https://github.com/couchbase/couchbase-ruby-client"
         | 
| @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| | |
| 37 37 | 
             
              spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 38 38 | 
             
              spec.require_paths = ["lib"]
         | 
| 39 39 | 
             
              spec.extensions = ["ext/extconf.rb"]
         | 
| 40 | 
            +
              spec.rdoc_options.append('--exclude', 'ext/')
         | 
| 40 41 |  | 
| 41 42 | 
             
              spec.add_development_dependency "bundler", "~> 2.1"
         | 
| 42 43 | 
             
              spec.add_development_dependency "rake", "~> 13.0"
         | 
    
        data/examples/crud.rb
    CHANGED
    
    | @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            require 'irb'
         | 
| 2 1 | 
             
            require 'couchbase'
         | 
| 3 2 | 
             
            include Couchbase
         | 
| 4 3 |  | 
| @@ -12,7 +11,7 @@ res = collection.upsert("foo", {"bar" => 42}) | |
| 12 11 | 
             
            p res.cas
         | 
| 13 12 |  | 
| 14 13 | 
             
            res = collection.get("foo")
         | 
| 15 | 
            -
            p res. | 
| 14 | 
            +
            p res.content
         | 
| 16 15 | 
             
            p res.cas
         | 
| 17 16 |  | 
| 18 17 | 
             
            res = collection.remove("foo")
         | 
| @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            require 'couchbase'
         | 
| 2 | 
            +
            include Couchbase
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            def measure(msg)
         | 
| 5 | 
            +
              start = Time.now
         | 
| 6 | 
            +
              yield
         | 
| 7 | 
            +
              printf "%s in %.2f seconds\n", msg, Time.now - start
         | 
| 8 | 
            +
            end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            options = Cluster::ClusterOptions.new
         | 
| 11 | 
            +
            options.authenticate("Administrator", "password")
         | 
| 12 | 
            +
            cluster = Cluster.connect("couchbase://localhost", options)
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            bucket_name = "new_bucket"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            all_buckets = cluster.buckets.get_all_buckets
         | 
| 17 | 
            +
            puts "There are #{all_buckets.size} buckets on the cluster"
         | 
| 18 | 
            +
            all_buckets.each do |bucket|
         | 
| 19 | 
            +
              puts " * #{bucket.name} (type: #{bucket.bucket_type}, quota: #{bucket.ram_quota_mb} MB)"
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            if all_buckets.any? { |bucket| bucket.name == bucket_name }
         | 
| 23 | 
            +
              measure("Bucket #{bucket_name.inspect} removed") { cluster.buckets.drop_bucket(bucket_name) }
         | 
| 24 | 
            +
            end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            settings = Management::BucketSettings.new
         | 
| 27 | 
            +
            settings.name = bucket_name
         | 
| 28 | 
            +
            settings.ram_quota_mb = 100
         | 
| 29 | 
            +
            settings.flush_enabled = true
         | 
| 30 | 
            +
            measure("New bucket #{bucket_name.inspect} created") { cluster.buckets.create_bucket(settings) }
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            sleep(1)
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            settings = cluster.buckets.get_bucket(bucket_name)
         | 
| 35 | 
            +
            puts "Bucket #{bucket_name.inspect} settings:"
         | 
| 36 | 
            +
            puts " * healthy?           : #{settings.healthy?}"
         | 
| 37 | 
            +
            puts " * RAM quota          : #{settings.ram_quota_mb}"
         | 
| 38 | 
            +
            puts " * number of replicas : #{settings.num_replicas}"
         | 
| 39 | 
            +
            puts " * flush enabled:     : #{settings.flush_enabled}"
         | 
| 40 | 
            +
            puts " * max TTL            : #{settings.max_expiry}"
         | 
| 41 | 
            +
            puts " * compression mode   : #{settings.compression_mode}"
         | 
| 42 | 
            +
            puts " * replica indexes    : #{settings.replica_indexes}"
         | 
| 43 | 
            +
            puts " * ejection policy    : #{settings.ejection_policy}"
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            measure("Bucket #{bucket_name.inspect} flushed") { cluster.buckets.flush_bucket(bucket_name) }
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            cluster.disconnect
         | 
| @@ -0,0 +1,58 @@ | |
| 1 | 
            +
            require 'couchbase'
         | 
| 2 | 
            +
            include Couchbase
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            def measure(msg)
         | 
| 5 | 
            +
              start = Time.now
         | 
| 6 | 
            +
              yield
         | 
| 7 | 
            +
              printf "%s in %.2f seconds\n", msg, Time.now - start
         | 
| 8 | 
            +
            end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            bucket_name = "travel-sample"
         | 
| 11 | 
            +
            scope_name = "myapp"
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            options = Cluster::ClusterOptions.new
         | 
| 14 | 
            +
            options.authenticate("Administrator", "password")
         | 
| 15 | 
            +
            cluster = Cluster.connect("couchbase://localhost", options)
         | 
| 16 | 
            +
            bucket = cluster.bucket(bucket_name)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
             | 
| 19 | 
            +
            scopes = bucket.collections.get_all_scopes
         | 
| 20 | 
            +
            puts "There are #{scopes.size} on the bucket \"#{bucket_name}\""
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            scopes.each do |scope|
         | 
| 23 | 
            +
              puts "  * \"#{scope.name}\" (#{scope.collections.size})"
         | 
| 24 | 
            +
              scope.collections.each do |collection|
         | 
| 25 | 
            +
                puts "    * \"#{collection.name}\""
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            if scopes.any? {|scope| scope.name == scope_name }
         | 
| 30 | 
            +
              measure("Scope \"#{scope_name}\" has been removed") { bucket.collections.drop_scope(scope_name) }
         | 
| 31 | 
            +
            end
         | 
| 32 | 
            +
            measure("Scope \"#{scope_name}\" has been created") { bucket.collections.create_scope(scope_name) }
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            scope = bucket.collections.get_scope(scope_name)
         | 
| 35 | 
            +
            puts "Scope \"#{scope_name}\" has #{scope.collections.size} collections"
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            collection = Management::CollectionSpec.new
         | 
| 38 | 
            +
            collection.scope_name = scope_name
         | 
| 39 | 
            +
            collection.name = "users"
         | 
| 40 | 
            +
            measure("Collection \"#{collection.name}\" on scope \"#{collection.scope_name}\" has been created") do
         | 
| 41 | 
            +
              bucket.collections.create_collection(collection)
         | 
| 42 | 
            +
            end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            scope = bucket.collections.get_scope(scope_name)
         | 
| 45 | 
            +
            puts "Scope \"#{scope_name}\" has #{scope.collections.size} collections"
         | 
| 46 | 
            +
            scope.collections.each do |collection|
         | 
| 47 | 
            +
              puts "  * \"#{collection.name}\""
         | 
| 48 | 
            +
            end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            measure("Collection \"#{collection.name}\" on scope \"#{collection.scope_name}\" has been dropped") do
         | 
| 51 | 
            +
              bucket.collections.drop_collection(collection)
         | 
| 52 | 
            +
            end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            scope = bucket.collections.get_scope(scope_name)
         | 
| 55 | 
            +
            puts "Scope \"#{scope_name}\" has #{scope.collections.size} collections"
         | 
| 56 | 
            +
            scope.collections.each do |collection|
         | 
| 57 | 
            +
              puts "  * \"#{collection.name}\""
         | 
| 58 | 
            +
            end
         |