envied 0.9.0 → 0.9.3

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
- SHA1:
3
- metadata.gz: 803c704396a34b45112c1e893d902f616146d826
4
- data.tar.gz: 2886267c88374d9b75d02920f55ca0df9e025244
2
+ SHA256:
3
+ metadata.gz: dcc781ac6f01f4925045b61ca88d14b41dbccebe46dc34582a391c884bb99e4a
4
+ data.tar.gz: 542a7c711445013a845478f716cddf7ac82b7834365429ebf24ed36b08462ca2
5
5
  SHA512:
6
- metadata.gz: 721fa2f72d8fbba07714eaf8efdaa93bd48b045defb67fdd4d2e0a56e7d78fe132e152a68762fe1586138b6624b6c2ea16a80ab9cd16f13b7bb22f8b26750c64
7
- data.tar.gz: 44567081a050048fc3eec30c4c7746999aaf9d5a26cb6c6f80480d3b4464ae88caa3be21aa1247a96c6304c0050575759bb631bfefa118a0e6ee57b939efb140
6
+ metadata.gz: 2c976e128a2c3c8ab59c31fbec653aa7fe3b8d01973e92e4da220deff09cdee826c34627ca873d4eb612292f175419914c4235932002422cab3454f72b3da2d8
7
+ data.tar.gz: f37e48c5f981902d2db3e46dfa2a6101998ef11987e48e59ac9fc8e951d5b48d4e1cc6da756ff9b1860bb01e2abf6c72d0f1563a453f3e412754c2f0b8cfcbbb
data/.gitignore CHANGED
@@ -1,18 +1,14 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
6
14
  Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- bin
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,49 @@
1
+ .rspec: &rspec
2
+ stage: test
3
+ tags:
4
+ - docker
5
+ before_script:
6
+ - "echo 'gem: --no-document' > ~/.gemrc"
7
+ - gem install bundler
8
+ - 'git -v || apk --update add git'
9
+ - bundle install -j $(nproc)
10
+ script:
11
+ - bundle exec rake
12
+
13
+ rspec ruby-2.4:
14
+ image: ruby:2.4-alpine
15
+ <<: *rspec
16
+
17
+ rspec ruby-2.5:
18
+ image: ruby:2.5-alpine
19
+ <<: *rspec
20
+
21
+ rspec ruby-2.6:
22
+ image: ruby:2.6-alpine
23
+ <<: *rspec
24
+
25
+ rspec ruby-2.7:
26
+ image: ruby:2.7-rc-alpine
27
+ <<: *rspec
28
+
29
+ rspec jruby-9.2:
30
+ image: jruby:9.2-alpine
31
+ <<: *rspec
32
+ only:
33
+ - 0-9-releases
34
+
35
+ release:
36
+ stage: deploy
37
+ image: ruby:2.6-alpine
38
+ tags:
39
+ - docker
40
+ script:
41
+ - "echo 'gem: --no-document' > ~/.gemrc"
42
+ - gem install bundler
43
+ - 'git -v || apk --update add git'
44
+ - bundle install -j $(nproc)
45
+ - 'ruby -ryaml -e "puts YAML.dump({rubygems_api_key: ENV.fetch(%{RUBYGEMS_API_KEY})})" > ~/.gem/credentials'
46
+ - chmod 600 ~/.gem/credentials
47
+ - bundle exec rake release
48
+ only:
49
+ - tags
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
- --warnings
2
- --format progress
3
1
  --color
2
+ --require spec_helper
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## 0.9.2 / 2019-06-29
2
+
3
+ * Project moved to GitLab (https://gitlab.com/envied/envied)
4
+ * Now requiring Ruby 2.4+ [#48], [#51]
5
+ * Removed `coercible` dependency as now all coercion functionality is implemented locally. This is a backwards compatible change. [#49]
6
+ * Lots of refactoring and bringing the project up-to-date
7
+
8
+ ### Deprecated
9
+
10
+ * default values
11
+
12
+ See https://gitlab.com/envied/envied/tree/0-9-releases#defaults
13
+
14
+ ## 0.9.1 / 2017-07-06
15
+
16
+ * Updates `envied check:heroku` to support multiline ENV variables [#42](../../pull/42)
17
+
1
18
  ## 0.9.0 / 2017-03-01
2
19
 
3
20
  * Support multiple groups [#16](../../pull/16)
data/Gemfile CHANGED
@@ -2,6 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in envied.gemspec
4
4
  gemspec
5
-
6
- gem 'pry'
7
- gem 'benchmark-ips'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ENVied [![Build Status](https://travis-ci.org/eval/envied.svg?branch=master)](https://travis-ci.org/eval/envied)
1
+ # ENVied [![pipeline status](https://gitlab.com/envied/envied/badges/0-9-releases/pipeline.svg)](https://gitlab.com/envied/envied/commits/0-9-releases) [![project chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://envied-rb.zulipchat.com/)
2
2
 
3
3
  ### TL;DR ensure presence and type of your app's ENV-variables.
4
4
 
@@ -19,7 +19,6 @@ For the rationale behind this project, see this [blogpost](http://www.gertgoet.c
19
19
  * [Groups](#groups)
20
20
  * [Defaults](#defaults)
21
21
  * [More examples](#more-examples)
22
- * [Rails](#rails--spring)
23
22
  * [Command-line interface](#command-line-interface)
24
23
  * [How do I...?](#how-do-i)
25
24
  * [Testing](#testing)
@@ -91,7 +90,7 @@ The following types are supported:
91
90
  * `:time` (e.g. '14:00')
92
91
  * `:hash` (e.g. 'a=1&b=2' becomes `{'a' => '1', 'b' => '2'}`)
93
92
  * `:array` (e.g. 'tag1,tag2' becomes `['tag1', 'tag2']`)
94
- * `:uri` (e.g. 'http://www.google.com' becomes `URI.parse('http://www.google.com')`
93
+ * `:uri` (e.g. 'http://www.google.com' becomes result of `URI.parse('http://www.google.com')`)
95
94
 
96
95
  ### Groups
97
96
 
@@ -134,6 +133,9 @@ ENVied.require(nil)
134
133
 
135
134
  ### Defaults
136
135
 
136
+ > *NOTE*: default values will be removed in the next minor-release (i.e. > v0.9). See https://gitlab.com/envied/envied/tree/master#what-happened-to-default-values for more information and how to migrate.
137
+ > While your project depends on this feature it's recommended to pin the gem to 0.9-releases, i.e. `gem 'envied', '~> 0.9.3'`.
138
+
137
139
  In order to let other developers easily bootstrap the application, you can assign defaults to variables.
138
140
  Defaults can be a value or a `Proc` (see example below).
139
141
 
@@ -192,7 +194,7 @@ It assumes a standard project layout (see the default value for the globs-option
192
194
  The easiest/quickest is to run:
193
195
 
194
196
  ```
195
- $ heroku config | bundle exec envied check:heroku
197
+ $ heroku config --json | bundle exec envied check:heroku
196
198
  ```
197
199
 
198
200
  This is equivalent to having the heroku config as your local environment and running `envied check:heroku --groups default production`.
@@ -220,12 +222,14 @@ bundle exec rspec
220
222
  ## Developing
221
223
 
222
224
  ```bash
223
- bundle exec pry --gem
225
+ bin/console
224
226
  ```
225
227
 
226
228
  ## Contributing
227
229
 
228
- 1. Fork it: http://github.com/eval/envied/fork
230
+ To suggest a new feature, [open an Issue](https://gitlab.com/envied/envied/issues/new) before opening a PR.
231
+
232
+ 1. Fork it: https://gitlab.com/envied/envied/-/forks/new
229
233
  2. Create your feature branch: `git checkout -b my-new-feature`
230
234
  3. Commit your changes: `git commit -am 'Add some feature'`
231
235
  4. Push to the branch: `git push origin my-new-feature`
data/Rakefile CHANGED
@@ -1,10 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
- require 'rspec/core/rake_task'
2
+ require "rspec/core/rake_task"
3
3
 
4
- RSpec::Core::RakeTask.new(:spec) do |s|
5
- s.ruby_opts = %w(-w)
6
- s.rspec_opts = '--format progress'
7
- end
4
+ RSpec::Core::RakeTask.new(:spec)
8
5
 
9
- desc "Run the specs"
10
6
  task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "envied"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/envied.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["gert@thinkcreate.nl", "jjfutbol@gmail.com"]
11
11
  spec.summary = %q{Ensure presence and type of ENV-variables}
12
12
  spec.description = %q{Ensure presence and type of your app's ENV-variables.}
13
- spec.homepage = "https://github.com/eval/envied"
13
+ spec.homepage = "https://gitlab.com/envied/envied/tree/master#envied"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -18,10 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.required_ruby_version = ">= 2.1.9"
22
- spec.add_dependency "coercible", "~> 1.0"
21
+ spec.required_ruby_version = ">= 2.4"
22
+
23
23
  spec.add_dependency "thor", "~> 0.15"
24
- spec.add_development_dependency "bundler", "~> 1.5"
25
- spec.add_development_dependency "rake"
24
+
25
+ spec.add_development_dependency "bundler", "~> 2.0"
26
+ spec.add_development_dependency "rake", "~> 12.0"
26
27
  spec.add_development_dependency "rspec", "~> 3.0"
27
28
  end
@@ -1,4 +1,6 @@
1
1
  # -*- mode: ruby -*-¬
2
+ # NOTE: defaults are deprecated and will be removed in > v0.9
3
+
2
4
  # We allow defaults for local development (and local tests), but want our CI
3
5
  # to mimic our production as much as possible.
4
6
  # New developers that don't have RACK_ENV set, will in this way not be presented with a huge
data/lib/envied/cli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'thor'
2
+ require 'json'
2
3
  require 'envied/env_var_extractor'
3
4
 
4
5
  class ENVied
@@ -42,10 +43,8 @@ class ENVied
42
43
  puts "Writing Envfile to #{File.expand_path('Envfile')}"
43
44
  template("Envfile.tt")
44
45
 
45
- puts <<-INIT
46
- Add the following snippet (or similar) to your app's initialization:
47
- ENVied.require(*ENV['ENVIED_GROUPS'] || [:default, ENV['RACK_ENV']])
48
- INIT
46
+ puts "Add the following snippet (or similar) to your app's initialization:"
47
+ puts "ENVied.require(*ENV['ENVIED_GROUPS'] || [:default, ENV['RACK_ENV']])"
49
48
  end
50
49
 
51
50
  desc "init:rails", "Generate all files needed for a Rails project"
@@ -78,13 +77,12 @@ INIT
78
77
  end
79
78
 
80
79
  desc "check:heroku", "Checks whether a Heroku config contains required variables"
81
-
82
80
  long_desc <<-LONG
83
81
  Checks the config of your Heroku app against the local Envfile.
84
82
 
85
83
  The Heroku config should be piped to this task:
86
84
 
87
- heroku config | bundle exec envied check:heroku
85
+ heroku config --json | bundle exec envied check:heroku
88
86
 
89
87
  Use the check:heroku:binstub-task to turn this into a bash-script.
90
88
 
@@ -95,18 +93,11 @@ INIT
95
93
  option :quiet, type: :boolean, desc: 'Communicate success of the check only via the exit status.'
96
94
  define_method "check:heroku" do
97
95
  if STDIN.tty?
98
- error <<-ERR
99
- Please pipe the contents of `heroku config` to this task.
100
- I.e. `heroku config | bundle exec envied check:heroku`"
101
- ERR
96
+ error "Please pipe to this task i.e. `heroku config --json | bundle exec envied check:heroku`"
102
97
  exit 1
103
98
  end
104
- config = STDIN.read
105
- heroku_env = Hash[config.split("\n")[1..-1].each_with_object([]) do |i, res|
106
- res << i.split(":", 2).map(&:strip)
107
- end]
108
-
109
- ENV.replace({}).update(heroku_env)
99
+ heroku_env = JSON.parse(STDIN.read)
100
+ ENV.replace(heroku_env)
110
101
 
111
102
  requested_groups = ENV['ENVIED_GROUPS'] || options[:groups]
112
103
  ENVied.require(*requested_groups)
@@ -119,8 +110,7 @@ ERR
119
110
  long_desc <<-LONG
120
111
  Generates a shell script to check the Heroku config against the local Envfile.
121
112
 
122
- The same as the check:heroku-task, but all in one script (no need to pipe `heroku config` to it etc.).
123
-
113
+ The same as the check:heroku-task, but all in one script (no need to pipe `heroku config --json` to it etc.).
124
114
  LONG
125
115
  option :dest, banner: "where to put the script", desc: "Default: bin/<app>-env-check or bin/heroku-env-check"
126
116
  option :app, banner: "name of Heroku app", desc: "uses ENV['HEROKU_APP'] as default if present", default: ENV['HEROKU_APP']
@@ -0,0 +1,72 @@
1
+ class ENVied::Coercer::ENViedString
2
+ TRUE_VALUES = %w[1 on t true y yes].freeze
3
+ FALSE_VALUES = %w[0 off f false n no].freeze
4
+ BOOLEAN_MAP = (TRUE_VALUES.product([ true ]) + FALSE_VALUES.product([ false ])).to_h.freeze
5
+
6
+ def to_array(str)
7
+ str.split(/(?<!\\),/).map{|i| i.gsub(/\\,/,',') }
8
+ end
9
+
10
+ def to_boolean(str)
11
+ BOOLEAN_MAP.fetch(str&.downcase) do
12
+ raise_unsupported_coercion(str, __method__)
13
+ end
14
+ end
15
+
16
+ def to_date(str)
17
+ require 'date'
18
+ ::Date.parse(str)
19
+ rescue ArgumentError
20
+ raise_unsupported_coercion(str, __method__)
21
+ end
22
+
23
+ def to_float(str)
24
+ Float(str)
25
+ rescue ArgumentError
26
+ raise_unsupported_coercion(str, __method__)
27
+ end
28
+
29
+ def to_hash(str)
30
+ require 'cgi'
31
+ ::CGI.parse(str).map { |key, values| [key, values[0]] }.to_h
32
+ end
33
+
34
+ def to_string(str)
35
+ if str.respond_to?(:to_str)
36
+ str.public_send(:to_str)
37
+ else
38
+ raise_unsupported_coercion(str, __method__)
39
+ end
40
+ end
41
+
42
+ def to_symbol(str)
43
+ str.to_sym
44
+ end
45
+
46
+ def to_time(str)
47
+ require 'time'
48
+ ::Time.parse(str)
49
+ rescue ArgumentError
50
+ raise_unsupported_coercion(str, __method__)
51
+ end
52
+
53
+ def to_uri(str)
54
+ require 'uri'
55
+ ::URI.parse(str)
56
+ end
57
+
58
+ def to_integer(str)
59
+ Integer(str)
60
+ rescue ArgumentError
61
+ raise_unsupported_coercion(str, __method__)
62
+ end
63
+
64
+ private
65
+
66
+ def raise_unsupported_coercion(value, method)
67
+ raise(
68
+ ENVied::Coercer::UnsupportedCoercion,
69
+ "#{self.class}##{method} doesn't know how to coerce #{value.inspect}"
70
+ )
71
+ end
72
+ end
@@ -1,23 +1,7 @@
1
- require 'coercible'
2
-
3
1
  # Responsible for all string to type coercions.
4
2
  class ENVied::Coercer
5
- module CoercerExts
6
- def to_array(str)
7
- str.split(/(?<!\\),/).map{|i| i.gsub(/\\,/,',') }
8
- end
9
-
10
- def to_hash(str)
11
- require 'cgi'
12
- ::CGI.parse(str).map { |key, values| [key, values[0]] }.to_h
13
- end
14
3
 
15
- def to_uri(str)
16
- require 'uri'
17
- ::URI.parse(str)
18
- end
19
- end
20
- Coercible::Coercer::String.send(:include, CoercerExts)
4
+ UnsupportedCoercion = Class.new(StandardError)
21
5
 
22
6
  # Coerce strings to specific type.
23
7
  #
@@ -31,14 +15,9 @@ class ENVied::Coercer
31
15
  # @return [type] the coerced string.
32
16
  def coerce(string, type)
33
17
  unless supported_type?(type)
34
- raise ArgumentError, "#{type.inspect} is not supported type"
18
+ raise ArgumentError, "The type `#{type.inspect}` is not supported."
35
19
  end
36
- coerce_method_for(type.to_sym)[string]
37
- end
38
-
39
- def coerce_method_for(type)
40
- return nil unless supported_type?(type)
41
- coercer.method("to_#{type.downcase}")
20
+ coercer.public_send("to_#{type.downcase}", string)
42
21
  end
43
22
 
44
23
  def self.supported_types
@@ -69,7 +48,7 @@ class ENVied::Coercer
69
48
  end
70
49
 
71
50
  def coercer
72
- @coercer ||= Coercible::Coercer.new[String]
51
+ @coercer ||= ENViedString.new
73
52
  end
74
53
 
75
54
  def coerced?(value)
@@ -80,7 +59,7 @@ class ENVied::Coercer
80
59
  return false unless supported_type?(type)
81
60
  coerce(string, type)
82
61
  true
83
- rescue Coercible::UnsupportedCoercion
62
+ rescue UnsupportedCoercion
84
63
  false
85
64
  end
86
65
  end
@@ -2,21 +2,13 @@ class ENVied
2
2
  class Configuration
3
3
  attr_reader :current_group, :defaults_enabled, :coercer
4
4
 
5
- def initialize(options = {}, &block)
5
+ def initialize(**options, &block)
6
6
  @coercer = options.fetch(:coercer, Coercer.new)
7
7
  @defaults_enabled = options.fetch(:enable_defaults, defaults_enabled_default)
8
8
  instance_eval(&block) if block_given?
9
9
  end
10
10
 
11
- def defaults_enabled_default
12
- if ENV['ENVIED_ENABLE_DEFAULTS'].nil?
13
- false
14
- else
15
- @coercer.coerce(ENV['ENVIED_ENABLE_DEFAULTS'], :boolean)
16
- end
17
- end
18
-
19
- def self.load(options = {})
11
+ def self.load(**options)
20
12
  envfile = File.expand_path('Envfile')
21
13
  new(options).tap do |v|
22
14
  v.instance_eval(File.read(envfile), envfile)
@@ -24,6 +16,7 @@ class ENVied
24
16
  end
25
17
 
26
18
  def enable_defaults!(value = true, &block)
19
+ default_values_deprecation
27
20
  @defaults_enabled = block_given? ? block.call : value
28
21
  end
29
22
 
@@ -33,13 +26,9 @@ class ENVied
33
26
  @defaults_enabled
34
27
  end
35
28
 
36
- def variable(name, *args)
37
- options = args.last.is_a?(Hash) ? args.pop : {}
38
- type = args.first || :string
39
-
29
+ def variable(name, type = :string, **options)
40
30
  unless coercer.supported_type?(type)
41
- raise ArgumentError,
42
- "Variable type (of #{name}) should be one of #{coercer.supported_types}"
31
+ raise ArgumentError, "#{type.inspect} is not a supported type. Should be one of #{coercer.supported_types}"
43
32
  end
44
33
  options[:group] = current_group if current_group
45
34
  variables << ENVied::Variable.new(name, type, options)
@@ -57,6 +46,24 @@ class ENVied
57
46
  def variables
58
47
  @variables ||= []
59
48
  end
60
- end
61
49
 
50
+ private
51
+
52
+ def default_values_deprecation
53
+ warning = "Default values will be removed in the next minor-release of ENVied (i.e. > v0.9). For more info see https://gitlab.com/envied/envied/tree/0-9-releases#defaults."
54
+ if defined?(ActiveSupport::Deprecation)
55
+ ActiveSupport::Deprecation.warn warning
56
+ else
57
+ $stderr.puts "DEPRECATION WARNING: #{warning}"
58
+ end
59
+ end
60
+
61
+ def defaults_enabled_default
62
+ if ENV['ENVIED_ENABLE_DEFAULTS'].nil?
63
+ false
64
+ else
65
+ @coercer.coerce(ENV['ENVIED_ENABLE_DEFAULTS'], :boolean)
66
+ end
67
+ end
68
+ end
62
69
  end
@@ -2,8 +2,9 @@ class ENVied
2
2
  # Responsible for anything related to the ENV.
3
3
  class EnvProxy
4
4
  attr_reader :config, :coercer, :groups
5
+ private :config, :coercer, :groups
5
6
 
6
- def initialize(config, options = {})
7
+ def initialize(config, **options)
7
8
  @config = config
8
9
  @coercer = options.fetch(:coercer, ENVied::Coercer.new)
9
10
  @groups = options.fetch(:groups, [])
@@ -17,16 +18,6 @@ class ENVied
17
18
  variables.reject(&method(:coerced?)).reject(&method(:coercible?))
18
19
  end
19
20
 
20
- def variables
21
- @variables ||= begin
22
- config.variables.select {|v| groups.include?(v.group) }
23
- end
24
- end
25
-
26
- def variables_by_name
27
- Hash[variables.map {|v| [v.name, v] }]
28
- end
29
-
30
21
  def [](name)
31
22
  coerce(variables_by_name[name.to_sym])
32
23
  end
@@ -35,35 +26,45 @@ class ENVied
35
26
  variables_by_name[name.to_sym]
36
27
  end
37
28
 
38
- def env_value_of(var)
39
- ENV[var.name.to_s]
40
- end
41
-
42
- def default_value_of(var)
43
- var.default_value(ENVied, var)
44
- end
45
-
46
29
  def value_to_coerce(var)
47
30
  return env_value_of(var) unless env_value_of(var).nil?
48
31
  config.defaults_enabled? ? default_value_of(var) : nil
49
32
  end
50
33
 
34
+ private
35
+
51
36
  def coerce(var)
52
37
  coerced?(var) ?
53
38
  value_to_coerce(var) :
54
39
  coercer.coerce(value_to_coerce(var), var.type)
55
40
  end
56
41
 
42
+ def coerced?(var)
43
+ coercer.coerced?(value_to_coerce(var))
44
+ end
45
+
57
46
  def coercible?(var)
58
47
  coercer.coercible?(value_to_coerce(var), var.type)
59
48
  end
60
49
 
50
+ def default_value_of(var)
51
+ var.default_value(ENVied, var)
52
+ end
53
+
54
+ def env_value_of(var)
55
+ ENV[var.name.to_s]
56
+ end
57
+
61
58
  def missing?(var)
62
59
  value_to_coerce(var).nil?
63
60
  end
64
61
 
65
- def coerced?(var)
66
- coercer.coerced?(value_to_coerce(var))
62
+ def variables
63
+ @variables ||= config.variables.select {|v| groups.include?(v.group) }
64
+ end
65
+
66
+ def variables_by_name
67
+ @variables_by_name ||= variables.map {|v| [v.name, v] }.to_h
67
68
  end
68
69
  end
69
70
  end
@@ -15,12 +15,12 @@ class ENVied
15
15
 
16
16
  attr_reader :globs, :extensions
17
17
 
18
- def initialize(options = {})
18
+ def initialize(**options)
19
19
  @globs = options.fetch(:globs, self.defaults[:globs])
20
20
  @extensions = options.fetch(:extensions, self.defaults[:extensions])
21
21
  end
22
22
 
23
- def self.extract_from(globs, options = {})
23
+ def self.extract_from(globs, **options)
24
24
  new(options.merge(globs: Array(globs))).extract
25
25
  end
26
26
 
@@ -3,7 +3,7 @@
3
3
  # Check the config of a Heroku app against the defined variables in `Envfile`
4
4
 
5
5
  <%- if @app %>
6
- HEROKU_APP=<%= @app %> exec heroku config | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
6
+ HEROKU_APP=<%= @app %> exec heroku config --json | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
7
7
  <%- else %>
8
- exec heroku config | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
8
+ exec heroku config --json | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
9
9
  <%- end %>
@@ -1,7 +1,7 @@
1
1
  class ENVied::Variable
2
2
  attr_reader :name, :type, :group, :default
3
3
 
4
- def initialize(name, type, options = {})
4
+ def initialize(name, type, **options)
5
5
  @name = name.to_sym
6
6
  @type = type.to_sym
7
7
  @group = options.fetch(:group, :default).to_sym
@@ -1,3 +1,3 @@
1
1
  class ENVied
2
- VERSION = '0.9.0'
2
+ VERSION = '0.9.3'
3
3
  end