confuse 0.1.5 → 0.1.6
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.
- data/lib/confuse/config.rb +1 -4
- data/lib/confuse/version.rb +1 -1
- data/test/test_config_base.rb +16 -13
- metadata +3 -3
data/lib/confuse/config.rb
CHANGED
@@ -19,15 +19,12 @@ module Confuse
|
|
19
19
|
def initialize(options = {})
|
20
20
|
load_namespaces(self.class.namespaces.clone)
|
21
21
|
paths = options[:paths] || []
|
22
|
-
load_defaults = begin
|
23
|
-
d = options[:load_defaults]
|
24
|
-
d.nil? ? true : d
|
25
|
-
end
|
26
22
|
if paths.flatten.empty?
|
27
23
|
read_files(self.class.config_path.flatten)
|
28
24
|
else
|
29
25
|
read_files(paths.flatten)
|
30
26
|
end
|
27
|
+
options[:conf].tap { |conf| conf && mixin_config!(conf) }
|
31
28
|
end
|
32
29
|
|
33
30
|
def config
|
data/lib/confuse/version.rb
CHANGED
data/test/test_config_base.rb
CHANGED
@@ -10,19 +10,6 @@ class Foo < Confuse::ConfigBase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
class TestConfigBase < MiniTest::Unit::TestCase
|
13
|
-
def test_two_instances_can_exist_with_different_values
|
14
|
-
# instatiate two versions of the config
|
15
|
-
config1 = Foo.new
|
16
|
-
config2 = Foo.new
|
17
|
-
|
18
|
-
# change the values of one of them
|
19
|
-
config1[:foo] = 'bar'
|
20
|
-
|
21
|
-
# assert only one has changed
|
22
|
-
assert_equal 'bar', config1[:foo]
|
23
|
-
assert_equal 'foo', config2[:foo]
|
24
|
-
end
|
25
|
-
|
26
13
|
# This is easier to test with an instance of a config object, rather than as
|
27
14
|
# part of the test for the module where other tests can modify the model.
|
28
15
|
def test_params_hash
|
@@ -30,5 +17,21 @@ class TestConfigBase < MiniTest::Unit::TestCase
|
|
30
17
|
:default => 'foo' } },
|
31
18
|
Foo.new.params_hash)
|
32
19
|
end
|
20
|
+
|
21
|
+
def test_can_specify_config_options_on_initialize
|
22
|
+
config = Foo.new(:conf => { :foo => 'bar' })
|
23
|
+
|
24
|
+
assert_equal 'bar', config[:foo]
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_two_instances_can_exist_with_different_values
|
28
|
+
# instatiate two versions of the config
|
29
|
+
config1 = Foo.new
|
30
|
+
config2 = Foo.new(:conf => { :foo => 'bar' })
|
31
|
+
|
32
|
+
# assert config1 and config2 are different
|
33
|
+
assert_equal 'foo', config1[:foo]
|
34
|
+
assert_equal 'bar', config2[:foo]
|
35
|
+
end
|
33
36
|
end
|
34
37
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confuse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tom Chipchase
|