cassandro 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTFjNGIyNDZkNTk5MzJkMGMwOTA3NTBkZDlmYjlmMWY4M2Q0OGEzYQ==
4
+ ZmZmNjQ5NjhmZTRlZjZmNWQyYmI5Y2E0MDE5ZGY2M2MyMDcxMTEzOQ==
5
5
  data.tar.gz: !binary |-
6
- OWNhMmRlZDViODY3YmMzOGUwYWE1NDhhODA4YTIwYmFlYTVmNjliNw==
6
+ MzliYzM5ODRjMDBhYzI0MGM2MWM2M2IxZGMzNDNkMmM2MWJhODg4OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTM0NjA5YTMzZmM4MmVlNjMzMTNiODU5MDc5OWJjZTIwMjk3ZTJmODA4ZmUz
10
- NDBlNTQ1MWRmZTA4OGI0ODY3MTNmYzQ4YmNlM2UwOGZjMjEyNzc3MzI0MTQy
11
- OWQ1NzA1ODcxZDI3OWE3ZjYzOGQ0NGFjMjhjNWVmMjBiY2MzNWU=
9
+ NDhjZGIyY2NjNzFjMDY5NjIyYmZkMTk1YmM4ZmQ5Mzk3MTNiYjU2YjMyZTNj
10
+ ZWVkOGQ2YzhiYWFkMWJlODZkZDNmMjllYjlkYjY5ZDEzMWUxOTQwMTIxMmUw
11
+ ZmI3ZDgwNTAyYjA4Yjc3NjM1Mjk4OWU2OTc5YTY0MDA4YjVmYzE=
12
12
  data.tar.gz: !binary |-
13
- ZjIxNzI0NmExMDkxMWMzMjc5YWJmYTljMmQxNWUwNGE2ZTkyZDhlMDg2NDI2
14
- ZGYxNzdmOTk1OWQwZTZkOTk3YWJjNTg3MjBmNGM5ZDc5OWJlYzY3YjlmNDhl
15
- ZDI2MGY0OGMxMTIwMjgxYWZkNTI0Y2Y4YTNkM2QwZGJmMTY4MmY=
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "cassandro"
5
- s.version = "0.3.1"
5
+ s.version = "1.0.0"
6
6
  s.summary = "Ruby ORM for Apache Cassandra"
7
7
  s.license = "MIT"
8
8
  s.description = "Lightweight Apache Cassandra ORM for Ruby"
@@ -36,14 +36,21 @@ module Cassandro
36
36
  @@session.execute(cql_command)
37
37
  end
38
38
 
39
- def self.create_keyspace(name, strategy = 'SimpleStrategy', replication_factor = 1)
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
- WITH replication = {
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.3.1
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-02 00:00:00.000000000 Z
12
+ date: 2014-12-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cassandra-driver