zenv 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.zenv +8 -0
- data/CHANGELOG.md +6 -0
- data/README.md +38 -4
- data/lib/zenv/version.rb +1 -1
- data/lib/zenv.rb +30 -27
- data/zenv.gemspec +3 -2
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1df55652a6508cc08bf94d84a0387c6299db04d
|
4
|
+
data.tar.gz: 96ae5137953732b39513021bd14f4278ac5831ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 044b22587347c9225a75b645337201f162676400f69bce4d5198f00020f1970f7eb6a1bad77587193901f2773a43f46ab59ecb765d58b711a74c0c393227765d
|
7
|
+
data.tar.gz: 7b6907ad555619e21768bef2f948f91c576412d59ab61c0ac73f105024f1e0e20fa0ffd7c6a2585242a43b2a93a48dafc2c5471f3c6cc260ee82a0b7c28dd831
|
data/.rspec
ADDED
data/.zenv
ADDED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# ZEN ENV
|
2
2
|
|
3
|
-
Simple and flexible approach to loading
|
3
|
+
Simple and flexible approach to loading environment variables.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,7 +20,41 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
Create a '.zenv' file at the root of your project:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
{
|
27
|
+
default: {
|
28
|
+
KEY: 'value',
|
29
|
+
...
|
30
|
+
},
|
31
|
+
}
|
32
|
+
```
|
33
|
+
|
34
|
+
The `:default` namespace will be loaded into `ENV`.
|
35
|
+
|
36
|
+
### Namespaces
|
37
|
+
|
38
|
+
To load a different set of environment variables, add another "namespace":
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
{
|
42
|
+
default: {
|
43
|
+
KEY: 'value',
|
44
|
+
...
|
45
|
+
},
|
46
|
+
other: {
|
47
|
+
KEY: 'other value',
|
48
|
+
...
|
49
|
+
}
|
50
|
+
}
|
51
|
+
```
|
52
|
+
|
53
|
+
Specify the namespace in `ZENV`. E.g. `ZENV=other rails console`.
|
54
|
+
|
55
|
+
### Pre-loading
|
56
|
+
|
57
|
+
If environment variables need to be loaded _before_ your application is loaded, run the command with `zenv`. For example, if you're running the puma web server and it depends on `PORT`, run `zenv puma`.
|
24
58
|
|
25
59
|
## Development
|
26
60
|
|
@@ -30,4 +64,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
30
64
|
|
31
65
|
## Contributing
|
32
66
|
|
33
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
67
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/austinthecoder/zenv.
|
data/lib/zenv/version.rb
CHANGED
data/lib/zenv.rb
CHANGED
@@ -1,41 +1,44 @@
|
|
1
|
+
require 'pathname'
|
1
2
|
require "zenv/version"
|
2
3
|
|
3
4
|
module Zenv
|
4
|
-
|
5
|
-
namespace = ENV['ZENV']&.to_sym || :default
|
5
|
+
@pathname = Pathname.new '.zenv'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
7
|
+
class << self
|
8
|
+
attr_writer :pathname
|
10
9
|
|
11
|
-
|
10
|
+
private
|
12
11
|
|
13
|
-
|
14
|
-
warn "[Zenv] .zenv file not found"
|
15
|
-
return
|
16
|
-
end
|
12
|
+
attr_reader :pathname, :namespace_loaded
|
17
13
|
|
18
|
-
|
19
|
-
|
20
|
-
ruby_code = File.read filepath
|
21
|
-
eval ruby_code
|
22
|
-
end
|
14
|
+
def load
|
15
|
+
namespace = ENV['ZENV']&.to_sym || :default
|
23
16
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
17
|
+
if namespace_loaded
|
18
|
+
warn "[Zenv] skipping #{namespace.inspect}, already loaded #{namespace_loaded.inspect}"
|
19
|
+
end
|
28
20
|
|
29
|
-
|
30
|
-
|
31
|
-
|
21
|
+
unless pathname.exist?
|
22
|
+
warn "[Zenv] .zenv file not found"
|
23
|
+
return
|
24
|
+
end
|
32
25
|
|
33
|
-
|
26
|
+
data = eval pathname.read
|
34
27
|
|
35
|
-
|
28
|
+
unless data.key? namespace
|
29
|
+
warn "[Zenv] missing #{namespace.inspect} in .zenv"
|
30
|
+
return
|
31
|
+
end
|
36
32
|
|
37
|
-
|
33
|
+
data[namespace].each do |key, value|
|
34
|
+
ENV[key.to_s] = value
|
35
|
+
end
|
36
|
+
|
37
|
+
namespace_loaded = namespace
|
38
|
+
|
39
|
+
puts "[Zenv] loaded #{namespace_loaded.inspect}"
|
40
|
+
end
|
38
41
|
end
|
39
|
-
end
|
40
42
|
|
41
|
-
|
43
|
+
load
|
44
|
+
end
|
data/zenv.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["me@austinschneider.com"]
|
11
11
|
|
12
12
|
spec.summary = 'Zen Env'
|
13
|
-
spec.description = 'Simple and flexible approach to loading
|
14
|
-
spec.homepage = ''
|
13
|
+
spec.description = 'Simple and flexible approach to loading environment variables.'
|
14
|
+
spec.homepage = 'https://github.com/austinthecoder/zenv'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
17
|
spec.bindir = "exe"
|
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.11"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
23
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Schneider
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,7 +38,21 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
55
|
+
description: Simple and flexible approach to loading environment variables.
|
42
56
|
email:
|
43
57
|
- me@austinschneider.com
|
44
58
|
executables:
|
@@ -47,6 +61,9 @@ extensions: []
|
|
47
61
|
extra_rdoc_files: []
|
48
62
|
files:
|
49
63
|
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".zenv"
|
66
|
+
- CHANGELOG.md
|
50
67
|
- Gemfile
|
51
68
|
- README.md
|
52
69
|
- Rakefile
|
@@ -56,7 +73,7 @@ files:
|
|
56
73
|
- lib/zenv.rb
|
57
74
|
- lib/zenv/version.rb
|
58
75
|
- zenv.gemspec
|
59
|
-
homepage:
|
76
|
+
homepage: https://github.com/austinthecoder/zenv
|
60
77
|
licenses: []
|
61
78
|
metadata: {}
|
62
79
|
post_install_message:
|