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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d122903d51b0e3c4a5964c9055d9a111760a1b37
4
- data.tar.gz: d8a340b6cb76bc625522e4fa80b91f6fa6e84a92
3
+ metadata.gz: c89c46d63f7d25ad9e39c5f47b043d6874f57317
4
+ data.tar.gz: 47a0d52f431b747d1b9e1ba4c6553b77d8ab8f5b
5
5
  SHA512:
6
- metadata.gz: 7e438035b69aeef307dd7460021b1cc132b8d442c80658bf1e3ca670789d47bbaccc3c731ed61a253da52e9c0c5029a74171fe65eff3d8a0256acd031b279f38
7
- data.tar.gz: 33e8062af7e3d959dcf9e8ffa725ff63f74eaf856c7277878e0c5cd9d9236a90abdf12750ce18cc0c4f6a44806747aadc187e89a3a275d849833e6670c294677
6
+ metadata.gz: fa60a949062417e65cb83332301f7c25ef5f797761447058f92bd1ad59f0454071c9db2041ebc6b44064654a0da7bddea8a16145f9292bc022e0e024e167c385
7
+ data.tar.gz: e22293931c88f4ce655226c51dc0c165c9a857de427da34dda332e573d2978275418f3db955422d642f21beecc711047bc509561be14a79caa063ad7c18d45de
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /spec/examples.txt
11
+ /blended_config-*.gem
data/README.md CHANGED
@@ -1,8 +1,39 @@
1
1
  # BlendedConfig
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/blended_config`. To experiment with that code, run `bin/console` for an interactive prompt.
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 `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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/[USERNAME]/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.
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
@@ -8,12 +8,6 @@ class BlendedConfig
8
8
  super(TOML.load_file(path))
9
9
  end
10
10
  alias toml raw_source
11
-
12
- def [](key)
13
- (prefixes + [key]).reduce(toml) do |value, key_fragment|
14
- value[key_fragment.to_s]
15
- end
16
- end
17
11
  end
18
12
  end
19
13
  end
@@ -1,3 +1,3 @@
1
1
  class BlendedConfig
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -13,18 +13,18 @@ class BlendedConfig
13
13
  end
14
14
 
15
15
  def self.option(name, &resolution)
16
- resolver = OptionResolver.new(name, &resolution)
17
- resolvers << resolver
16
+ option_resolver = OptionResolver.new(name, &resolution)
17
+ option_resolvers << option_resolver
18
18
 
19
- define_method(name) { resolver }
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.resolvers
27
- @resolvers ||= []
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.1.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-17 00:00:00.000000000 Z
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,13 +0,0 @@
1
- require 'blended_config/source'
2
- require 'toml'
3
-
4
- class BlendedConfig
5
- module Sources
6
- class TomlSource < Source
7
- def initialize(path)
8
- super(TOML.load_file(path))
9
- end
10
- alias toml raw_source
11
- end
12
- end
13
- end
@@ -1 +0,0 @@
1
- yarmiganosca@bladelike.4274:1453821888