blended_config 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +35 -4
- data/lib/blended_config/sources/toml_source.rb +0 -6
- data/lib/blended_config/version.rb +1 -1
- data/lib/blended_config.rb +5 -5
- metadata +2 -5
- data/lib/blended_config/sources/#toml_source.rb# +0 -13
- data/lib/blended_config/sources/.#toml_source.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c89c46d63f7d25ad9e39c5f47b043d6874f57317
|
4
|
+
data.tar.gz: 47a0d52f431b747d1b9e1ba4c6553b77d8ab8f5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa60a949062417e65cb83332301f7c25ef5f797761447058f92bd1ad59f0454071c9db2041ebc6b44064654a0da7bddea8a16145f9292bc022e0e024e167c385
|
7
|
+
data.tar.gz: e22293931c88f4ce655226c51dc0c165c9a857de427da34dda332e573d2978275418f3db955422d642f21beecc711047bc509561be14a79caa063ad7c18d45de
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,39 @@
|
|
1
1
|
# BlendedConfig
|
2
2
|
|
3
|
-
|
3
|
+
BlendedConfig gives you a simple dsl for indicating resolution order between the contents of config files, environment variables and default values. Say you've got this beautiful config file:
|
4
|
+
```toml
|
5
|
+
[colors]
|
6
|
+
blue = "indigo"
|
7
|
+
green = "lime"
|
8
|
+
red = "maroon"
|
9
|
+
purple = "aubergine"
|
10
|
+
yellow = "mustard"
|
11
|
+
```
|
12
|
+
|
13
|
+
but you want only some environment variables to override these. Tell us your decisions like so:
|
14
|
+
```ruby
|
15
|
+
class ColorsConfig < BlendedConfig
|
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
|
22
|
+
end
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
You can now run your program with environment variables:
|
27
|
+
|
28
|
+
$ COLORS_BLUE=cobalt COLORS_YELLOW=butterscotch spec/support/print-colors
|
29
|
+
cobalt
|
30
|
+
lime
|
31
|
+
brick
|
32
|
+
aubergine
|
33
|
+
butterscotch
|
34
|
+
|
35
|
+
And it resolves your configuration correctly!
|
4
36
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
37
|
|
7
38
|
## Installation
|
8
39
|
|
@@ -26,13 +57,13 @@ TODO: Write usage instructions here
|
|
26
57
|
|
27
58
|
## Development
|
28
59
|
|
29
|
-
After checking out the repo, run `
|
60
|
+
After checking out the repo, run `bundle install` to install its dependencies. Then, run `bundle exec spec` to run the tests.
|
30
61
|
|
31
62
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
63
|
|
33
64
|
## Contributing
|
34
65
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yarmiganosca/blended_config. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
67
|
|
37
68
|
|
38
69
|
## License
|
data/lib/blended_config.rb
CHANGED
@@ -13,18 +13,18 @@ class BlendedConfig
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.option(name, &resolution)
|
16
|
-
|
17
|
-
|
16
|
+
option_resolver = OptionResolver.new(name, &resolution)
|
17
|
+
option_resolvers << option_resolver
|
18
18
|
|
19
|
-
define_method(name) {
|
19
|
+
define_method(name) { option_resolver }
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.option_groups
|
23
23
|
@option_groups ||= []
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.
|
27
|
-
@
|
26
|
+
def self.option_resolvers
|
27
|
+
@option_resolvers ||= []
|
28
28
|
end
|
29
29
|
|
30
30
|
def initialize(file: nil, env: ENV)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blended_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hoffman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: toml
|
@@ -89,8 +89,6 @@ files:
|
|
89
89
|
- lib/blended_config/option_group.rb
|
90
90
|
- lib/blended_config/option_resolver.rb
|
91
91
|
- lib/blended_config/source.rb
|
92
|
-
- lib/blended_config/sources/#toml_source.rb#
|
93
|
-
- lib/blended_config/sources/.#toml_source.rb
|
94
92
|
- lib/blended_config/sources/environment.rb
|
95
93
|
- lib/blended_config/sources/file.rb
|
96
94
|
- lib/blended_config/sources/toml_source.rb
|
@@ -120,4 +118,3 @@ signing_key:
|
|
120
118
|
specification_version: 4
|
121
119
|
summary: Decide how your config objects choose between files, env_vars & default values.
|
122
120
|
test_files: []
|
123
|
-
has_rdoc:
|
@@ -1 +0,0 @@
|
|
1
|
-
yarmiganosca@bladelike.4274:1453821888
|