mutaconf 0.0.5 → 0.0.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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/mutaconf.rb +12 -1
- data/mutaconf.gemspec +2 -1
- data/spec/env_spec.rb +23 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ab4d7e17675c6ca67a288015785c3960d8f1cdf
|
4
|
+
data.tar.gz: 0559bfe85a294fd62db3dc91f740cb382ca1953a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adfac344fe43f78bb06228ed393b60f4f82218a3ebe2b6b7897eefa9ee4ab6281abdc0b9cf95d1c4e6a5b7c75f99915882f627d083c03b0793c3ab11c16425c7
|
7
|
+
data.tar.gz: 92dde7af0a4bb33b6852b20e56362cbf8a768d8c39a7d76ccf6c8d8cbc233f33408b69bdcc89397c31742457993854f1895c6d435518b7bea9f15bd42394bab7
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/mutaconf.rb
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Mutaconf
|
4
|
-
VERSION = '0.0.
|
4
|
+
VERSION = '0.0.6'
|
5
5
|
|
6
6
|
def self.dsl *args
|
7
7
|
DSL.new *args
|
8
8
|
end
|
9
9
|
|
10
|
+
def self.env *args
|
11
|
+
options = args.last.kind_of?(Hash) ? args.pop : {}
|
12
|
+
args.inject({}) do |memo,key|
|
13
|
+
env_key = options[:upcase] == false ? key.to_s : key.to_s.upcase
|
14
|
+
prefix = options[:prefix]
|
15
|
+
prefix = prefix.upcase if prefix and options[:upcase] != false
|
16
|
+
memo[key.to_sym] = ENV["#{prefix}#{env_key}"]
|
17
|
+
memo
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
10
21
|
def self.extract source, key
|
11
22
|
if source.kind_of? Hash
|
12
23
|
source[key.to_sym]
|
data/mutaconf.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "mutaconf"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["AlphaHydrae"]
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/mutaconf/target.rb",
|
34
34
|
"mutaconf.gemspec",
|
35
35
|
"spec/block_spec.rb",
|
36
|
+
"spec/env_spec.rb",
|
36
37
|
"spec/extract_spec.rb",
|
37
38
|
"spec/fixtures/eval.rb",
|
38
39
|
"spec/helper.rb",
|
data/spec/env_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe "Mutaconf.env" do
|
4
|
+
|
5
|
+
it "should extract properties from environment variables" do
|
6
|
+
ENV['FOO'] = 'bar'
|
7
|
+
ENV['BAR'] = 'foo'
|
8
|
+
ENV.delete 'NIL'
|
9
|
+
Mutaconf.env(:foo, :bar, :nil).should == { foo: 'bar', bar: 'foo', nil: nil }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should not upcase keys if specified" do
|
13
|
+
ENV['foo'] = 'bar'
|
14
|
+
ENV['bar'] = 'foo'
|
15
|
+
Mutaconf.env(:foo, :bar, upcase: false).should == { foo: 'bar', bar: 'foo' }
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should use the given prefix" do
|
19
|
+
ENV['MUTACONF_FOO'] = 'bar'
|
20
|
+
ENV['MUTACONF_BAR'] = 'foo'
|
21
|
+
Mutaconf.env(:foo, :bar, prefix: :mutaconf_).should == { foo: 'bar', bar: 'foo' }
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mutaconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AlphaHydrae
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/mutaconf/target.rb
|
147
147
|
- mutaconf.gemspec
|
148
148
|
- spec/block_spec.rb
|
149
|
+
- spec/env_spec.rb
|
149
150
|
- spec/extract_spec.rb
|
150
151
|
- spec/fixtures/eval.rb
|
151
152
|
- spec/helper.rb
|