blended_config 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/blended_config.rb +4 -4
- data/lib/blended_config/option_resolver.rb +5 -5
- data/lib/blended_config/sources/file.rb +3 -3
- data/lib/blended_config/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5afd28f957fd1e922ebf10050cb8949103fd2249
|
4
|
+
data.tar.gz: 1c6ba946edc93e65ae40fa07c5388600d9cf77e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e338cebd07243835f92a6f69222a7ffe84de6f13cf2f1c358a91d6d3f8a4c94d0b7c7f7c4ce020e2cfe6d9af5105042684ffb1acca60006b29f186367ce0869
|
7
|
+
data.tar.gz: 1ae3b653d1f991aabcb6a7d89d0af6e937ba06a67412a54e896b27a21001f4a825d388a61917b5e99f60c3e90d0fc10ac81338fbc913fe9463193bf2b80a55f5
|
data/README.md
CHANGED
@@ -14,11 +14,11 @@ but you want only some environment variables to override these. Tell us your dec
|
|
14
14
|
```ruby
|
15
15
|
class ColorsConfig < BlendedConfig
|
16
16
|
group(:colors) do
|
17
|
-
option(:blue) { env || file }
|
18
|
-
option(:green) { file || env }
|
19
|
-
option(:red) { env || 'brick' }
|
20
|
-
|
21
|
-
option(:yellow) { env || file || 'marigold' } # try everything
|
17
|
+
option(:blue) { env || file } # pretty standard
|
18
|
+
option(:green) { file || env } # the reverse
|
19
|
+
option(:red) { env || 'brick' } # never read from file, but have a default
|
20
|
+
option(:purple) { file || 'plum' } # only read from the file, with a default
|
21
|
+
option(:yellow) { env || file || 'marigold' } # try everything
|
22
22
|
end
|
23
23
|
end
|
24
24
|
```
|
data/lib/blended_config.rb
CHANGED
@@ -27,15 +27,15 @@ class BlendedConfig
|
|
27
27
|
@option_resolvers ||= []
|
28
28
|
end
|
29
29
|
|
30
|
-
def initialize(
|
31
|
-
bind_config_file(
|
30
|
+
def initialize(env: ENV, **options)
|
31
|
+
bind_config_file(options)
|
32
32
|
bind_environment(env)
|
33
33
|
end
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
|
-
def bind_config_file(
|
38
|
-
source = Sources::File.new(
|
37
|
+
def bind_config_file(options)
|
38
|
+
source = Sources::File.new(options)
|
39
39
|
|
40
40
|
bind_source(:file, source)
|
41
41
|
end
|
@@ -2,14 +2,14 @@ require 'blended_config/sources/environment'
|
|
2
2
|
|
3
3
|
class BlendedConfig
|
4
4
|
class OptionResolver
|
5
|
-
def initialize(name, &
|
6
|
-
@name
|
7
|
-
@
|
8
|
-
@sources
|
5
|
+
def initialize(name, &resolution)
|
6
|
+
@name = name
|
7
|
+
@resolution = resolution
|
8
|
+
@sources = {}
|
9
9
|
end
|
10
10
|
|
11
11
|
def value
|
12
|
-
instance_exec(&@
|
12
|
+
instance_exec(&@resolution)
|
13
13
|
end
|
14
14
|
|
15
15
|
def file
|
@@ -3,9 +3,9 @@ require 'blended_config/sources/toml_source'
|
|
3
3
|
class BlendedConfig
|
4
4
|
module Sources
|
5
5
|
class File
|
6
|
-
def self.new(
|
7
|
-
path = Pathname.new(
|
8
|
-
extension =
|
6
|
+
def self.new(options)
|
7
|
+
path = Pathname.new(options[:toml])
|
8
|
+
extension = :toml
|
9
9
|
|
10
10
|
send(extension, path)
|
11
11
|
end
|