zenv 1.0.1 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a04ceca2d980622088f13ce6c76533c81a2207d2
4
- data.tar.gz: ca1d0bdfcb286a56cf2cc2ff4949f0eb6ee52248
3
+ metadata.gz: 3b6d5e7fa1011f7a47d6bfaed16dc6e7b674e425
4
+ data.tar.gz: 32a72c3c526d584d19bd339100302a2af023a8f8
5
5
  SHA512:
6
- metadata.gz: 7f477d9f84e0f7005a2639982c1a2f7d8d82b1b5340a71f13821ce95a689e07c657108acefe997acb537b1226560bdc4abe588c83a13c45d922433839fc92326
7
- data.tar.gz: bc0c9a8a90eec201a5b3c92260b5886beac9bb1b2d2c515a75bf3a2eb5f56f228b14c66fe5417d09ac5253bd47689d998dde63722d78789cf022a60b4770f29e
6
+ metadata.gz: 8d4342c8eaaa362c666988efecfd1f8696a7faa3e3453ebdcd5685a3aa70929c7ba23f7dd98fa3e5c15fed1d0dc22c3ac394057255fd517fc3de4861dd0b93e3
7
+ data.tar.gz: b45e549d41d2afb61b77a4bbb48d95fbda8c89b49fd52c7100a430afdaba45a8d2f4f9d1c2a0b96892f1d38de615182c8cf73278bdfb5c3d2ad1a7ce3b0322d1
@@ -1,3 +1,7 @@
1
+ ## 1.0.1 (2016-06-12)
2
+
3
+ * Skip loading env vars if already loaded.
4
+
1
5
  ## 1.0.0 (2016-06-06)
2
6
 
3
7
  * Removed `Zenv.load` as a public method.
data/README.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Simple and flexible approach to loading environment variables.
4
4
 
5
+ **How is this different than Dotenv?**
6
+
7
+ * ZEN ENV loads earlier, so there's no special handling needed for Rails apps.
8
+ * The `.zenv` file is Ruby, which allows for more flexibility.
9
+ * Env vars should specify the Rails env, not the other way around.
10
+ * Does not support overrides via multiple `.zenv` files. If you want to share env vars across multiple namespaces, it's Ruby, DRY it up.
11
+
5
12
  ## Status
6
13
 
7
14
  [![Build Status](https://travis-ci.org/austinthecoder/zenv.svg?branch=master)](https://travis-ci.org/austinthecoder/zenv)
@@ -24,7 +31,7 @@ Or install it yourself as:
24
31
 
25
32
  ## Usage
26
33
 
27
- Create a `.zenv` file at the root of your project:
34
+ Create a `.zenv` or `.zenv.rb` file at the root of your project:
28
35
 
29
36
  ```ruby
30
37
  {
@@ -60,6 +67,15 @@ Specify the namespace in `ZENV`. E.g. `ZENV=other rails console`.
60
67
 
61
68
  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`.
62
69
 
70
+ ### Test environment
71
+
72
+ You probably don't want the default namespace loaded for tests. Create a "test" namespace and put this at the top of your tests (if using RSpec, put it at the top of `spec_helper.rb`):
73
+
74
+ ```ruby
75
+ ENV['ZENV'] = 'test'
76
+ require 'zenv'
77
+ ```
78
+
63
79
  ## Development
64
80
 
65
81
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,13 +1,19 @@
1
1
  require 'pathname'
2
- require "zenv/version"
3
2
 
4
3
  module Zenv
5
- @pathname = Pathname.new '.zenv'
4
+ @available_pathnames = [
5
+ Pathname.new('.zenv'),
6
+ Pathname.new('.zenv.rb'),
7
+ ].freeze
6
8
 
7
9
  class << self
10
+ def version
11
+ '1.1.0'
12
+ end
13
+
8
14
  private
9
15
 
10
- attr_reader :pathname, :namespace_loaded
16
+ attr_reader :available_pathnames, :namespace_loaded
11
17
 
12
18
  def load
13
19
  namespace = ENV['ZENV']&.to_sym || :default
@@ -16,7 +22,9 @@ module Zenv
16
22
  warn "[Zenv] skipping #{namespace.inspect}, already loaded #{namespace_loaded.inspect}"
17
23
  end
18
24
 
19
- unless pathname.exist?
25
+ pathname = available_pathnames.find(&:exist?)
26
+
27
+ unless pathname
20
28
  warn "[Zenv] .zenv file not found"
21
29
  return
22
30
  end
@@ -1,15 +1,15 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'zenv/version'
4
+ require 'zenv'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "zenv"
8
- spec.version = Zenv::VERSION
8
+ spec.version = Zenv.version
9
9
  spec.authors = ["Austin Schneider"]
10
10
  spec.email = ["me@austinschneider.com"]
11
11
 
12
- spec.summary = 'Zen Env'
12
+ spec.summary = 'ZEN ENV'
13
13
  spec.description = 'Simple and flexible approach to loading environment variables.'
14
14
  spec.homepage = 'https://github.com/austinthecoder/zenv'
15
15
 
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: 1.0.1
4
+ version: 1.1.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-12 00:00:00.000000000 Z
11
+ date: 2016-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,7 +63,6 @@ files:
63
63
  - ".gitignore"
64
64
  - ".rspec"
65
65
  - ".travis.yml"
66
- - ".zenv"
67
66
  - CHANGELOG.md
68
67
  - Gemfile
69
68
  - README.md
@@ -72,7 +71,6 @@ files:
72
71
  - bin/setup
73
72
  - exe/zenv
74
73
  - lib/zenv.rb
75
- - lib/zenv/version.rb
76
74
  - zenv.gemspec
77
75
  homepage: https://github.com/austinthecoder/zenv
78
76
  licenses: []
@@ -96,5 +94,5 @@ rubyforge_project:
96
94
  rubygems_version: 2.5.1
97
95
  signing_key:
98
96
  specification_version: 4
99
- summary: Zen Env
97
+ summary: ZEN ENV
100
98
  test_files: []
data/.zenv DELETED
@@ -1,8 +0,0 @@
1
- {
2
- default: {
3
- KEY: 'default value'
4
- },
5
- other: {
6
- KEY: 'other value'
7
- }
8
- }
@@ -1,3 +0,0 @@
1
- module Zenv
2
- VERSION = "1.0.1"
3
- end