envied 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/CHANGELOG.md +11 -1
- data/README.md +5 -3
- data/Rakefile +3 -1
- data/lib/envied.rb +6 -6
- data/lib/envied/cli.rb +55 -3
- data/lib/envied/templates/heroku-env-check.tt +9 -0
- data/lib/envied/version.rb +1 -1
- data/spec/envied_spec.rb +4 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89f6ebe3012653a783d97fb3c1df78c4b747ec6b
|
4
|
+
data.tar.gz: 1fdc04401cd1a5d1dad6aa710e157e1bc0d4108e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72742c30e2590982a229849d225ae669bc9468e802155a1e9703fe409796b4209fd2d6fdc9faf6831a69a6c9c4f81f0af30d105008ca105b0c80f4935f4b210
|
7
|
+
data.tar.gz: 4a361ee32e03924384526ced8c4c22162a8060387831dd9c1cbd954efd7538c4d4aa1a13d93ff3eac27871e709ddcf32349619c12f8751885e8dde267f946932
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--warnings
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
|
+
# 0.6.2 / unreleased
|
2
|
+
|
3
|
+
* Add `envied check:heroku` to do a check on your Heroku app.
|
4
|
+
|
5
|
+
* Add `envied check:heroku:binstub` to generate script for convenient 'check:heroku'
|
6
|
+
|
7
|
+
# 0.6.1 / 2014-08-13
|
8
|
+
|
9
|
+
* Add `envied check` to check whether defined variables are present and valid.
|
10
|
+
|
1
11
|
# 0.6.0 / 2014-08-13
|
2
12
|
|
3
|
-
*
|
13
|
+
* The configuration now lives in `Envfile` by default.
|
4
14
|
|
5
15
|
# 0.5.0 / 2014-07-02
|
6
16
|
|
data/README.md
CHANGED
@@ -159,9 +159,11 @@ ENVied.require(:default, ENV['RACK_ENV'], (ENV['CI'] ? :ci : :not_ci))
|
|
159
159
|
```bash
|
160
160
|
$ envied help
|
161
161
|
Commands:
|
162
|
-
envied check
|
163
|
-
envied
|
164
|
-
envied
|
162
|
+
envied check # Checks whether you environment contains the defined variables
|
163
|
+
envied check:heroku # Checks whether a Heroku config contains the defined variables
|
164
|
+
envied check:heroku:binstub # Generates a shell script for the check:heroku-task
|
165
|
+
envied help [COMMAND] # Describe available commands or one specific command
|
166
|
+
envied init # Generates a default Envfile in the current working directory
|
165
167
|
```
|
166
168
|
|
167
169
|
## Installation
|
data/Rakefile
CHANGED
data/lib/envied.rb
CHANGED
@@ -33,7 +33,7 @@ class ENVied
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.enable_defaults
|
36
|
-
@enable_defaults.respond_to?(:call) ?
|
36
|
+
(@enable_defaults ||= false).respond_to?(:call) ?
|
37
37
|
@enable_defaults.call :
|
38
38
|
@enable_defaults
|
39
39
|
end
|
@@ -46,7 +46,7 @@ class ENVied
|
|
46
46
|
class << self
|
47
47
|
alias_method :defaults_enabled?, :enable_defaults
|
48
48
|
alias_method :enable_defaults=, :enable_defaults!
|
49
|
-
|
49
|
+
attr_writer :current_group
|
50
50
|
end
|
51
51
|
|
52
52
|
def self.current_group
|
@@ -101,15 +101,15 @@ class ENVied
|
|
101
101
|
|
102
102
|
def self.ensure_configured!
|
103
103
|
# Backward compat: load Envfile only when it's present
|
104
|
-
configure_via_envfile if
|
104
|
+
configure_via_envfile if envfile_exist?
|
105
105
|
end
|
106
106
|
|
107
107
|
def self.envfile
|
108
108
|
File.expand_path('Envfile')
|
109
109
|
end
|
110
110
|
|
111
|
-
def self.
|
112
|
-
File.
|
111
|
+
def self.envfile_exist?
|
112
|
+
File.exist?(envfile)
|
113
113
|
end
|
114
114
|
|
115
115
|
def self.configure_via_envfile
|
@@ -158,7 +158,7 @@ class ENVied
|
|
158
158
|
# A list of all configured variable names.
|
159
159
|
#
|
160
160
|
# @example
|
161
|
-
# ENVied.
|
161
|
+
# ENVied.required_variable_names
|
162
162
|
# # => [:DATABASE_URL]
|
163
163
|
#
|
164
164
|
# @return [Array<Symbol>] the list of variable names
|
data/lib/envied/cli.rb
CHANGED
@@ -11,9 +11,9 @@ class ENVied
|
|
11
11
|
template("Envfile.tt")
|
12
12
|
end
|
13
13
|
|
14
|
-
desc "check", "Checks whether
|
14
|
+
desc "check", "Checks whether you environment contains the defined variables"
|
15
15
|
long_desc <<-LONG
|
16
|
-
Checks whether
|
16
|
+
Checks whether defined variables are present and valid in your shell.
|
17
17
|
|
18
18
|
On success the process will exit with status 0.
|
19
19
|
Else the missing/invalid variables will be shown, and the process will exit with status 1.
|
@@ -21,7 +21,59 @@ class ENVied
|
|
21
21
|
option :groups, type: :array, default: %w(default), banner: 'default production'
|
22
22
|
def check
|
23
23
|
ENVied.require(*options[:groups])
|
24
|
-
puts "All
|
24
|
+
puts "All variables for group(s) #{options[:groups]} are present and valid"
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "check:heroku", "Checks whether a Heroku config contains the defined variables"
|
28
|
+
|
29
|
+
long_desc <<-LONG
|
30
|
+
Checks the config of your Heroku app against the local Envfile.
|
31
|
+
|
32
|
+
The Heroku config should be piped to this task:
|
33
|
+
|
34
|
+
heroku config | bundle exec envied check:heroku
|
35
|
+
|
36
|
+
It's more convenient to generate a shell script using the check:heroku:binstub-task.
|
37
|
+
|
38
|
+
On success the process will exit with status 0.
|
39
|
+
Else the missing/invalid variables will be shown, and the process will exit with status 1.
|
40
|
+
LONG
|
41
|
+
option :groups, type: :array, default: %w(default production), banner: 'default production'
|
42
|
+
define_method "check:heroku" do
|
43
|
+
if STDIN.tty?
|
44
|
+
error <<-ERR
|
45
|
+
Please pipe the contents of `heroku config` to this task.
|
46
|
+
I.e. `heroku config | bundle exec envied check:heroku`"
|
47
|
+
ERR
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
config = STDIN.read
|
51
|
+
heroku_env = Hash[config.split("\n")[1..-1].each_with_object([]) do |i, res|
|
52
|
+
res << i.split(":", 2).map(&:strip)
|
53
|
+
end]
|
54
|
+
ENV.replace({}).update(heroku_env)
|
55
|
+
ENVied.require(*options[:groups])
|
56
|
+
puts "All variables for group(s) #{options[:groups]} are present and valid in your Heroku app"
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "check:heroku:binstub", "Generates a shell script for the check:heroku-task"
|
60
|
+
long_desc <<-LONG
|
61
|
+
Generates a shell script to check the Heroku config against the local Envfile.
|
62
|
+
|
63
|
+
The same as the check:heroku-task, but all in one script (no need to pipe `heroku config` to it etc.).
|
64
|
+
|
65
|
+
LONG
|
66
|
+
option :dest, banner: "where to put the script", default: 'bin/heroku-env-check'
|
67
|
+
option :app, banner: "name of Heroku app"
|
68
|
+
option :groups, type: :array, default: %w(default production), banner: 'default production'
|
69
|
+
define_method "check:heroku:binstub" do
|
70
|
+
require 'fileutils'
|
71
|
+
@app = options[:app]
|
72
|
+
@dest = @app ? File.join(*%W(bin #{@app}-env-check)) : options[:dest]
|
73
|
+
@groups = options[:groups]
|
74
|
+
full_dest = File.expand_path(@dest)
|
75
|
+
template("heroku-env-check.tt", full_dest)
|
76
|
+
FileUtils.chmod 0755, full_dest
|
25
77
|
end
|
26
78
|
end
|
27
79
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# Check the config of a Heroku app against the defined variables in `Envfile`
|
4
|
+
|
5
|
+
<%- if @app %>
|
6
|
+
HEROKU_APP=<%= @app %> exec heroku config | bundle exec envied check:heroku --groups <%= @groups.join(",") %>
|
7
|
+
<%- else %>
|
8
|
+
exec heroku config | bundle exec envied check:heroku --groups <%= @groups.join(",") %>
|
9
|
+
<%- end %>
|
data/lib/envied/version.rb
CHANGED
data/spec/envied_spec.rb
CHANGED
@@ -69,7 +69,7 @@ describe ENVied do
|
|
69
69
|
specify do
|
70
70
|
expect {
|
71
71
|
ENVied.require
|
72
|
-
}.to raise_error
|
72
|
+
}.to raise_error(/set the following ENV-variables: a/)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -79,7 +79,7 @@ describe ENVied do
|
|
79
79
|
specify do
|
80
80
|
expect {
|
81
81
|
ENVied.require
|
82
|
-
}.to raise_error
|
82
|
+
}.to raise_error(/ENV\['A'\] \('NaN' can't be coerced to Integer/)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -175,7 +175,7 @@ describe ENVied do
|
|
175
175
|
it 'is required when requiring the group' do
|
176
176
|
expect {
|
177
177
|
described_class.require(:foo)
|
178
|
-
}.to raise_error
|
178
|
+
}.to raise_error(/bar/)
|
179
179
|
end
|
180
180
|
|
181
181
|
it 'is not required when requiring another group' do
|
@@ -197,7 +197,7 @@ describe ENVied do
|
|
197
197
|
[:default, 'default'].each do |groups|
|
198
198
|
expect {
|
199
199
|
described_class.require(*groups)
|
200
|
-
}.to raise_error
|
200
|
+
}.to raise_error(/moar/)
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envied
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gert Goet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -103,6 +103,7 @@ extensions: []
|
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
105
|
- ".gitignore"
|
106
|
+
- ".rspec"
|
106
107
|
- ".travis.yml"
|
107
108
|
- CHANGELOG.md
|
108
109
|
- Gemfile
|
@@ -114,6 +115,7 @@ files:
|
|
114
115
|
- lib/envied.rb
|
115
116
|
- lib/envied/cli.rb
|
116
117
|
- lib/envied/templates/Envfile.tt
|
118
|
+
- lib/envied/templates/heroku-env-check.tt
|
117
119
|
- lib/envied/version.rb
|
118
120
|
- spec/envied_spec.rb
|
119
121
|
- spec/spec_helper.rb
|