rails-env 1.0.0 → 1.0.1
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/lib/rails-env.rb +25 -0
- data/lib/rails-env/version.rb +1 -1
- data/spec/rails_spec.rb +38 -0
- data/spec/spec_helper.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54be7bfad6d607eb1031afc41ebd006000b28ccd
|
4
|
+
data.tar.gz: 7008dff976d48c3a821d6ee4ae97c6c111ffdc60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fa0ca1dbe54d9d6b98b22096be6f5c9c7624121b177016b57ff2509140c628b44fddf3d3366b5fb77bc1f99b63a8ac8cdfc27e28ccc1156b867b1a49778006c
|
7
|
+
data.tar.gz: da0fdf44a876a8100ea0cdb69ddf1cfe315ec95040553686ca31794cb7d9557737c833fe97a40213df50a4deb1e17152d0f15d8beb553371b2bf53e8181f1c89
|
data/lib/rails-env.rb
CHANGED
@@ -7,10 +7,35 @@ module RailsEnv
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
def self.propagate_configuration!
|
11
|
+
propagate(:action_mailer, '::ActionMailer::Base')
|
12
|
+
propagate(:active_record, '::ActiveRecord::Base')
|
13
|
+
propagate(:active_job, '::ActiveJob::Base')
|
14
|
+
propagate(:time_zone, '::Time', :zone)
|
15
|
+
propagate(:i18n, '::I18n')
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.propagate(options_name, target_name, target_property = nil)
|
19
|
+
return unless Object.const_defined?(target_name)
|
20
|
+
return unless Rails.configuration.respond_to?(options_name)
|
21
|
+
|
22
|
+
target = Object.const_get(target_name)
|
23
|
+
options = Rails.configuration.public_send(options_name)
|
24
|
+
|
25
|
+
if options.kind_of?(Enumerable)
|
26
|
+
options.each do |key, value|
|
27
|
+
target.public_send("#{key}=", value) if target.respond_to?("#{key}=")
|
28
|
+
end
|
29
|
+
else
|
30
|
+
target.public_send("#{target_property}=", options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
10
34
|
module Extension
|
11
35
|
def on(*envs, &block)
|
12
36
|
env_matched = envs.include?(:any) || envs.include?(Rails.env.to_sym)
|
13
37
|
Rails.application.configure(&block) if env_matched
|
38
|
+
RailsEnv.propagate_configuration!
|
14
39
|
end
|
15
40
|
end
|
16
41
|
end
|
data/lib/rails-env/version.rb
CHANGED
data/spec/rails_spec.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RailsEnv, '::ActionMailer' do
|
4
|
+
before do
|
5
|
+
Rails.env.on(:test) do
|
6
|
+
config.action_mailer.default_url_options = {host: 'localhost', port: 3000}
|
7
|
+
config.action_mailer.raise_delivery_errors = true
|
8
|
+
config.action_mailer.delivery_method = :letter_opener
|
9
|
+
config.time_zone = 'America/Sao_Paulo'
|
10
|
+
config.i18n.available_locales = ['pt-BR']
|
11
|
+
config.i18n.default_locale = 'pt-BR'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'sets url options' do
|
16
|
+
expect(ActionMailer::Base.default_url_options).to include(host: 'localhost', port: 3000)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'sets raise option' do
|
20
|
+
expect(ActionMailer::Base.raise_delivery_errors).to be_truthy
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'sets delivery method' do
|
24
|
+
expect(ActionMailer::Base.delivery_method).to eq(:letter_opener)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'sets timezone' do
|
28
|
+
expect(Time.zone.name).to eq('America/Sao_Paulo')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'sets locale' do
|
32
|
+
expect(I18n.locale).to eq(:'pt-BR')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'sets available locales' do
|
36
|
+
expect(I18n.available_locales).to eq([:'pt-BR'])
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
CHANGED
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: 1.0.
|
4
|
+
version: 1.0.1
|
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-
|
11
|
+
date: 2015-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/rails-env/version.rb
|
98
98
|
- rails-env.gemspec
|
99
99
|
- spec/rails-env_spec.rb
|
100
|
+
- spec/rails_spec.rb
|
100
101
|
- spec/spec_helper.rb
|
101
102
|
homepage: https://github.com/fnando/rails-env
|
102
103
|
licenses:
|
@@ -118,10 +119,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
119
|
version: '0'
|
119
120
|
requirements: []
|
120
121
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.4.
|
122
|
+
rubygems_version: 2.4.5.1
|
122
123
|
signing_key:
|
123
124
|
specification_version: 4
|
124
125
|
summary: Avoid environment detection on Rails
|
125
126
|
test_files:
|
126
127
|
- spec/rails-env_spec.rb
|
128
|
+
- spec/rails_spec.rb
|
127
129
|
- spec/spec_helper.rb
|