envied 0.8.1 → 0.8.2

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: d25c3d2c51229b8d12b11c07e31924a88114d2d1
4
- data.tar.gz: 051c4d8bf0056995e60bfcf79e727d5263b72812
3
+ metadata.gz: 9d96082d1dc1fedf685dc01443f880342727f980
4
+ data.tar.gz: 15edf9b6d7d41abd5f694a534ff092e422cffa4f
5
5
  SHA512:
6
- metadata.gz: e1e84ad9166cd60b9f024f042ad9d77fcb5ebedbfa3cc1263a9f7f611dc7d943458ac974fe57d8f05201279a7a091a839c10ca21597b7e1f9e0ff382c17d1ffd
7
- data.tar.gz: 8cf40ec2c6baf773b65eb3e447cb97ec5896e5731a3a33a86b19734bd6e6fe239dc59b89c709dc504803fe41d4d570ef2dfa045ab1074cf5df75eadd115d8186
6
+ metadata.gz: 34036deeaaf2f1bb339b645ea3f6680aa72323a2e0f3c71d84da130ac8fe2d2b685cdc5f208d5c84bb7b6008d108cc121256a0c9e4806f24512cad2aa77a2e9b
7
+ data.tar.gz: f6768c4c9a2deab86218b9579b41af302ecd18fdd0567a94041067b8d9c4bd4ef17337fa7b1738c78f1402b8ce67a3a4f2ca0cbc7ca8e361de4d3e276dfc4f5d
data/.rspec CHANGED
@@ -1 +1,3 @@
1
1
  --warnings
2
+ --format documentation
3
+ --color
data/.travis.yml CHANGED
@@ -1,5 +1,20 @@
1
+ language: ruby
2
+
3
+ before_install:
4
+ - gem update --system
5
+ - gem install bundler
6
+ - gem update bundler
7
+
1
8
  rvm:
2
9
  - 1.9.3
3
10
  - 2.0.0
4
- - 2.1.0
5
- - jruby
11
+ - 2.1.9
12
+ - 2.2.6
13
+ - 2.3.3
14
+ - 2.4.0
15
+ - jruby-9.0.5.0
16
+ - jruby-head
17
+
18
+ cache: bundler
19
+ sudo: false
20
+ fast_finish: true
data/CHANGELOG.md CHANGED
@@ -1,14 +1,39 @@
1
1
  ## unreleased
2
2
 
3
+ ...
4
+
5
+ ## 0.8.2 / 2017-02-21
6
+
7
+ ### Added
8
+
9
+ * Rails 5 support
10
+
11
+ ### Fixed
12
+
13
+ * Envfile: type string is also correctly implied when providing a default.
14
+
15
+ ## 0.8.1 / 2014-10-18
16
+
3
17
  ### Added
4
18
 
5
19
  * the `check` task uses ENV['ENVIED_GROUPS'] as default groups-option if present
6
20
 
7
21
  ### Fixed
8
22
 
