rails-env 1.0.6 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ce82d44b07a02c08c130d1017570eeca3b1aa96a
4
- data.tar.gz: 59bd44ea9ae33fc99450521f257fc2c26cdbb4ae
2
+ SHA256:
3
+ metadata.gz: e00ec34d2254078e3667c53a347d45fad7dcec20bdbcfd0f059cfaaff238c845
4
+ data.tar.gz: 899f3078f18680bd4f854edff0026ff47a31696022a387fd590d366e2eac460e
5
5
  SHA512:
6
- metadata.gz: c3a1fdd95cdb42bce025a436e5c4ce81a6f55d6912d9bc679cda58b9caca68ed6e014487e659ab96d045d6429194635c7c84a77c84d03853bee41240929377c3
7
- data.tar.gz: e146a9f72d26c5bc3a79bb5b82d04a4729928ca262fc7b4869324ffeabf47628170ec3c7eee0f1ac8dfc85a5ad34a5fd298125c537095ee35955e86f93812fd6
6
+ metadata.gz: e1c11390634eb183f2fa38e87c9b5f395484691bf7bd4cbbea6b0715eda5f531ba0c4c963e9934c3a7b4d376a8259e3ff927595323ebf3c78553f9965c3157be
7
+ data.tar.gz: 4a4f99bdab25e0a9b02cc588350d81ab6ea877da83531438f369ca0e2a94d10a55a0e10eec9892ede28a785a819190850f0153a0dd9c024ec44b0c98235dc061
@@ -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/.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,22 @@
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.1 - 2021-12-11
15
+
16
+ - [Fixed] Rails 7 was raising an exception because
17
+ `ActionView::Base.raise_on_missing_translations` is not a thing anymore.
18
+
19
+ ## v2.0.0 - 2021-12-06
20
+
21
+ - [Fixed] Fix Rails 7 issues.
22
+ - [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,24 +1,23 @@
1
1
  # rails-env
2
2
 
3
- [![Build Status](https://travis-ci.org/fnando/rails-env.svg)](https://travis-ci.org/fnando/rails-env)
4
- [![Code Climate](https://codeclimate.com/github/fnando/rails-env.png)](https://codeclimate.com/github/fnando/rails-env)
5
- [![Gem Version](https://badge.fury.io/rb/rails-env.svg)](http://badge.fury.io/rb/rails-env)
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)
6
7
 
7
8
  Avoid environment detection on Rails.
8
9
 
9
10
  ## Installation
10
11
 
11
- Add this line to your application's Gemfile:
12
-
13
- gem 'rails-env'
14
-
15
- And then execute:
16
-
17
- $ bundle
12
+ ```bash
13
+ gem install rails-env
14
+ ```
18
15
 
19
- Or install it yourself as:
16
+ Or add the following line to your project's Gemfile:
20
17
 
21
- $ gem install rails-env
18
+ ```ruby
19
+ gem "rails-env"
20
+ ```
22
21
 
23
22
  ## Usage
24
23
 
@@ -38,7 +37,9 @@ Rails.env.on(:production) do
38
37
  end
39
38
  ```
40
39
 
41
- 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.
42
43
 
43
44
  To match all environments, use `:any`.
44
45
 
@@ -50,9 +51,12 @@ end
50
51
 
51
52
  ## Gotcha
52
53
 
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
+ 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.
54
57
 
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:
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:
56
60
 
57
61
  - action_controller
58
62
  - action_mailer
@@ -62,12 +66,15 @@ It's hard to automatically propagate every existing option, so we have the most
62
66
  - time_zone
63
67
  - auto/eager load paths
64
68
  - i18n
69
+ - hosts
65
70
 
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).
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).
67
73
 
68
74
  ## Upgrading from previous versions
69
75
 
70
- 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+.
71
78
 
72
79
  So, instead of using
73
80
 
@@ -85,10 +92,27 @@ Rails.env.on(:development) do
85
92
  end
86
93
  ```
87
94
 
95
+ ## Maintainer
96
+
97
+ - [Nando Vieira](https://github.com/fnando)
98
+
99
+ ## Contributors
100
+
101
+ - https://github.com/fnando/rails-env/contributors
102
+
88
103
  ## Contributing
89
104
 
90
- 1. Fork it ( https://github.com/fnando/rails-env/fork )
91
- 2. Create your feature branch (`git checkout -b my-new-feature`)
92
- 3. Commit your changes (`git commit -am 'Add some feature'`)
93
- 4. Push to the branch (`git push origin my-new-feature`)
94
- 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]
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
  gemspec path: ".."
3
3
 
4
- gem "rails", "~> 5.0.0.beta3"
4
+ gem "rails", "~> 5.0.0"
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
  gemspec path: ".."
3
3
 
4
- gem "rails", "~> 4.2.5"
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.rc1"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsEnv
2
- VERSION = "1.0.6"
4
+ VERSION = "2.0.1"
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,16 +32,37 @@ 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
32
36
  propagate_autoload_paths
33
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
34
47
  end
35
48
 
36
49
  def self.propagate_i18n
37
50
  I18n.available_locales = (config.i18n.available_locales || [])
38
- .compact
39
- .map(&:to_sym)
40
- .uniq
41
- 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
+ with_rails_constraint("< 7.0.0") do
60
+ if config.i18n.respond_to?(:raise_on_missing_translations)
61
+ ActionView::Base.raise_on_missing_translations =
62
+ config.i18n.raise_on_missing_translations
63
+ end
64
+ end
65
+
42
66
  I18n.locale = config.i18n.locale if config.i18n.locale
43
67
  I18n.load_path += config.i18n.load_path if config.i18n.load_path
44
68
  end
@@ -47,11 +71,17 @@ module RailsEnv
47
71
  all_autoload_paths = (
48
72
  config.autoload_paths +
49
73
  config.eager_load_paths +
50
- config.autoload_once_paths
51
- ).uniq
74
+ config.autoload_once_paths +
75
+ ActiveSupport::Dependencies.autoload_paths
76
+ ).uniq.freeze
52
77
 
53
- ActiveSupport::Dependencies.autoload_paths.unshift(*all_autoload_paths)
54
- ActiveSupport::Dependencies.autoload_once_paths.unshift(*config.autoload_once_paths)
78
+ all_autoload_once_paths = (
79
+ config.autoload_once_paths +
80
+ ActiveSupport::Dependencies.autoload_once_paths
81
+ ).uniq.freeze
82
+
83
+ ActiveSupport::Dependencies.autoload_paths = all_autoload_paths
84
+ ActiveSupport::Dependencies.autoload_once_paths = all_autoload_once_paths
55
85
  end
56
86
 
57
87
  def self.propagate(options_name, target_name, target_property = nil)
@@ -70,6 +100,12 @@ module RailsEnv
70
100
  end
71
101
  end
72
102
 
103
+ def self.with_rails_constraint(constraint)
104
+ Gem::Requirement
105
+ .create(constraint)
106
+ .satisfied_by?(Gem::Version.create(Rails::VERSION::STRING))
107
+ end
108
+
73
109
  module Extension
74
110
  def on(*envs, &block)
75
111
  env_matched = envs.include?(:any) || envs.include?(Rails.env.to_sym)
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.6
4
+ version: 2.0.1
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-11 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,31 +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"
92
- - ".travis.yml"
140
+ - ".rubocop.yml"
141
+ - CHANGELOG.md
142
+ - CODE_OF_CONDUCT.md
143
+ - CONTRIBUTING.md
93
144
  - Gemfile
94
- - LICENSE.txt
145
+ - LICENSE.md
95
146
  - README.md
96
147
  - Rakefile
97
- - gemfiles/rails_4_2.gemfile
98
148
  - gemfiles/rails_5_0.gemfile
149
+ - gemfiles/rails_5_2.gemfile
150
+ - gemfiles/rails_6_0.gemfile
151
+ - gemfiles/rails_7_0.gemfile
99
152
  - lib/rails-env.rb
100
153
  - lib/rails-env/version.rb
101
154
  - rails-env.gemspec
102
- - test/test_helper.rb
103
- - test/unit/rails_env_test.rb
104
- - test/unit/rails_test.rb
105
- homepage: https://github.com/fnando/rails-env
155
+ homepage: https://github.com/fnando/rails_env
106
156
  licenses:
107
157
  - MIT
108
- metadata: {}
109
- 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.1
163
+ changelog_uri: https://github.com/fnando/rails_env/tree/v2.0.1/CHANGELOG.md
164
+ documentation_uri: https://github.com/fnando/rails_env/tree/v2.0.1/README.md
165
+ license_uri: https://github.com/fnando/rails_env/tree/v2.0.1/LICENSE.md
166
+ post_install_message:
110
167
  rdoc_options: []
111
168
  require_paths:
112
169
  - lib
@@ -114,19 +171,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
171
  requirements:
115
172
  - - ">="
116
173
  - !ruby/object:Gem::Version
117
- version: '0'
174
+ version: 2.7.0
118
175
  required_rubygems_version: !ruby/object:Gem::Requirement
119
176
  requirements:
120
177
  - - ">="
121
178
  - !ruby/object:Gem::Version
122
179
  version: '0'
123
180
  requirements: []
124
- rubyforge_project:
125
- rubygems_version: 2.5.1
126
- signing_key:
181
+ rubygems_version: 3.2.32
182
+ signing_key:
127
183
  specification_version: 4
128
184
  summary: Avoid environment detection on Rails
129
- test_files:
130
- - test/test_helper.rb
131
- - test/unit/rails_env_test.rb
132
- - test/unit/rails_test.rb
185
+ test_files: []
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- sudo: false
2
- cache: bundler
3
- rvm:
4
- - "2.2.4"
5
- - "2.3.0"
6
- script: bundle exec rake
7
- gemfile:
8
- - gemfiles/rails_4_2.gemfile
9
- - gemfiles/rails_5_0.gemfile
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,18 +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 "action_controller/railtie"
8
- require "active_job/railtie"
9
- require "rails-env"
10
-
11
- require "minitest/utils"
12
- require "minitest/autorun"
13
-
14
- class DummyApp < Rails::Application
15
- config.eager_load = false
16
- end
17
-
18
- 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,68 +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
-
15
- config.autoload_paths += ["#{__dir__}/al"]
16
- config.autoload_once_paths += ["#{__dir__}/alo"]
17
- config.eager_load_paths += ["#{__dir__}/el"]
18
- end
19
- end
20
-
21
- test "assigns extended environment" do
22
- Rails.env = "test"
23
- assert Rails.env.respond_to?(:on)
24
- end
25
-
26
- test "sets url options" do
27
- assert_equal "localhost", ActionMailer::Base.default_url_options[:host]
28
- assert_equal 3000, ActionMailer::Base.default_url_options[:port]
29
- end
30
-
31
- test "sets raise option" do
32
- assert ActionMailer::Base.raise_delivery_errors
33
- end
34
-
35
- test "sets delivery method" do
36
- assert_equal :letter_opener, ActionMailer::Base.delivery_method
37
- end
38
-
39
- test "sets timezone" do
40
- assert_equal "America/Sao_Paulo", Time.zone.name
41
- end
42
-
43
- test "sets locale" do
44
- assert_equal :"pt-BR", I18n.locale
45
- end
46
-
47
- test "sets available locales" do
48
- assert_equal [:"pt-BR"], I18n.available_locales
49
- end
50
-
51
- test "sets raise on missing translations" do
52
- assert ActionView::Base.raise_on_missing_translations
53
- end
54
-
55
- test "sets queue adapter" do
56
- assert_kind_of ActiveJob::QueueAdapters::TestAdapter, ActiveJob::Base.queue_adapter
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
68
- end