cassandra_migrations 0.0.3 → 0.0.4

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.
@@ -73,6 +73,8 @@ module CassandraMigrations
73
73
  "'#{value.strftime('%Y-%m-%d %H:%M:%S%z')}'"
74
74
  elsif value.is_a?(String)
75
75
  "'#{value}'"
76
+ elsif value.is_a?(Hash)
77
+ "{ #{value.reduce([]) {|sum, (key, value)| sum << "'#{key}': '#{value}'" }.join(", ") } }"
76
78
  else
77
79
  value.to_s
78
80
  end
@@ -51,6 +51,7 @@ module CassandraMigrations
51
51
 
52
52
  def self.execute(cql)
53
53
  connect_to_server unless client
54
+ Rails.logger.try(:info, "\e[1;35m [Cassandra Migrations] \e[0m #{cql.to_s}")
54
55
  result = client.execute(cql)
55
56
  QueryResult.new(result) if result
56
57
  end
@@ -14,7 +14,7 @@ module CassandraMigrations
14
14
 
15
15
  def self.load_config
16
16
  begin
17
- self.config = YAML.load_file(Rails.root.join("config", "cassandra.yml"))[Rails.env]
17
+ self.config = YAML.load(ERB.new(File.new(Rails.root.join("config", "cassandra.yml")).read).result)[Rails.env]
18
18
 
19
19
  if config.nil?
20
20
  raise Errors::MissingConfigurationError, "No configuration for #{Rails.env} environment! Complete your config/cassandra.yml."
@@ -32,5 +32,17 @@ describe CassandraMigrations::Config do
32
32
  CassandraMigrations::Config.keyspace
33
33
  }.to raise_exception CassandraMigrations::Errors::MissingConfigurationError
34
34
  end
35
+
36
+ it 'should allow ERB in the config file' do
37
+ Rails.stub(:root).and_return Pathname.new("spec/fixtures/with_erb")
38
+ Rails.stub(:env).and_return ActiveSupport::StringInquirer.new("test")
39
+
40
+ CassandraMigrations::Config.keyspace.should == 'cassandra_migrations_test'
41
+
42
+ CassandraMigrations::Config.config = nil
43
+ ENV.stub(:[]).with("CI").and_return("true")
44
+
45
+ CassandraMigrations::Config.keyspace.should == 'cassandra_migrations_ci'
46
+ end
35
47
  end
36
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassandra_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-21 00:00:00.000000000 Z
12
+ date: 2013-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cql-rb