rails-env 1.0.5 → 2.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
- SHA1:
3
- metadata.gz: 090040b7adbed72a4e3cf77672bc5ab2d35d8cfd
4
- data.tar.gz: 7791272c42622b829b5b5d7a409b96f2b16b75f2
2
+ SHA256:
3
+ metadata.gz: ea802749d2e70a95ff81d1b0b0a1de144edd4e6832c7c82d2572f27261628f81
4
+ data.tar.gz: 8c145d8d22615140b8522e5cfdac2ad3b8306901d26d40827ac0e8a4025ba746
5
5
  SHA512:
6
- metadata.gz: fe41ee71ac13c65069d27a107c868dae6e895f0adfdb5856cc6f244d82c70e8f6f89bd17a952736d26173adaf71f49fd0acffed5cb737a04ecc26d87f9dc9a6d
7
- data.tar.gz: 1ed4c557662ce1858fd7414b0ad66b8613bac26981b904f484d4c1cb7e2a6715b3eed21942c34f3e9d2557db173b9d81b30fdaf847a62aba98efe3669a42be8b
6
+ metadata.gz: 7304f1800a93bb07c64c51c1bd514576935110bfda4d1a5121c81920076c14b1e5ba327d222deb8d689d647657c63b671d84ddcbaafff72b78bfc80a45c8f6a0
7
+ data.tar.gz: e00b9ac0a8c4dd4196709d042c8042afdb668ad1edb8714f0eb549405ad25a0fb07ff1a6a3a96eb38b4e88992cd4f479a40a28970d7895f0830ea0b201cdff50
@@ -0,0 +1,4 @@
1
+ # You can read more about CODEOWNERS at
2
+ # https://help.github.com/github/creating-cloning-and-archiving-repositories/about-code-owners
3
+
4
+ * @fnando
@@ -0,0 +1,4 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [fnando]
4
+ custom: ["https://paypal.me/nandovieira/🍕"]
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: "🐛 Bug Report"
3
+ about: Report a reproducible bug or regression.
4
+ title: 'Bug: '
5
+ labels: 'Status: Unconfirmed'
6
+
7
+ ---
8
+
9
+ <!--
10
+ - Please provide a clear and concise description of what the bug is.
11
+ - If possible, add an example reproducing your issue.
12
+ - Please test using the latest version of rails_env
13
+ to make sure your issue has not already been fixed.
14
+ -->
15
+
16
+ ## Description
17
+
18
+ [Add bug description here]
19
+
20
+ ## How to reproduce
21
+
22
+ [Add steps on how to reproduce this issue]
23
+
24
+ ## What do you expect
25
+
26
+ [Describe what do you expect to happen]
27
+
28
+ ## What happened instead
29
+
30
+ [Describe the actual results]
31
+
32
+ ## Software:
33
+
34
+ - Gem version: [Add gem version here]
35
+ - Ruby version: [Add version here]
36
+
37
+ ## Full backtrace
38
+
39
+ ```text
40
+ [Paste full backtrace here]
41
+ ```
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: "💡 Feature request"
3
+ about: Have an idea that may be useful? Make a suggestion!
4
+ title: 'Feature Request: '
5
+ labels: 'Feature request'
6
+
7
+ ---
8
+
9
+ ## Description
10
+
11
+ _A clear and concise description of what the problem is._
12
+
13
+ ## Describe the solution
14
+
15
+ _A clear and concise description of what you want to happen._
16
+
17
+ ## Alternatives you considered
18
+
19
+ _A clear and concise description of any alternative solutions or features you've considered._
20
+
21
+ ## Additional context
22
+
23
+ _Add any other context, screenshots, links, etc about the feature request here._
@@ -0,0 +1,38 @@
1
+ <!--
2
+ If you're making a doc PR or something tiny where the below is irrelevant,
3
+ delete this template and use a short description, but in your description aim to
4
+ include both what the change is, and why it is being made, with enough context
5
+ for anyone to understand.
6
+ -->
7
+
8
+ <details>
9
+ <summary>PR Checklist</summary>
10
+
11
+ ### PR Structure
12
+
13
+ - [ ] This PR has reasonably narrow scope (if not, break it down into smaller
14
+ PRs).
15
+ - [ ] This PR avoids mixing refactoring changes with feature changes (split into
16
+ two PRs otherwise).
17
+ - [ ] This PR's title starts is concise and descriptive.
18
+
19
+ ### Thoroughness
20
+
21
+ - [ ] This PR adds tests for the most critical parts of the new functionality or
22
+ fixes.
23
+ - [ ] I've updated any docs, `.md` files, etc… affected by this change.
24
+
25
+ </details>
26
+
27
+ ### What
28
+
29
+ [TODO: Short statement about what is changing.]
30
+
31
+ ### Why
32
+
33
+ [TODO: Why this change is being made. Include any context required to understand
34
+ the why.]
35
+
36
+ ### Known limitations
37
+
38
+ [TODO or N/A]
@@ -0,0 +1,15 @@
1
+ ---
2
+ # Documentation:
3
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
4
+
5
+ version: 2
6
+ updates:
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "daily"
11
+
12
+ - package-ecosystem: "bundler"
13
+ directory: "/"
14
+ schedule:
15
+ interval: "daily"
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: ruby-tests
3
+
4
+ on:
5
+ pull_request:
6
+ push:
7
+ workflow_dispatch:
8
+ inputs: {}
9
+
10
+ jobs:
11
+ build:
12
+ name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
13
+ runs-on: "ubuntu-latest"
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ ruby: [2.7.x, 3.0.x]
18
+ gemfile:
19
+ - Gemfile
20
+ - gemfiles/rails_7_0.gemfile
21
+ - gemfiles/rails_6_0.gemfile
22
+
23
+ steps:
24
+ - uses: actions/checkout@v2.4.0
25
+
26
+ - uses: actions/cache@v2.1.7
27
+ with:
28
+ path: vendor/bundle
29
+ key: >
30
+ ${{ runner.os }}-${{ matrix.ruby }}-gems-${{
31
+ hashFiles(matrix.gemfile) }}
32
+ restore-keys: >
33
+ ${{ runner.os }}-${{ matrix.ruby }}-gems-${{
34
+ hashFiles(matrix.gemfile) }}
35
+
36
+ - name: Set up Ruby
37
+ uses: actions/setup-ruby@v1.1.3
38
+ with:
39
+ ruby-version: ${{ matrix.ruby }}
40
+
41
+ - name: Install gem dependencies
42
+ env:
43
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
44
+ run: |
45
+ gem install bundler
46
+ bundle config path vendor/bundle
47
+ bundle update --jobs 4 --retry 3
48
+
49
+ - name: Run Tests
50
+ env:
51
+ PGHOST: localhost
52
+ PGUSER: postgres
53
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
54
+ run: |
55
+ bundle exec rake
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ gemfiles/*.lock
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ ---
2
+ inherit_gem:
3
+ rubocop-fnando: .rubocop.yml
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.7
7
+ NewCops: enable
8
+
9
+ Naming/FileName:
10
+ Exclude:
11
+ - lib/rails-env.rb
12
+
13
+ Metrics/AbcSize:
14
+ Enabled: false
15
+
16
+ Metrics/MethodLength:
17
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ <!--
4
+ Prefix your message with one of the following:
5
+
6
+ - [Added] for new features.
7
+ - [Changed] for changes in existing functionality.
8
+ - [Deprecated] for soon-to-be removed features.
9
+ - [Removed] for now removed features.
10
+ - [Fixed] for any bug fixes.
11
+ - [Security] in case of vulnerabilities.
12
+ -->
13
+
14
+ ## v2.0.0 - 2021-12-06
15
+
16
+ - [Fixed] Fix Rails 7 issues.
17
+ - [Changed] Drop support for Ruby 2.6 and older.
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at me@fnando.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,79 @@
1
+ # Contributing to rails_env
2
+
3
+ 👍🎉 First off, thanks for taking the time to contribute! 🎉👍
4
+
5
+ The following is a set of guidelines for contributing to this project. These are
6
+ mostly guidelines, not rules. Use your best judgment, and feel free to propose
7
+ changes to this document in a pull request.
8
+
9
+ ## Code of Conduct
10
+
11
+ Everyone interacting in this project's codebases, issue trackers, chat rooms and
12
+ mailing lists is expected to follow the [code of conduct](https://github.com/fnando/rails_env/blob/main/CODE_OF_CONDUCT.md).
13
+
14
+ ## Reporting bugs
15
+
16
+ This section guides you through submitting a bug report. Following these
17
+ guidelines helps maintainers and the community understand your report, reproduce
18
+ the behavior, and find related reports.
19
+
20
+ - Before creating bug reports, please check the open issues; somebody may
21
+ already have submitted something similar, and you may not need to create a new
22
+ one.
23
+ - When you are creating a bug report, please include as many details as
24
+ possible, with an example reproducing the issue.
25
+
26
+ ## Contributing with code
27
+
28
+ Before making any radicals changes, please make sure you discuss your intention
29
+ by [opening an issue on Github](https://github.com/fnando/rails_env/issues).
30
+
31
+ When you're ready to make your pull request, follow checklist below to make sure
32
+ your contribution is according to how this project works.
33
+
34
+ 1. [Fork](https://help.github.com/forking/) rails_env
35
+ 2. Create a topic branch - `git checkout -b my_branch`
36
+ 3. Make your changes using [descriptive commit messages](#commit-messages)
37
+ 4. Update CHANGELOG.md describing your changes by adding an entry to the
38
+ "Unreleased" section. If this section is not available, create one right
39
+ before the last version.
40
+ 5. Push to your branch - `git push origin my_branch`
41
+ 6. [Create a pull request](https://help.github.com/articles/creating-a-pull-request)
42
+ 7. That's it!
43
+
44
+ ## Styleguides
45
+
46
+ ### Commit messages
47
+
48
+ - Use the present tense ("Add feature" not "Added feature")
49
+ - Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
50
+ - Limit the first line to 72 characters or less
51
+ - Reference issues and pull requests liberally after the first line
52
+
53
+ ### Changelog
54
+
55
+ - Add a message describing your changes to the "Unreleased" section. The
56
+ changelog message should follow the same style as the commit message.
57
+ - Prefix your message with one of the following:
58
+ - `[Added]` for new features.
59
+ - `[Changed]` for changes in existing functionality.
60
+ - `[Deprecated]` for soon-to-be removed features.
61
+ - `[Removed]` for now removed features.
62
+ - `[Fixed]` for any bug fixes.
63
+ - `[Security]` in case of vulnerabilities.
64
+
65
+ ### Ruby code
66
+
67
+ - This project uses [Rubocop](https://rubocop.org) to enforce code style. Before
68
+ submitting your changes, make sure your tests are passing and code conforms to
69
+ the expected style by running `rake`.
70
+ - Do not change the library version. This will be done by the maintainer
71
+ whenever a new version is about to be released.
72
+
73
+ ### JavaScript code
74
+
75
+ - This project uses [ESLint](https://eslint.org) to enforce code style. Before
76
+ submitting your changes, make sure your tests are passing and code conforms to
77
+ the expected style by running `yarn test:ci`.
78
+ - Do not change the library version. This will be done by the maintainer
79
+ whenever a new version is about to be released.
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
 
3
- # Specify your gem's dependencies in rails-env.gemspec
4
5
  gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ # The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Nando Vieira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,20 +1,23 @@
1
1
  # rails-env
2
2
 
3
+ [![Tests](https://github.com/fnando/rails-env/workflows/ruby-tests/badge.svg)](https://github.com/fnando/rails-env)
4
+ [![Code Climate](https://codeclimate.com/github/fnando/rails-env/badges/gpa.svg)](https://codeclimate.com/github/fnando/rails-env)
5
+ [![Gem](https://img.shields.io/gem/v/rails-env.svg)](https://rubygems.org/gems/rails-env)
6
+ [![Gem](https://img.shields.io/gem/dt/rails-env.svg)](https://rubygems.org/gems/rails-env)
7
+
3
8
  Avoid environment detection on Rails.
4
9
 
5
10
  ## Installation
6
11
 
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'rails-env'
10
-
11
- And then execute:
12
-
13
- $ bundle
12
+ ```bash
13
+ gem install rails-env
14
+ ```
14
15
 
15
- Or install it yourself as:
16
+ Or add the following line to your project's Gemfile:
16
17
 
17
- $ gem install rails-env
18
+ ```ruby
19
+ gem "rails-env"
20
+ ```
18
21
 
19
22
  ## Usage
20
23
 
@@ -34,7 +37,9 @@ Rails.env.on(:production) do
34
37
  end
35
38
  ```
36
39
 
37
- Looks dumb, but you don't have to use the long `Rails.configuration` or assign it to a local variable. This is useful when you're extracting out things to initializers.
40
+ Looks dumb, but you don't have to use the long `Rails.configuration` or assign
41
+ it to a local variable. This is useful when you're extracting out things to
42
+ initializers.
38
43
 
39
44
  To match all environments, use `:any`.
40
45
 
@@ -44,9 +49,32 @@ Rails.env.on(:any) do
44
49
  end
45
50
  ```
46
51
 
52
+ ## Gotcha
53
+
54
+ Not all options can be defined through `Rails.env`. Rails propagates options on
55
+ its engine file, meaning that every option defined on `config` afterwards must
56
+ be manually propagated.
57
+
58
+ It's hard to automatically propagate every existing option, so we have the most
59
+ common options covered, as you can see in the list below:
60
+
61
+ - action_controller
62
+ - action_mailer
63
+ - action_view
64
+ - active_job
65
+ - active_record
66
+ - time_zone
67
+ - auto/eager load paths
68
+ - i18n
69
+ - hosts
70
+
71
+ If you need to set any option not covered by rails-env,
72
+ [please open a ticket](https://github.com/fnando/rails-env/issues/new).
73
+
47
74
  ## Upgrading from previous versions
48
75
 
49
- Previous versions used to yield the configuration; this is no longer true on 1.0+.
76
+ Previous versions used to yield the configuration; this is no longer true on
77
+ 1.0+.
50
78
 
51
79
  So, instead of using
52
80
 
@@ -64,10 +92,27 @@ Rails.env.on(:development) do
64
92
  end
65
93
  ```
66
94
 
95
+ ## Maintainer
96
+
97
+ - [Nando Vieira](https://github.com/fnando)
98
+
99
+ ## Contributors
100
+
101
+ - https://github.com/fnando/rails-env/contributors
102
+
67
103
  ## Contributing
68
104
 
69
- 1. Fork it ( https://github.com/fnando/rails-env/fork )
70
- 2. Create your feature branch (`git checkout -b my-new-feature`)
71
- 3. Commit your changes (`git commit -am 'Add some feature'`)
72
- 4. Push to the branch (`git push origin my-new-feature`)
73
- 5. Create a new Pull Request
105
+ For more details about how to contribute, please read
106
+ https://github.com/fnando/rails-env/blob/main/CONTRIBUTING.md.
107
+
108
+ ## License
109
+
110
+ The gem is available as open source under the terms of the
111
+ [MIT License](https://opensource.org/licenses/MIT). A copy of the license can be
112
+ found at https://github.com/fnando/rails-env/blob/main/LICENSE.md.
113
+
114
+ ## Code of Conduct
115
+
116
+ Everyone interacting in the rails-env project's codebases, issue trackers, chat
117
+ rooms and mailing lists is expected to follow the
118
+ [code of conduct](https://github.com/fnando/rails-env/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,10 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rake/testtask"
5
+ require "rubocop/rake_task"
3
6
 
4
7
  Rake::TestTask.new(:test) do |t|
5
- t.libs << 'test'
6
- t.test_files = FileList['test/**/*_test.rb']
7
- t.verbose = true
8
+ t.libs << "test"
9
+ t.libs << "lib"
10
+ t.test_files = FileList["test/**/*_test.rb"]
8
11
  end
