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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 438dd1e82c02275c21e289e689ee308e869f07fe
4
- data.tar.gz: 98388f6bc62fae19cca7b588c6a7cf4ed7cbdad1
3
+ metadata.gz: b1df55652a6508cc08bf94d84a0387c6299db04d
4
+ data.tar.gz: 96ae5137953732b39513021bd14f4278ac5831ce
5
5
  SHA512:
6
- metadata.gz: 066e17b3fde5ac7abcceb5f13a39230851c1f9737a372d9629fed2dbaf77bbba61366b3db594b5a5f07ace0266851504696c0e6ae5f942582ba39d268c1dde75
7
- data.tar.gz: a1f33259b1697d7b370eb15947063f892b9054b125b79d6e6d0e67aa5f10ff0f59da08cc22c5563b78155a27e5ebe48f805c0c5227e9407deb417d53ef177571
6
+ metadata.gz: 044b22587347c9225a75b645337201f162676400f69bce4d5198f00020f1970f7eb6a1bad77587193901f2773a43f46ab59ecb765d58b711a74c0c393227765d
7
+ data.tar.gz: 7b6907ad555619e21768bef2f948f91c576412d59ab61c0ac73f105024f1e0e20fa0ffd7c6a2585242a43b2a93a48dafc2c5471f3c6cc260ee82a0b7c28dd831
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.zenv ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ default: {
3
+ KEY: 'default value'
4
+ },
5
+ other: {
6
+ KEY: 'other value'
7
+ }
8
+ }
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 1.0.0 (2016-06-06)
2
+
3
+ * Removed `Zenv.load` as a public method.
4
+ * Added basic specs. Run with `rspec`.
5
+ * Updated some docs to `README.md`.
6
+ * Added `CHANGELOG.md`.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Zenv
1
+ # ZEN ENV
2
2
 
3
- Simple and flexible approach to loading env vars
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
- Coming soon.
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/[USERNAME]/zenv.
67
+ Bug reports and pull requests are welcome on GitHub at https://github.com/austinthecoder/zenv.
data/lib/zenv/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zenv
2
- VERSION = "0.2.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/zenv.rb CHANGED
@@ -1,41 +1,44 @@
1
+ require 'pathname'
1
2
  require "zenv/version"
2
3
 
3
4
  module Zenv
4
- def self.load
5
- namespace = ENV['ZENV']&.to_sym || :default
5
+ @pathname = Pathname.new '.zenv'
6
6
 
7
- if @namespace_loaded
8
- warn "[Zenv] skipping #{namespace.inspect}, already loaded #{@namespace_loaded.inspect}"
9
- end
7
+ class << self
8
+ attr_writer :pathname
10
9
 
11
- filename = '.zenv'
10
+ private
12
11
 
13
- unless File.exist? filename
14
- warn "[Zenv] .zenv file not found"
15
- return
16
- end
12
+ attr_reader :pathname, :namespace_loaded
17
13
 
18
- data = begin
19
- filepath = File.expand_path filename
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
- unless data.key? namespace
25
- warn "[Zenv] missing #{namespace.inspect} in .zenv"
26
- return
27
- end
17
+ if namespace_loaded
18
+ warn "[Zenv] skipping #{namespace.inspect}, already loaded #{namespace_loaded.inspect}"
19
+ end
28
20
 
29
- data[namespace].each do |key, value|
30
- ENV[key.to_s] = value
31
- end
21
+ unless pathname.exist?
22
+ warn "[Zenv] .zenv file not found"
23
+ return
24
+ end
32
25
 
33
- @namespace_loaded = namespace
26
+ data = eval pathname.read
34
27
 
35
- puts "[Zenv] loaded #{@namespace_loaded.inspect}"
28
+ unless data.key? namespace
29
+ warn "[Zenv] missing #{namespace.inspect} in .zenv"
30
+ return
31
+ end
36
32
 
37
- @namespace_loaded
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
- Zenv.load
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 env vars'
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.2.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-03 00:00:00.000000000 Z
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
- description: Simple and flexible approach to loading env vars
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: