rails-env 1.0.5 → 1.0.6
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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -0
- data/README.md +21 -0
- data/gemfiles/rails_4_2.gemfile +4 -0
- data/gemfiles/rails_5_0.gemfile +4 -0
- data/lib/rails-env.rb +13 -1
- data/lib/rails-env/version.rb +1 -1
- data/test/test_helper.rb +1 -0
- data/test/unit/rails_test.rb +14 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ce82d44b07a02c08c130d1017570eeca3b1aa96a
|
|
4
|
+
data.tar.gz: 59bd44ea9ae33fc99450521f257fc2c26cdbb4ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3a1fdd95cdb42bce025a436e5c4ce81a6f55d6912d9bc679cda58b9caca68ed6e014487e659ab96d045d6429194635c7c84a77c84d03853bee41240929377c3
|
|
7
|
+
data.tar.gz: e146a9f72d26c5bc3a79bb5b82d04a4729928ca262fc7b4869324ffeabf47628170ec3c7eee0f1ac8dfc85a5ad34a5fd298125c537095ee35955e86f93812fd6
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# rails-env
|
|
2
2
|
|
|
3
|
+
[](https://travis-ci.org/fnando/rails-env)
|
|
4
|
+
[](https://codeclimate.com/github/fnando/rails-env)
|
|
5
|
+
[](http://badge.fury.io/rb/rails-env)
|
|
6
|
+
|
|
3
7
|
Avoid environment detection on Rails.
|
|
4
8
|
|
|
5
9
|
## Installation
|
|
@@ -44,6 +48,23 @@ Rails.env.on(:any) do
|
|
|
44
48
|
end
|
|
45
49
|
```
|
|
46
50
|
|
|
51
|
+
## Gotcha
|
|
52
|
+
|
|
53
|
+
Not all options can be defined through `Rails.env`. Rails propagates options on its engine file, meaning that every option defined on `config` afterwards must be manually propagated.
|
|
54
|
+
|
|
55
|
+
It's hard to automatically propagate every existing option, so we have the most common options covered, as you can see the list below:
|
|
56
|
+
|
|
57
|
+
- action_controller
|
|
58
|
+
- action_mailer
|
|
59
|
+
- action_view
|
|
60
|
+
- active_job
|
|
61
|
+
- active_record
|
|
62
|
+
- time_zone
|
|
63
|
+
- auto/eager load paths
|
|
64
|
+
- i18n
|
|
65
|
+
|
|
66
|
+
If you need to set any option not covered by rails-env, [please open a ticket](https://github.com/fnando/rails-env/issues/new).
|
|
67
|
+
|
|
47
68
|
## Upgrading from previous versions
|
|
48
69
|
|
|
49
70
|
Previous versions used to yield the configuration; this is no longer true on 1.0+.
|
data/lib/rails-env.rb
CHANGED
|
@@ -29,6 +29,7 @@ module RailsEnv
|
|
|
29
29
|
propagate(:active_job, "::ActiveJob::Base")
|
|
30
30
|
propagate(:active_record, "::ActiveRecord::Base")
|
|
31
31
|
propagate(:time_zone, "::Time", :zone)
|
|
32
|
+
propagate_autoload_paths
|
|
32
33
|
propagate_i18n
|
|
33
34
|
end
|
|
34
35
|
|
|
@@ -42,6 +43,17 @@ module RailsEnv
|
|
|
42
43
|
I18n.load_path += config.i18n.load_path if config.i18n.load_path
|
|
43
44
|
end
|
|
44
45
|
|
|
46
|
+
def self.propagate_autoload_paths
|
|
47
|
+
all_autoload_paths = (
|
|
48
|
+
config.autoload_paths +
|
|
49
|
+
config.eager_load_paths +
|
|
50
|
+
config.autoload_once_paths
|
|
51
|
+
).uniq
|
|
52
|
+
|
|
53
|
+
ActiveSupport::Dependencies.autoload_paths.unshift(*all_autoload_paths)
|
|
54
|
+
ActiveSupport::Dependencies.autoload_once_paths.unshift(*config.autoload_once_paths)
|
|
55
|
+
end
|
|
56
|
+
|
|
45
57
|
def self.propagate(options_name, target_name, target_property = nil)
|
|
46
58
|
return unless Object.const_defined?(target_name)
|
|
47
59
|
return unless config.respond_to?(options_name)
|
|
@@ -49,7 +61,7 @@ module RailsEnv
|
|
|
49
61
|
target = Object.const_get(target_name)
|
|
50
62
|
options = config.public_send(options_name)
|
|
51
63
|
|
|
52
|
-
if options.is_a?(
|
|
64
|
+
if options.is_a?(Hash)
|
|
53
65
|
options.each do |key, value|
|
|
54
66
|
target.public_send("#{key}=", value) if target.respond_to?("#{key}=")
|
|
55
67
|
end
|
data/lib/rails-env/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/unit/rails_test.rb
CHANGED
|
@@ -11,6 +11,10 @@ class ConfigPropagationTest < Minitest::Test
|
|
|
11
11
|
config.i18n.default_locale = "pt-BR"
|
|
12
12
|
config.action_view.raise_on_missing_translations = true
|
|
13
13
|
config.active_job.queue_adapter = :test
|
|
14
|
+
|
|
15
|
+
config.autoload_paths += ["#{__dir__}/al"]
|
|
16
|
+
config.autoload_once_paths += ["#{__dir__}/alo"]
|
|
17
|
+
config.eager_load_paths += ["#{__dir__}/el"]
|
|
14
18
|
end
|
|
15
19
|
end
|
|
16
20
|
|
|
@@ -51,4 +55,14 @@ class ConfigPropagationTest < Minitest::Test
|
|
|
51
55
|
test "sets queue adapter" do
|
|
52
56
|
assert_kind_of ActiveJob::QueueAdapters::TestAdapter, ActiveJob::Base.queue_adapter
|
|
53
57
|
end
|
|
58
|
+
|
|
59
|
+
test "sets autoload_paths" do
|
|
60
|
+
assert ActiveSupport::Dependencies.autoload_paths.include?("#{__dir__}/al")
|
|
61
|
+
assert ActiveSupport::Dependencies.autoload_paths.include?("#{__dir__}/el")
|
|
62
|
+
assert ActiveSupport::Dependencies.autoload_paths.include?("#{__dir__}/alo")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
test "sets autoload_once_paths" do
|
|
66
|
+
assert ActiveSupport::Dependencies.autoload_once_paths.include?("#{__dir__}/alo")
|
|
67
|
+
end
|
|
54
68
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-env
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nando Vieira
|
|
@@ -89,10 +89,13 @@ extra_rdoc_files: []
|
|
|
89
89
|
files:
|
|
90
90
|
- ".gitignore"
|
|
91
91
|
- ".rspec"
|
|
92
|
+
- ".travis.yml"
|
|
92
93
|
- Gemfile
|
|
93
94
|
- LICENSE.txt
|
|
94
95
|
- README.md
|
|
95
96
|
- Rakefile
|
|
97
|
+
- gemfiles/rails_4_2.gemfile
|
|
98
|
+
- gemfiles/rails_5_0.gemfile
|
|
96
99
|
- lib/rails-env.rb
|
|
97
100
|
- lib/rails-env/version.rb
|
|
98
101
|
- rails-env.gemspec
|