9
12
 
10
- task :default => :test
13
+ RuboCop::RakeTask.new
14
+
15
+ task default: %i[test rubocop]
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ gemspec path: ".."
3
+
4
+ gem "rails", "~> 5.0.0"
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ gemspec path: ".."
3
+
4
+ gem "rails", "~> 5.2.0"
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ gemspec path: ".."
3
+
4
+ gem "rails", "~> 6.0.0.beta2"
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec path: ".."
5
+
6
+ gem "rails", "~> 7.0.0.alpha2"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsEnv
2
- VERSION = "1.0.5"
4
+ VERSION = "2.0.0"
3
5
  end
data/lib/rails-env.rb CHANGED
@@ -1,11 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rails-env/version"
2
4
 
3
5
  module Rails
4
6
  class << self
5
7
  env_method = instance_method(:env=)
8
+ remove_method(:env=)
6
9
 
7
10
  define_method :env= do |env|
8
- env_method.bind(self).call(env)
11
+ env_method.bind_call(self, env)
9
12
  Rails.env.extend(RailsEnv::Extension)
10
13
  end
11
14
  end
@@ -29,19 +32,56 @@ module RailsEnv
29
32
  propagate(:active_job, "::ActiveJob::Base")
30
33
  propagate(:active_record, "::ActiveRecord::Base")
31
34
  propagate(:time_zone, "::Time", :zone)
35
+ propagate_hosts
36
+ propagate_autoload_paths
32
37
  propagate_i18n
38
+ propagate_cache_store
39
+ end
40
+
41
+ def self.propagate_cache_store
42
+ Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store)
43
+ end
44
+
45
+ def self.propagate_hosts
46
+ Rails.application.config.hosts = config.hosts
33
47
  end
34
48
 
35
49
  def self.propagate_i18n
36
50
  I18n.available_locales = (config.i18n.available_locales || [])
37
- .compact
38
- .map(&:to_sym)
39
- .uniq
40
- I18n.default_locale = config.i18n.default_locale if config.i18n.default_locale
51
+ .compact
52
+ .map(&:to_sym)
53
+ .uniq
54
+
55
+ if config.i18n.default_locale
56
+ I18n.default_locale = config.i18n.default_locale
57
+ end
58
+
59
+ if config.i18n.respond_to?(:raise_on_missing_translations)
60
+ ActionView::Base.raise_on_missing_translations =
61
+ config.i18n.raise_on_missing_translations
62
+ end
63
+
41
64
  I18n.locale = config.i18n.locale if config.i18n.locale
42
65
  I18n.load_path += config.i18n.load_path if config.i18n.load_path
43
66
  end
44
67
 
68
+ def self.propagate_autoload_paths
69
+ all_autoload_paths = (
70
+ config.autoload_paths +
71
+ config.eager_load_paths +
72
+ config.autoload_once_paths +
73
+ ActiveSupport::Dependencies.autoload_paths
74
+ ).uniq.freeze
75
+
76
+ all_autoload_once_paths = (
77
+ config.autoload_once_paths +
78
+ ActiveSupport::Dependencies.autoload_once_paths
79
+ ).uniq.freeze
80
+
81
+ ActiveSupport::Dependencies.autoload_paths = all_autoload_paths
82
+ ActiveSupport::Dependencies.autoload_once_paths = all_autoload_once_paths
83
+ end
84
+
45
85
  def self.propagate(options_name, target_name, target_property = nil)
46
86
  return unless Object.const_defined?(target_name)
47
87
  return unless config.respond_to?(options_name)
@@ -49,7 +89,7 @@ module RailsEnv
49
89
  target = Object.const_get(target_name)
50
90
  options = config.public_send(options_name)
51
91
 
52
- if options.is_a?(Enumerable)
92
+ if options.is_a?(Hash)
53
93
  options.each do |key, value|
54
94
  target.public_send("#{key}=", value) if target.respond_to?("#{key}=")
