cassandro 0.3.1 → 1.0.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 +8 -8
- data/README.md +11 -0
- data/cassandro.gemspec +1 -1
- data/lib/cassandro/core.rb +12 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
ZmZmNjQ5NjhmZTRlZjZmNWQyYmI5Y2E0MDE5ZGY2M2MyMDcxMTEzOQ==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
MzliYzM5ODRjMDBhYzI0MGM2MWM2M2IxZGMzNDNkMmM2MWJhODg4OQ==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
NDhjZGIyY2NjNzFjMDY5NjIyYmZkMTk1YmM4ZmQ5Mzk3MTNiYjU2YjMyZTNj
|
|
10
|
+
ZWVkOGQ2YzhiYWFkMWJlODZkZDNmMjllYjlkYjY5ZDEzMWUxOTQwMTIxMmUw
|
|
11
|
+
ZmI3ZDgwNTAyYjA4Yjc3NjM1Mjk4OWU2OTc5YTY0MDA4YjVmYzE=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
M2JjMTAzY2UzMGFjMmFlODA5NDk1N2I2MjQ1MzY2ZTNjYjFhMTE0MjExZWFj
|
|
14
|
+
N2M0OGQ4ZjQ3NzUwNThlMzliZWU3MmJmYTdlMDUwNTk4Yzk0NjVhOWQ3ZjZh
|
|
15
|
+
NDZlMzBlNGQ2MDM4ZTg0ODRjNWQyMTExYmVjNWQ1NzA1OGQ5MTA=
|
data/README.md
CHANGED
|
@@ -20,7 +20,18 @@ Cassandro.connect(
|
|
|
20
20
|
Creating a new keyspace. For full details of keyspace creation visit [CLI keyspace](http://www.datastax.com/documentation/cassandra/2.0/cassandra/reference/referenceStorage_r.html)
|
|
21
21
|
|
|
22
22
|
```ruby
|
|
23
|
+
# < 1.0.0
|
|
23
24
|
Cassandro.create_keyspace('new_keyspace', 'SimpleStrategy', 1)
|
|
25
|
+
|
|
26
|
+
# >= 1.0.0, allow more options
|
|
27
|
+
Cassandro.create_keyspace('new_keyspace', {
|
|
28
|
+
replication: {
|
|
29
|
+
class: 'NetworkTopologyStrategy',
|
|
30
|
+
dc_1: 2,
|
|
31
|
+
dc_2: 2
|
|
32
|
+
},
|
|
33
|
+
durable_writes: true
|
|
34
|
+
})
|
|
24
35
|
```
|
|
25
36
|
|
|
26
37
|
Select keyspace outside `#connect`
|
data/cassandro.gemspec
CHANGED
data/lib/cassandro/core.rb
CHANGED
|
@@ -36,14 +36,21 @@ module Cassandro
|
|
|
36
36
|
@@session.execute(cql_command)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
def self.create_keyspace(name,
|
|
39
|
+
def self.create_keyspace(name, options = { replication: { class: 'SimpleStrategy', replication_factor: 1}} )
|
|
40
|
+
with = "WITH " + options.map do |key, option|
|
|
41
|
+
param_string = "#{key.to_s.upcase} = " +
|
|
42
|
+
if option.is_a?(Hash)
|
|
43
|
+
"{ #{option.map { |k,v| "'#{k}': #{v.is_a?(String) ? "'#{v}'": v.to_s}" }.join(", ")} }"
|
|
44
|
+
else
|
|
45
|
+
option.is_a?(String) ? "'#{option}'": option.to_s
|
|
46
|
+
end
|
|
47
|
+
end.join(" AND ")
|
|
48
|
+
|
|
40
49
|
keyspace_definition = <<-KSDEF
|
|
41
50
|
CREATE KEYSPACE IF NOT EXISTS #{name}
|
|
42
|
-
|
|
43
|
-
'class': '#{strategy}',
|
|
44
|
-
'replication_factor': #{replication_factor}
|
|
45
|
-
}
|
|
51
|
+
#{with}
|
|
46
52
|
KSDEF
|
|
53
|
+
|
|
47
54
|
@@session.execute(keyspace_definition)
|
|
48
55
|
end
|
|
49
56
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cassandro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lautaro Orazi
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-12-
|
|
12
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: cassandra-driver
|