ciql 0.3.1 → 0.3.2

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: b0c24dfc6f7e95361c405a08d552c4e88b296e79
4
- data.tar.gz: b4f6eae5dc11907751b959994858cbd663ecdca4
3
+ metadata.gz: d970154542794f5068a3eb1c3db01626c0043dac
4
+ data.tar.gz: 6fa0c48171ecbcb7eaadf406612a556ea181474d
5
5
  SHA512:
6
- metadata.gz: 371cc72b3bf7886fe99c124ab5a18be855c07e5a6867d2a5c27bea4de40de6cf13a96f0a8b51b79a8e29c760b6a0d803be6e2366c56fa0725233fcfefc9079d4
7
- data.tar.gz: 2948ca1f3c9c7e8d812aade4f5436b2e56a01559dcfd8a3a11e462458a7602cc9dd220b78705992f4589484ff6ff3d6d1c3b0abd72c6bba9b006e702fd59f422
6
+ metadata.gz: f8617949842428fab81a257d449b7e48c2cf56e5f4babc0f5b53860a8c3d0b7413fd69472f018b247eb30dad144305014a462495d5e02c37df91838806cf0957
7
+ data.tar.gz: 16e5a590c5820eba2909d849a57c87e629bbac5d7a84421aa62b41b1227f2350d48636441d1f04ac161fa5ff4e4daeb12ee6936ea941c780b5a900aad94e4ead
data/lib/ciql/sanitize.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'simple_uuid'
2
+ require 'set'
2
3
 
3
4
  module Ciql
4
5
  module Sanitize
@@ -29,10 +30,13 @@ module Ciql
29
30
  def self.cast(obj)
30
31
  case obj
31
32
  when Hash
32
- obj.map { |pair| pair.map(&method(:cast)).join(':') }.join(',')
33
+ "{#{obj.map { |pair| pair.map(&method(:cast)).join(':') }.join(',')}}"
34
+
35
+ when Set
36
+ "{#{obj.map { |member| cast(member) }.join(',')}}"
33
37
 
34
38
  when Enumerable
35
- obj.map { |member| cast(member) }.join(',')
39
+ "[#{obj.map { |member| cast(member) }.join(',')}]"
36
40
 
37
41
  when NilClass then 'NULL'
38
42
  when Numeric then obj
data/lib/ciql/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ciql
2
- VERSION = '0.3.1'.freeze
2
+ VERSION = '0.3.2'.freeze
3
3
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  module Ciql::Client
4
4
  describe Binary do
5
5
  let(:logger) do
6
- mock(:debug? => true, debug: nil, info: nil, warn: nil)
6
+ double(:debug? => true, debug: nil, info: nil, warn: nil)
7
7
  end
8
8
 
9
9
  subject { described_class.new(log: logger) }
@@ -3,7 +3,7 @@ require 'ciql/client/thrift'
3
3
 
4
4
  module Ciql::Client
5
5
  describe Thrift do
6
- let(:logger) { mock(:debug? => true, debug: nil) }
6
+ let(:logger) { double(:debug? => true, debug: nil) }
7
7
 
8
8
  subject { described_class.new(log: logger) }
9
9
 
@@ -85,19 +85,24 @@ module Ciql
85
85
  end
86
86
 
87
87
  it 'converts TrueClass instances to true, without quotes' do
88
- subject.sanitize('?', [true]).should == 'true'
88
+ subject.sanitize('?', true).should == 'true'
89
89
  end
90
90
 
91
91
  it 'converts FalseClass instances to false, without quotes' do
92
- subject.sanitize('?', [false]).should == 'false'
92
+ subject.sanitize('?', false).should == 'false'
93
93
  end
94
94
 
95
- it 'joins elements of an array with a comma separator' do
96
- subject.sanitize('?', [1,2,3]).should == '1,2,3'
95
+ it 'joins casted elements of an array with a comma separator wrapped in []' do
96
+ subject.sanitize('?', [1,true,Time.at(0).to_date])
97
+ .should == "[1,true,'1969-12-31']"
97
98
  end
98
99
 
99
- it 'joins key/value pairs of a hash with colon and comma separators' do
100
- subject.sanitize('?', {a: 1, b: 'z'}).should == "'a':1,'b':'z'"
100
+ it 'joins casted elements of a set with a comma separator wrapped in {}' do
101
+ subject.sanitize('?', [1,nil,'a'].to_set).should == "{1,NULL,'a'}"
102
+ end
103
+
104
+ it 'joins casted key/value pairs of a hash with colon and comma separators wrapped in {}' do
105
+ subject.sanitize('?', {a: 1, b: 'z'}).should == "{'a':1,'b':'z'}"
101
106
  end
102
107
  end
103
108
  end
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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Bradford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-06 00:00:00.000000000 Z
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cql-rb
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.1
19
+ version: 1.1.2
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.1
26
+ version: 1.1.2
27
27
  - !ruby/object:Gem::Dependency
28
- name: cassandra-cql
28
+ name: simple_uuid
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.1
34
- type: :development
33
+ version: 0.4.0
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2.1
40
+ version: 0.4.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: simple_uuid
42
+ name: cassandra-cql
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 0.3.0
47
+ version: 1.2.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 0.3.0
54
+ version: 1.2.1
55
55
  description: A CQL-based Cassandra client for Ruby
56
56
  email:
57
57
  - justin@nulu.com