blended_config 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c89c46d63f7d25ad9e39c5f47b043d6874f57317
4
- data.tar.gz: 47a0d52f431b747d1b9e1ba4c6553b77d8ab8f5b
3
+ metadata.gz: 5afd28f957fd1e922ebf10050cb8949103fd2249
4
+ data.tar.gz: 1c6ba946edc93e65ae40fa07c5388600d9cf77e1
5
5
  SHA512:
6
- metadata.gz: fa60a949062417e65cb83332301f7c25ef5f797761447058f92bd1ad59f0454071c9db2041ebc6b44064654a0da7bddea8a16145f9292bc022e0e024e167c385
7
- data.tar.gz: e22293931c88f4ce655226c51dc0c165c9a857de427da34dda332e573d2978275418f3db955422d642f21beecc711047bc509561be14a79caa063ad7c18d45de
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 } # pretty standard
18
- option(:green) { file || env } # the reverse
19
- option(:red) { env || 'brick' } # never read from env vars, but have a default
20
- optino(:purple) { file || 'plum' } # only read from the environment, with a default
21
- option(:yellow) { env || file || 'marigold' } # try everything first
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
  ```
@@ -27,15 +27,15 @@ class BlendedConfig
27
27
  @option_resolvers ||= []
28
28
  end
29
29
 
30
- def initialize(file: nil, env: ENV)
31
- bind_config_file(file) if 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(path)
38
- source = Sources::File.new(path)
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, &lookup_preference)
6
- @name = name
7
- @lookup_preference = lookup_preference
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(&@lookup_preference)
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(path)
7
- path = Pathname.new(path)
8
- extension = path.extname[1..-1]
6
+ def self.new(options)
7
+ path = Pathname.new(options[:toml])
8
+ extension = :toml
9
9
 
10
10
  send(extension, path)
11
11
  end
@@ -1,3 +1,3 @@
1
1
  class BlendedConfig
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blended_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hoffman