ciql 0.3.4 → 0.4.0
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/README.md +1 -1
- data/lib/ciql/version.rb +1 -1
- metadata +4 -8
- data/lib/ciql/client/thrift.rb +0 -54
- data/spec/ciql/client/thrift_spec.rb +0 -35
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 90a74923332f73607ec9ec7a36de440dbe47001d
         | 
| 4 | 
            +
              data.tar.gz: 1f569aa52dd3ccf3903c2e78cef45beb1c6a869c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 267ddb3749c72c8fb9883701726d155653ab8b154f4a08c709b132c51b7c37d1eddfccd3f271253d96cd2bc60ef1d86e5109d7403388410db5dfe3fff349e8df
         | 
| 7 | 
            +
              data.tar.gz: 9770ffcda81a5d21dcf43b51e888b6808d22e326b06f487fe6ec41458cbffeb9be3fb990167efda7cbd20aff2eabd3c44439d3344a48bdfd5ada4cb208287961
         | 
    
        data/README.md
    CHANGED
    
    | @@ -2,4 +2,4 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            [](https://travis-ci.org/Nulu/ciql) [](https://gemnasium.com/Nulu/ciql)
         | 
| 4 4 |  | 
| 5 | 
            -
            This project is currently small support utilities and extensions for the [ | 
| 5 | 
            +
            This project is currently small support utilities and extensions for the [cql-rb](https://github.com/iconara/cql-rb) driver.
         | 
    
        data/lib/ciql/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: ciql
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Justin Bradford
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014- | 
| 11 | 
            +
            date: 2014-05-12 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: cql-rb
         | 
| @@ -16,14 +16,14 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: 1.1 | 
| 19 | 
            +
                    version: 1.2.1
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: 1.1 | 
| 26 | 
            +
                    version: 1.2.1
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: simple_uuid
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -49,14 +49,12 @@ files: | |
| 49 49 | 
             
            - lib/ciql.rb
         | 
| 50 50 | 
             
            - lib/ciql/client/binary.rb
         | 
| 51 51 | 
             
            - lib/ciql/client/log.rb
         | 
| 52 | 
            -
            - lib/ciql/client/thrift.rb
         | 
| 53 52 | 
             
            - lib/ciql/configuration.rb
         | 
| 54 53 | 
             
            - lib/ciql/rails.rb
         | 
| 55 54 | 
             
            - lib/ciql/sanitize.rb
         | 
| 56 55 | 
             
            - lib/ciql/uuid.rb
         | 
| 57 56 | 
             
            - lib/ciql/version.rb
         | 
| 58 57 | 
             
            - spec/ciql/client/binary_spec.rb
         | 
| 59 | 
            -
            - spec/ciql/client/thrift_spec.rb
         | 
| 60 58 | 
             
            - spec/ciql/configuration_spec.rb
         | 
| 61 59 | 
             
            - spec/ciql/sanitize_spec.rb
         | 
| 62 60 | 
             
            - spec/ciql/uuid_spec.rb
         | 
| @@ -87,9 +85,7 @@ specification_version: 4 | |
| 87 85 | 
             
            summary: CQL Cassandra client for Ruby
         | 
| 88 86 | 
             
            test_files:
         | 
| 89 87 | 
             
            - spec/ciql/client/binary_spec.rb
         | 
| 90 | 
            -
            - spec/ciql/client/thrift_spec.rb
         | 
| 91 88 | 
             
            - spec/ciql/configuration_spec.rb
         | 
| 92 89 | 
             
            - spec/ciql/sanitize_spec.rb
         | 
| 93 90 | 
             
            - spec/ciql/uuid_spec.rb
         | 
| 94 91 | 
             
            - spec/spec_helper.rb
         | 
| 95 | 
            -
            has_rdoc: 
         | 
    
        data/lib/ciql/client/thrift.rb
    DELETED
    
    | @@ -1,54 +0,0 @@ | |
| 1 | 
            -
            require 'cassandra-cql/1.2'
         | 
| 2 | 
            -
            require 'cassandra-cql'
         | 
| 3 | 
            -
            require 'benchmark'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            require 'ciql/client/log'
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            module Ciql::Client
         | 
| 8 | 
            -
              class Thrift < CassandraCQL::Database
         | 
| 9 | 
            -
                include Log
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                attr_reader :connection
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                def initialize(options={})
         | 
| 14 | 
            -
                  options     = options.dup
         | 
| 15 | 
            -
                  @log_format = options.delete(:log_format)
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  retries = options.delete(:retries) { 2 }
         | 
| 18 | 
            -
                  port    = options.delete(:port) { 9160 }
         | 
| 19 | 
            -
                  hosts   = options.delete(:host) { '127.0.0.1' }.split(',')
         | 
| 20 | 
            -
                  hosts_with_port = hosts.map { |host| [host, port].join(':') }
         | 
| 21 | 
            -
                  super(hosts_with_port, options, retries: retries)
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                def execute(statement, *arguments)
         | 
| 25 | 
            -
                  bind_variables    = arguments.shift statement.count('?')
         | 
| 26 | 
            -
                  bound_statement   = Ciql::Sanitize.sanitize(statement, *bind_variables)
         | 
| 27 | 
            -
                  compression_type  = CassandraCQL::Thrift::Compression::NONE
         | 
| 28 | 
            -
                  consistency_level = (arguments.shift or :quorum).to_s.upcase
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                  result = nil
         | 
| 31 | 
            -
                  times = Benchmark.measure do
         | 
| 32 | 
            -
                    result = CassandraCQL::Result.new(
         | 
| 33 | 
            -
                      @connection.execute_cql3_query(
         | 
| 34 | 
            -
                        bound_statement, compression_type,
         | 
| 35 | 
            -
                        CassandraCQL::Thrift::ConsistencyLevel.const_get(consistency_level)
         | 
| 36 | 
            -
                      )
         | 
| 37 | 
            -
                    )
         | 
| 38 | 
            -
                  end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                  log(
         | 
| 41 | 
            -
                    duration:    times.real * 10**3,
         | 
| 42 | 
            -
                    query:       bound_statement,
         | 
| 43 | 
            -
                    compression: compression_type,
         | 
| 44 | 
            -
                    consistency: consistency_level
         | 
| 45 | 
            -
                  )
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                  result
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                rescue CassandraCQL::Thrift::InvalidRequestException
         | 
| 50 | 
            -
                  message = [$!.why, bound_statement].join(' -- ')
         | 
| 51 | 
            -
                  raise CassandraCQL::Error::InvalidRequestException.new(message)
         | 
| 52 | 
            -
                end
         | 
| 53 | 
            -
              end
         | 
| 54 | 
            -
            end
         | 
| @@ -1,35 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
            require 'ciql/client/thrift'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            module Ciql::Client
         | 
| 5 | 
            -
              describe Thrift do
         | 
| 6 | 
            -
                let(:logger) { double(:debug? => true, debug: nil) }
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                subject { described_class.new(log: logger) }
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                before do
         | 
| 11 | 
            -
                  Ciql.logger = logger
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                it 'inherits from CassandraCQL::Database' do
         | 
| 15 | 
            -
                  subject.should be_kind_of CassandraCQL::Database
         | 
| 16 | 
            -
                end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                it 'defaults to two retries on connection exceptions' do
         | 
| 19 | 
            -
                  subject.instance_variable_get(:@thrift_client_options)[:retries].should eq 2
         | 
| 20 | 
            -
                end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                it 'accepts :retries as an option' do
         | 
| 23 | 
            -
                  instance = described_class.new(log: logger, retries: 5)
         | 
| 24 | 
            -
                  instance.instance_variable_get(:@thrift_client_options)[:retries].should eq 5
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                describe '#execute' do
         | 
| 28 | 
            -
                  it 'logs the query' do
         | 
| 29 | 
            -
                    subject # instantiate
         | 
| 30 | 
            -
                    logger.should_receive(:debug).with(/system.local where key = 'local' \[ONE\]/)
         | 
| 31 | 
            -
                    subject.execute('select * from system.local where key = ?', :local, :one)
         | 
| 32 | 
            -
                  end
         | 
| 33 | 
            -
                end
         | 
| 34 | 
            -
              end
         | 
| 35 | 
            -
            end
         |