quandl_logger 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/quandl/configuration.rb +14 -6
- data/lib/quandl/logger/version.rb +1 -1
- metadata +2 -2
data/lib/quandl/configuration.rb
CHANGED
@@ -4,6 +4,13 @@ module Quandl
|
|
4
4
|
class Configuration
|
5
5
|
class << self
|
6
6
|
|
7
|
+
attr_accessor :config_file, :config_env
|
8
|
+
|
9
|
+
def from_file(file, env)
|
10
|
+
self.config_file = file
|
11
|
+
self.config_env = env
|
12
|
+
end
|
13
|
+
|
7
14
|
def configures(*names)
|
8
15
|
define_attributes(*names)
|
9
16
|
end
|
@@ -33,16 +40,17 @@ class Configuration
|
|
33
40
|
|
34
41
|
end
|
35
42
|
|
36
|
-
def from_file(path, env)
|
37
|
-
config = YAML.load_file( path )[ env ]
|
38
|
-
config.each{|k,v| self.send("#{k}=",v) if respond_to?("#{k}=") }
|
39
|
-
end
|
40
|
-
|
41
43
|
def initialize(*args)
|
42
44
|
attrs = args.extract_options!
|
43
45
|
self.attributes
|
44
|
-
# assign attributes
|
45
46
|
self.assign_attributes(attrs)
|
47
|
+
from_file(self.class.config_file, self.class.config_env) if self.class.config_file.present? && self.class.config_env.present?
|
48
|
+
end
|
49
|
+
|
50
|
+
def from_file(path, env)
|
51
|
+
config = YAML.load_file( path )[ env ]
|
52
|
+
raise ArgumentError, "Unknown env #{env}" if config.nil?
|
53
|
+
config.each{|k,v| self.send("#{k}=",v) if respond_to?("#{k}=") }
|
46
54
|
end
|
47
55
|
|
48
56
|
def assign_attributes(hash)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quandl_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
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: 2014-
|
12
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|