55
95
  end
data/rails-env.gemspec CHANGED
@@ -1,23 +1,46 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "./lib/rails-env/version"
2
4
 
3
5
  Gem::Specification.new do |spec|
4
- spec.name = "rails-env"
5
- spec.version = RailsEnv::VERSION
6
- spec.authors = ["Nando Vieira"]
7
- spec.email = ["fnando.vieira@gmail.com"]
8
- spec.summary = "Avoid environment detection on Rails"
9
- spec.description = spec.summary
10
- spec.homepage = "https://github.com/fnando/rails-env"
11
- spec.license = "MIT"
12
-
13
- spec.files = `git ls-files -z`.split("\x0")
14
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
6
+ spec.name = "rails-env"
7
+ spec.version = RailsEnv::VERSION
8
+ spec.authors = ["Nando Vieira"]
9
+ spec.email = ["me@fnando.com"]
10
+ spec.metadata = {"rubygems_mfa_required" => "true"}
11
+
12
+ spec.summary = "Avoid environment detection on Rails"
13
+ spec.description = spec.summary
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
16
+
17
+ github_url = "https://github.com/fnando/rails_env"
18
+ github_tree_url = "#{github_url}/tree/v#{spec.version}"
19
+
20
+ spec.homepage = github_url
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["bug_tracker_uri"] = "#{github_url}/issues"
23
+ spec.metadata["source_code_uri"] = github_tree_url
24
+ spec.metadata["changelog_uri"] = "#{github_tree_url}/CHANGELOG.md"
25
+ spec.metadata["documentation_uri"] = "#{github_tree_url}/README.md"
26
+ spec.metadata["license_uri"] = "#{github_tree_url}/LICENSE.md"
27
+
28
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
29
+ `git ls-files -z`
30
+ .split("\x0")
31
+ .reject {|f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
16
36
  spec.require_paths = ["lib"]
17
37
 
18
- spec.add_development_dependency "bundler", "~> 1.6"
38
+ spec.add_development_dependency "minitest"
39
+ spec.add_development_dependency "minitest-utils"
40
+ spec.add_development_dependency "pry-meta"
19
41
  spec.add_development_dependency "rails"
20
42
  spec.add_development_dependency "rake"
21
- spec.add_development_dependency "pry-meta"
22
- spec.add_development_dependency "minitest-utils"
43
+ spec.add_development_dependency "rubocop"
44
+ spec.add_development_dependency "rubocop-fnando"
45
+ spec.add_development_dependency "simplecov"
23
46
  end
metadata CHANGED
@@ -1,29 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
- autorequire:
9
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-06 00:00:00.000000000 Z
11
+ date: 2021-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest-utils
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry-meta
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
18
46
  - !ruby/object:Gem::Version
19
- version: '1.6'
47
+ version: '0'
20
48
  type: :development
21
49
  prerelease: false
22
50
  version_requirements: !ruby/object:Gem::Requirement
23
51
  requirements:
24
- - - "~>"
52
+ - - ">="
25
53
  - !ruby/object:Gem::Version
26
- version: '1.6'
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rails
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +81,7 @@ dependencies:
53
81
  - !ruby/object:Gem::Version
54
82
  version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
- name: pry-meta
84
+ name: rubocop
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - ">="
@@ -67,7 +95,21 @@ dependencies:
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
- name: minitest-utils
98
+ name: rubocop-fnando
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
115
  - - ">="
@@ -82,28 +124,46 @@ dependencies:
82
124
  version: '0'
83
125
  description: Avoid environment detection on Rails
84
126
  email:
85
- - fnando.vieira@gmail.com
127
+ - me@fnando.com
86
128
  executables: []
87
129
  extensions: []
88
130
  extra_rdoc_files: []
89
131
  files:
132
+ - ".github/CODEOWNERS"
133
+ - ".github/FUNDING.yml"
134
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
135
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
136
+ - ".github/PULL_REQUEST_TEMPLATE.md"
137
+ - ".github/dependabot.yml"
138
+ - ".github/workflows/ruby-tests.yml"
90
139
  - ".gitignore"
91
- - ".rspec"
140
+ - ".rubocop.yml"
141
+ - CHANGELOG.md
142
+ - CODE_OF_CONDUCT.md
143
+ - CONTRIBUTING.md
92
144
  - Gemfile
93
- - LICENSE.txt
145
+ - LICENSE.md
94
146
  - README.md
95
147
  - Rakefile
148
+ - gemfiles/rails_5_0.gemfile
149
+ - gemfiles/rails_5_2.gemfile
150
+ - gemfiles/rails_6_0.gemfile
151
+ - gemfiles/rails_7_0.gemfile
96
152
  - lib/rails-env.rb
97
153
  - lib/rails-env/version.rb
98
154
  - rails-env.gemspec
99
- - test/test_helper.rb
100
- - test/unit/rails_env_test.rb
101
- - test/unit/rails_test.rb
102
- homepage: https://github.com/fnando/rails-env
155
+ homepage: https://github.com/fnando/rails_env
103
156
  licenses:
104
157
  - MIT
105
- metadata: {}
106
- post_install_message:
158
+ metadata:
159
+ rubygems_mfa_required: 'true'
160
+ homepage_uri: https://github.com/fnando/rails_env
161
+ bug_tracker_uri: https://github.com/fnando/rails_env/issues
162
+ source_code_uri: https://github.com/fnando/rails_env/tree/v2.0.0
163
+ changelog_uri: https://github.com/fnando/rails_env/tree/v2.0.0/CHANGELOG.md
164
+ documentation_uri: https://github.com/fnando/rails_env/tree/v2.0.0/README.md
165
+ license_uri: https://github.com/fnando/rails_env/tree/v2.0.0/LICENSE.md
166
+ post_install_message:
107
167
  rdoc_options: []
108
168
  require_paths:
109
169
  - lib
@@ -111,19 +171,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
171
  requirements:
112
172
  - - ">="
113
173
  - !ruby/object:Gem::Version
114
- version: '0'
174
+ version: 2.7.0
115
175
  required_rubygems_version: !ruby/object:Gem::Requirement
116
176
  requirements:
117
177
  - - ">="
118
178
  - !ruby/object:Gem::Version
119
179
  version: '0'
120
180
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.5.1
123
- signing_key:
181
+ rubygems_version: 3.2.32
182
+ signing_key:
124
183
  specification_version: 4
125
184
  summary: Avoid environment detection on Rails
126
- test_files:
127
- - test/test_helper.rb
128
- - test/unit/rails_env_test.rb
129
- - test/unit/rails_test.rb
185
+ test_files: []
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014 Nando Vieira
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/test/test_helper.rb DELETED
@@ -1,17 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
-
3
- require "bundler/setup"
4
- require "rails"
5
- require "action_mailer/railtie"
6
- require "action_view/railtie"
7
- require "active_job/railtie"
8
- require "rails-env"
9
-
10
- require "minitest/utils"
11
- require "minitest/autorun"
12
-
13
- class DummyApp < Rails::Application
14
- config.eager_load = false
15
- end
16
-
17
- Rails.application.initialize!
@@ -1,43 +0,0 @@
1
- require "test_helper"
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
-
15
- class RailsEnvTest < Minitest::Test
16
- test "runs block when env matches" do
17
- block = Callable.new
18
- Rails.env.on(:test, &block)
19
-
20
- assert_equal Rails.configuration, block.configuration
21
- end
22
-
23
- test "matches against multiple envs" do
24
- block = Callable.new
25
- Rails.env.on(:development, :test, &block)
26
-
27
- assert_equal Rails.configuration, block.configuration
28
- end
29
-
30
- test "skips block when env differs" do
31
- block = Callable.new
32
- Rails.env.on(:production, &block)
33
-
34
- assert_nil block.configuration
35
- end
36
-
37
- test "runs on any environment" do
38
- block = Callable.new
39
- Rails.env.on(:any, &block)
40
-
41
- assert_equal Rails.configuration, block.configuration
42
- end
43
- end
@@ -1,54 +0,0 @@
1
- require "test_helper"
2
-
3
- class ConfigPropagationTest < Minitest::Test
4
- setup 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
- config.action_view.raise_on_missing_translations = true
13
- config.active_job.queue_adapter = :test
14
- end
15
- end
16
-
17
- test "assigns extended environment" do
18
- Rails.env = "test"
19
- assert Rails.env.respond_to?(:on)
20
- end
21
-
22
- test "sets url options" do
23
- assert_equal "localhost", ActionMailer::Base.default_url_options[:host]
24
- assert_equal 3000, ActionMailer::Base.default_url_options[:port]
25
- end
26
-
27
- test "sets raise option" do
28
- assert ActionMailer::Base.raise_delivery_errors
29
- end
30
-
31
- test "sets delivery method" do
32
- assert_equal :letter_opener, ActionMailer::Base.delivery_method
33
- end
34
-
35
- test "sets timezone" do
36
- assert_equal "America/Sao_Paulo", Time.zone.name
37
- end
38
-
39
- test "sets locale" do
40
- assert_equal :"pt-BR", I18n.locale
41
- end
42
-
43
- test "sets available locales" do
44
- assert_equal [:"pt-BR"], I18n.available_locales
45
- end
46
-
47
- test "sets raise on missing translations" do
48
- assert ActionView::Base.raise_on_missing_translations
49
- end
50
-
51
- test "sets queue adapter" do
52
- assert_kind_of ActiveJob::QueueAdapters::TestAdapter, ActiveJob::Base.queue_adapter
53
- end
54
- end