23
+ * Rails: you can use ENVied now in config/application.rb and config/environments/*.rb
24
+
25
+ For existing projects: rerun the `init:rails`-task
26
+
9
27
  * running `check:heroku` takes Heroku's value of ENVIED_GROUPS into account
10
28
  * calling `enable_defaults!` without arguments now does what it says
11
29
 
30
+ ### Deprecated
31
+
32
+ * doing `ENVied.require` in `config/initializers/envied.rb` (as previously generated by `init:rails`-task)
33
+ is not recommended anymore. It triggers a deprecation warning.
34
+
35
+ It's recommended to rerun the `init:rails`-task.
36
+
12
37
  ## 0.8.0 / 2014-10-04
13
38
 
14
39
  ### Added
@@ -16,7 +41,7 @@
16
41
  * the `check:heroku:binstub` task uses ENV['HEROKU_APP'] as app-option if present
17
42
  * the `check` and `check:heroku` task now have a `--quiet` option
18
43
 
19
- This prevents output on STDOUT for a successful check.
44
+ This prevents output on STDOUT for a successful check.
20
45
  Handy for wrapper-scripts:
21
46
 
22
47
  # some bash-script 'ensure-env'
@@ -114,7 +139,7 @@
114
139
 
115
140
  * groups added
116
141
 
117
- This allows for more fine-grained requiring.
142
+ This allows for more fine-grained requiring.
118
143
  See the section in the [README](https://github.com/eval/envied/tree/v0.4.0#groups).
119
144
 
120
145
  * configuring is now simpler:
@@ -129,7 +154,7 @@
129
154
 
130
155
  * Deprecate lowercase methods for uppercase ENV-variables.
131
156
 
132
- `ENV['RACK_ENV']` is no longer accessible as `ENVied.rack_env`, only as `ENVied.RACK_ENV`.
157
+ `ENV['RACK_ENV']` is no longer accessible as `ENVied.rack_env`, only as `ENVied.RACK_ENV`.
133
158
  This is not only what you would expect, but it also reduces the chance of clashing with existing class-methods.
134
159
 
135
160
  ## 0.3.0 / 2014-03-14
data/README.md CHANGED
@@ -137,8 +137,8 @@ Note that 'easily bootstrap' is quite the opposite of 'fail-fast when not all EN
137
137
  # Envfile
138
138
  enable_defaults! { ENV['RACK_ENV'] == 'development' }
139
139
 
140
- variable :FORCE_SSL, :Boolean, default: false
141
- variable :PORT, :Integer, default: proc {|envied| envied.FORCE_SSL ? 443 : 80 }
140
+ variable :FORCE_SSL, :boolean, default: 'false'
141
+ variable :PORT, :integer, default: proc {|envied| envied.FORCE_SSL ? 443 : 80 }
142
142
  ```
143
143
 
144
144
  Please remember that ENVied only **reads** from ENV; it doesn't mutate ENV.
@@ -152,13 +152,6 @@ As a rule of thumb you should only use defaults:
152
152
  * See the [examples](/examples)-folder for a more extensive Envfile
153
153
  * See [the Envfile](https://github.com/eval/bunny_drain/blob/c54d7d977afb5e23a92da7a2fd0d39f6a7e29bf1/Envfile) for the bunny_drain application
154
154
 
155
- ## Rails & Spring
156
-
157
- Long story short: Checking the presence of ENV variables using `ENVied.require` *will* work (use the `init:rails`-task and you're all set).
158
- What won't work: relying on values from `ENV` (and thus `ENVied`) somewhere in `config/**/*.rb` **if these values vary between environments**.
159
-
160
- See this [wiki-page](https://github.com/eval/envied/wiki/Spring-gotchas) for more background info.
161
-
162
155
  ## Command-line interface
163
156
 
164
157
  For help on a specific command, use `envied help <command>`.
@@ -184,7 +177,7 @@ Commands:
184
177
  $ bundle exec envied extract
185
178
  ```
186
179
 
187
- This comes in handy when you're not using ENVied yet. It will find all `ENV['EKY']` and `ENV.fetch('KEY')` statements in your project.
180
+ This comes in handy when you're not using ENVied yet. It will find all `ENV['KEY']` and `ENV.fetch('KEY')` statements in your project.
188
181
 
189
182
  It assumes a standard project layout (see the default value for the globs-option).
190
183
 
data/Rakefile CHANGED
@@ -3,6 +3,7 @@ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec) do |s|
5
5
  s.ruby_opts = %w(-w)
6
+ s.rspec_opts = '--format progress'
6
7
  end
7
8
 
8
9
  desc "Run the specs"
data/envied.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'envied/version'
4
+ require "envied/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "envied"
@@ -18,11 +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 = '>= 1.9.3'
22
- spec.add_dependency "coercible", '~> 1.0'
23
- spec.add_dependency "rack", "~> 1.4"
21
+ spec.required_ruby_version = ">= 1.9.3"
22
+ spec.add_dependency "coercible", "~> 1.0"
23
+ spec.add_dependency "rack", ">= 1.4", (RUBY_VERSION < "2.2.2" ? "< 2" : "< 3")
24
24
  spec.add_dependency "thor", "~> 0.15"
25
25
  spec.add_development_dependency "bundler", "~> 1.5"
26
26
  spec.add_development_dependency "rake"
27
- spec.add_development_dependency "rspec", '~> 3.0'
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
28
  end
@@ -10,8 +10,8 @@ enable_defaults!(&not_production_nor_ci)
10
10
  # we want it to be present though; heck, we're using it in this file!
11
11
  variable :RACK_ENV
12
12
 
13
- variable :FORCE_SSL, :boolean, default: false
14
- variable :PORT, :integer, default: 3000
13
+ variable :FORCE_SSL, :boolean, default: 'false'
14
+ variable :PORT, :integer, default: '3000'
15
15
  # generate the default value using the value of PORT:
16
16
  variable :PUBLIC_HOST_WITH_PORT, :string, default: proc {|envied| "localhost:#{envied.PORT}" }
