believer 0.2.16 → 0.2.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,9 +20,16 @@ module Believer
20
20
  }
21
21
 
22
22
  # Creates a new environment using the provided configuration
23
- # @param config [Hash] the configuration
23
+ # @param config [Object] the configuration. If it's a hash use it as the configuration. If it's a String, assume
24
+ # it's a YAML file and load it as a Hash
24
25
  def initialize(config = nil)
25
- @configuration = config.dup unless config.nil?
26
+ unless config.nil?
27
+ if config.is_a?(Hash)
28
+ @configuration = config.dup
29
+ elsif config.is_a?(String)
30
+ @configuration = load_config_from_file(config)
31
+ end
32
+ end
26
33
  end
27
34
 
28
35
  def logger
@@ -83,6 +90,14 @@ module Believer
83
90
  connection
84
91
  end
85
92
 
93
+ protected
94
+ def load_config_from_file(config_file)
95
+ return nil if config_file.nil?
96
+ cfg = HashWithIndifferentAccess.new(YAML::load(File.open(config_file.to_s)))
97
+ puts "Loaded config from file #{config_file.to_s}: #{cfg}"
98
+ cfg
99
+ end
100
+
86
101
  end
87
102
 
88
103
  end
@@ -9,7 +9,7 @@ module Believer
9
9
 
10
10
  def load_configuration
11
11
  config_file = File.join(Merb.root, 'config', 'believer.yml')
12
- config = HashWithIndifferentAccess.new(YAML::load(File.open(config_file.to_s)))
12
+ config = load_config_from_file(config_file)
13
13
  env_config = config[Merb.environment]
14
14
  env_config
15
15
  end
@@ -9,7 +9,7 @@ module Believer
9
9
 
10
10
  def load_configuration
11
11
  config_file = File.join(Rails.root, 'config', 'believer.yml')
12
- config = HashWithIndifferentAccess.new(YAML::load(File.open(config_file.to_s)))
12
+ config = load_config_from_file(config_file)
13
13
  env_config = config[Rails.env]
14
14
  env_config
15
15
  end
@@ -22,7 +22,9 @@ module Believer
22
22
  keyspace.create({})
23
23
  connection.use(env.connection_configuration[:keyspace])
24
24
 
25
- classes = options[:classes]
25
+ ::Believer::Base.environment = env
26
+
27
+ classes = options[:classes]
26
28
  classes.each do |cl|
27
29
  if cl.is_a?(String)
28
30
  clazz = cl.split('::').inject(Kernel) { |scope, const_name| scope.const_get(const_name) }
@@ -1,5 +1,5 @@
1
1
  module Believer
2
2
  module Version
3
- VERSION = '0.2.16'
3
+ VERSION = '0.2.17'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: believer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.2.17
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-11-15 00:00:00.000000000 Z
12
+ date: 2013-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel