sinatra-env_to_config 1.0.1 → 2.0.0
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 +8 -8
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.md +13 -3
- data/lib/sinatra/env_to_config.rb +6 -2
- data/lib/sinatra-env_to_config/version.rb +1 -1
- data/lib/sinatra-env_to_config.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmQwYmIxZGY0NTQ1NjE2YTk1NThlMTdjY2I4YWZmZDFmMmE0NmFjNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmQ4ZDhkZmM2ZTIyNGNkYWFiYzJjMTU4MzI3YzYxN2RkNDIwMDIzOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDAwMjExYzU5NTg0YzdjMTY4MzkyNzZjMWM3OTZiM2FjZDAzNjg5OWQwZWM1
|
10
|
+
ZjIzZDc3YmIxYmViODM1NDA5MDBlYjg3NGM4ODMzOTk1YTA5NGI5ZDYxZDZm
|
11
|
+
MDUxZmZlN2M1ZTcwN2UyZjEzZTUzNzEzYmY5OGFhNzJjMzNlZTY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2U4N2FiZjVhMjQyMzY2OGJmOGFkNzE4Y2JmYWY4ZjkyMGE3ZTEyYjE3N2I5
|
14
|
+
YWE2NGYxZmEyNGI0YTExZWU2MDIzYmEyNWFmY2M0YzFkMTMzMTY0ZGUwMzkz
|
15
|
+
NjI1ZjAwNGU3NTQyYzRhZmE4ZTVmNGM2MzA5ZmFmZGJlMzViNDc=
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[](http://badge.fury.io/rb/sinatra-env_to_config)
|
4
4
|
|
5
5
|
|
6
|
-
Provided
|
6
|
+
Provided method:
|
7
7
|
* `env_to_config(key1, key2, ...)`
|
8
8
|
|
9
9
|
which takes the proper values from ENV and places them in the settings.
|
@@ -39,8 +39,18 @@ end
|
|
39
39
|
and then you can use it:
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
puts settings.key1 # -> '
|
43
|
-
puts ENV['key1'] # -> '
|
42
|
+
puts settings.key1 # -> 'foo'
|
43
|
+
puts ENV['key1'] # -> 'foo'
|
44
|
+
```
|
45
|
+
|
46
|
+
You should give the same variable as in the ENV, as an argument to
|
47
|
+
the `env_to_config` function, but all variables are set in lower case:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
ENV['VaR1'] # => 'foo'
|
51
|
+
env_to_config 'VaR1'
|
52
|
+
settings.var1 # => 'foo'
|
53
|
+
settings.VaR1 # => NoMethodError
|
44
54
|
```
|
45
55
|
|
46
56
|
## Versioning
|
@@ -17,16 +17,20 @@
|
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
|
20
|
-
require
|
20
|
+
require "sinatra/base"
|
21
21
|
|
22
22
|
module Sinatra
|
23
23
|
module EnvToConfig
|
24
24
|
def env_to_config(*args)
|
25
|
-
args.each { |key| set key, find_value_for_key(key) }
|
25
|
+
args.each { |key| set standarize_key(key), find_value_for_key(key) }
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
+
def standarize_key(key)
|
31
|
+
key.to_s.downcase
|
32
|
+
end
|
33
|
+
|
30
34
|
def find_value_for_key(key)
|
31
35
|
key_string = key.to_s
|
32
36
|
ENV[key_string]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-env_to_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Szymon Kopciewski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.2.
|
103
|
+
rubygems_version: 2.2.5
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: The Sinatra extension for adding options from the env variables
|