17
17
 
@@ -27,7 +27,7 @@ end
27
27
  group :not_ci do
28
28
  # CI needs no puma-threads, and sidekiq-stuff etc.
29
29
  # Define that here:
30
- variable :MIN_THREADS, :integer, default: 1
30
+ variable :MIN_THREADS, :integer, default: '1'
31
31
  # more...
32
32
  end
33
33
 
data/lib/envied.rb CHANGED
@@ -23,9 +23,9 @@ class ENVied
23
23
 
24
24
  def self.env!(requested_groups, options = {})
25
25
  @env = begin
26
- config = options.fetch(:config) { Configuration.load }
26
+ @config = options.fetch(:config) { Configuration.load }
27
27
  groups = required_groups(*requested_groups)
28
- EnvProxy.new(config, groups: groups)
28
+ EnvProxy.new(@config, groups: groups)
29
29
  end
30
30
  end
31
31
 
@@ -33,7 +33,10 @@ class ENVied
33
33
  @defaults_enabled
34
34
  end
35
35
 
36
- def variable(name, type = :String, options = {})
36
+ def variable(name, *args)
37
+ options = args.last.is_a?(Hash) ? args.pop : {}
38
+ type = args.first || :string
39
+
37
40
  unless coercer.supported_type?(type)
38
41
  raise ArgumentError,
39
42
  "Variable type (of #{name}) should be one of #{coercer.supported_types}"
@@ -15,4 +15,9 @@ class ENVied::Variable
15
15
  def default_value(*args)
16
16
  default.respond_to?(:call) ? default[*args] : default
17
17
  end
18
+
19
+ def ==(other)
20
+ self.class == other.class &&
21
+ [name, type, group, default] == [other.name, other.type, other.group, other.default]
22
+ end
18
23
  end
@@ -1,3 +1,3 @@
1
1
  class ENVied
2
- VERSION = '0.8.1'
2
+ VERSION = '0.8.2'
3
3
  end
@@ -6,8 +6,25 @@ describe ENVied::Configuration do
6
6
  it { is_expected.to respond_to :defaults_enabled? }
7
7
 
8
8
  describe '#variable' do
9
+ def with_envfile(&block)
10
+ @config = described_class.new(&block)
11
+ end
12
+ attr_reader :config
13
+
9
14
  it 'results in an added variable' do
15
+ with_envfile do
16
+ variable :foo, :boolean
17
+ end
18
+
19
+ expect(config.variables).to include ENVied::Variable.new(:foo, :boolean)
20
+ end
21
+
22
+ it 'sets string as type when no type is given' do
23
+ with_envfile do
24
+ variable :bar, default: 'bar'
25
+ end
10
26
 
27
+ expect(config.variables).to include ENVied::Variable.new(:bar, :string, default: 'bar')
11
28
  end
12
29
  end
13
30
 
data/spec/envied_spec.rb CHANGED
@@ -12,6 +12,7 @@ describe ENVied do
12
12
 
13
13
  before do
14
14
  reset_env
15
+ reset_envied_config
15
16
  reset_configuration
16
17
  end
17
18
 
@@ -23,6 +24,10 @@ describe ENVied do
23
24
  ENVied.instance_eval { @env = nil }
24
25
  end
25
26
 
27
+ def reset_envied_config
28
+ ENVied.instance_eval { @config = nil }
29
+ end
30
+
26
31
  context 'configured' do
27
32
 
28
33
  def unconfigured
@@ -78,6 +83,13 @@ describe ENVied do
78
83
  expect(described_class).to_not respond_to :B
79
84
  end
80
85
 
86
+ it 'sets ENVied.config' do
87
+ configured_with(a: :Integer).and_ENV({'a' => '1'})
88
+ envied_require
89
+
90
+ expect(ENVied.config).to_not be(nil)
91
+ end
92
+
81
93
  context 'ENV contains not all configured variables' do
82
94
  before { configured_with(a: :Integer).and_no_ENV }
83
95
 
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.8.1
4
+ version: 0.8.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-10-17 00:00:00.000000000 Z
11
+ date: 2017-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coercible
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.4'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '3'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '1.4'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '3'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: thor
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -149,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
155
  version: '0'
150
156
  requirements: []
151
157
  rubyforge_project:
152
- rubygems_version: 2.4.2
158
+ rubygems_version: 2.6.8
153
159
  signing_key:
154
160
  specification_version: 4
155
161
  summary: Ensure presence and type of ENV-variables