rails-env 0.3.0 → 1.0.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: 52c51c805e327445733cfb918be0de3d8a8be724
4
- data.tar.gz: ff8a7b3782ac83c882feba9fe9143bab672d9a1e
3
+ metadata.gz: 88a0628c82307f77ce43292c6944457555217adb
4
+ data.tar.gz: fd260fbe6229e5fe68fe26b5b82515cfb180146f
5
5
  SHA512:
6
- metadata.gz: ce6d646b544c4685a36f2ea4cbc110e9b49f4d13ed59e1239f71b272d3c9c4e0022771eda7b3e4e98fd50436af12e9c4eb33d55528cdbbe00254295cffae18e0
7
- data.tar.gz: 2af8235c5bd7690536081af44ddf3ce3aab814df736ff5659548c3997b3d98dfcefe0c94b088f44609e62a8a1412b59912b7fe804df8291373de6600bb3443a5
6
+ metadata.gz: 456fae20dd8fac5c4efcfc466b8cad56c3c4fe8383d15d4d81f99b908e0365f6d1d15be65052abf9a2ce3b4472bf5db04c03d1c54d7596630fdd39fd6ade1309
7
+ data.tar.gz: 728c5ff0e8cf8f2f67f23c0309fc9705e3dca18a0298215cfef7086e8b28287a6cc697a22e9a85958e3e88f7eeea61af984dda3f6fd04c2bba70c4578bdae9f0
data/README.md CHANGED
@@ -29,8 +29,8 @@ end
29
29
  You can just use:
30
30
 
31
31
  ```ruby
32
- Rails.env.on(:production) do |config|
33
- # Do something with config
32
+ Rails.env.on(:production) do
33
+ config.assets.version = '1.0'
34
34
  end
35
35
  ```
36
36
 
@@ -39,8 +39,28 @@ Looks dumb, but you don't have to use the long `Rails.configuration` or assign i
39
39
  To match all environments, use `:any`.
40
40
 
41
41
  ```ruby
42
- Rails.env.on(:any) do |config|
43
- # Do something with config
42
+ Rails.env.on(:any) do
43
+ config.assets.version = '1.0'
44
+ end
45
+ ```
46
+
47
+ ## Upgrading from previous versions
48
+
49
+ Previous versions used to yield the configuration; this is no longer true on 1.0+.
50
+
51
+ So, instead of using
52
+
53
+ ```ruby
54
+ Rails.env.on(:development) do |config|
55
+ config.assets.version = '1.0'
56
+ end
57
+ ```
58
+
59
+ use
60
+
61
+ ```ruby
62
+ Rails.env.on(:development) do
63
+ config.assets.version = '1.0'
44
64
  end
45
65
  ```
46
66
 
data/lib/rails-env.rb CHANGED
@@ -10,7 +10,7 @@ module RailsEnv
10
10
  module Extension
11
11
  def on(*envs, &block)
12
12
  env_matched = envs.include?(:any) || envs.include?(Rails.env.to_sym)
13
- block.call(Rails.configuration) if env_matched
13
+ Rails.application.configure(&block) if env_matched
14
14
  end
15
15
  end
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module RailsEnv
2
- VERSION = '0.3.0'
2
+ VERSION = '1.0.0'
3
3
  end
data/rails-env.gemspec CHANGED
@@ -19,4 +19,5 @@ Gem::Specification.new do |spec|
19
19
  spec.add_development_dependency 'rails'
20
20
  spec.add_development_dependency 'rake'
21
21
  spec.add_development_dependency 'rspec'
22
+ spec.add_development_dependency 'pry-meta'
22
23
  end
@@ -1,27 +1,43 @@
1
1
  require 'spec_helper'
2
2
 
3
+ class Callable
4
+ attr_accessor :configuration
5
+
6
+ def to_proc
7
+ callable = self
8
+
9
+ lambda do |app|
10
+ callable.configuration = config
11
+ end
12
+ end
13
+ end
14
+
3
15
  describe RailsEnv do
4
16
  it 'runs block when env matches' do
5
- block = proc {}
6
- expect(block).to receive(:call).with(Rails.configuration)
17
+ block = Callable.new
7
18
  Rails.env.on(:test, &block)
19
+
20
+ expect(block.configuration).to eq(Rails.configuration)
8
21
  end
9
22
 
10
23
  it 'matches against multiple envs' do
11
- block = proc {}
12
- expect(block).to receive(:call).with(Rails.configuration)
24
+ block = Callable.new
13
25
  Rails.env.on(:development, :test, &block)
26
+
27
+ expect(block.configuration).to eq(Rails.configuration)
14
28
  end
15
29
 
16
30
  it 'skips block when env differs' do
17
- block = proc {}
18
- expect(block).not_to receive(:call)
31
+ block = Callable.new
19
32
  Rails.env.on(:production, &block)
33
+
34
+ expect(block.configuration).to be_nil
20
35
  end
21
36
 
22
37
  it 'runs on any environment' do
23
- block = proc {}
24
- expect(block).to receive(:call).with(Rails.configuration)
38
+ block = Callable.new
25
39
  Rails.env.on(:any, &block)
40
+
41
+ expect(block.configuration).to eq(Rails.configuration)
26
42
  end
27
43
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  ENV['RAILS_ENV'] = 'test'
2
2
 
3
3
  require 'bundler/setup'
4
- require 'rails/all'
4
+ require 'rails'
5
5
  require 'rails-env'
6
6
 
7
7
  class DummyApp < Rails::Application
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-08 00:00:00.000000000 Z
11
+ date: 2015-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-meta
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Avoid environment detection on Rails
70
84
  email:
71
85
  - fnando.vieira@gmail.com
@@ -104,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
118
  version: '0'
105
119
  requirements: []
106
120
  rubyforge_project:
107
- rubygems_version: 2.4.5
121
+ rubygems_version: 2.4.6
108
122
  signing_key:
109
123
  specification_version: 4
110
124
  summary: Avoid environment detection on Rails