rails-env 1.0.7 → 2.0.2

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
  SHA256:
3
- metadata.gz: 7e72c42892865678652da90b743fa7ef787d095bcd976c79fc5148bb259a739f
4
- data.tar.gz: d7d29c1d0635bc94334abeb16202b43f6dbf743a801cd88d24301a7c8a174391
3
+ metadata.gz: ce003b00f171ed3cf0d04345adfaf1cde619fd0e99cbc913ca57015344c4686b
4
+ data.tar.gz: 2532b5358fbeb054778349e852baba9a8689de98339813038fb4cbe192dff6b5
5
5
  SHA512:
6
- metadata.gz: c258025d142d75c9b2e5bf1d55c00b6027ea73e57ce72921dcda6f03a0e98101df91c85da246e406b5e368dd1d7483b7581321a7654e632d13a406469d79897e
7
- data.tar.gz: ff87c0443b930254040cff1b5a68b6f4ef50a98509510c0ad5abee912b04ac3b285f69229879edda0eb87d7e550e8359485509f8209f749d3e04654b640c9b2f
6
+ metadata.gz: 0e18cd47c8f8637dc39235043bd83e13861d5585cddfb86ba3dc13934ed9de10739dbb27fb40f3e140d2e312c6e04570c25513716a1793284a55454b43d76590
7
+ data.tar.gz: 77a8797ca01accd1302f6866c1253915450a6b14f52284101e67590750b7928bb397beb555abae2bdb1a230504f04ec15bec226baa62947154614143ba8416f5
@@ -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,56 @@
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_1.gemfile
22
+ - gemfiles/rails_6_0.gemfile
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2.4.0
26
+
27
+ - uses: actions/cache@v2.1.7
28
+ with:
29
+ path: vendor/bundle
30
+ key: >
31
+ ${{ runner.os }}-${{ matrix.ruby }}-gems-${{
32
+ hashFiles(matrix.gemfile) }}
33
+ restore-keys: >
34
+ ${{ runner.os }}-${{ matrix.ruby }}-gems-${{
35
+ hashFiles(matrix.gemfile) }}
36
+
37
+ - name: Set up Ruby
38
+ uses: actions/setup-ruby@v1.1.3
39
+ with:
40
+ ruby-version: ${{ matrix.ruby }}
41
+
42
+ - name: Install gem dependencies
43
+ env:
44
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
45
+ run: |
46
+ gem install bundler
47
+ bundle config path vendor/bundle
48
+ bundle update --jobs 4 --retry 3
49
+
50
+ - name: Run Tests
51
+ env:
52
+ PGHOST: localhost
53
+ PGUSER: postgres
54
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
55
+ run: |
56
+ 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,26 @@
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
+ ## Unreleased
15
+
16
+ - [Fixed] Fix ActiveRecord 7 deprecation warnings.
17
+
18
+ ## v2.0.1 - 2021-12-11
19
+
20
+ - [Fixed] Rails 7 was raising an exception because
21
+ `ActionView::Base.raise_on_missing_translations` is not a thing anymore.
22
+
23
+ ## v2.0.0 - 2021-12-06
24
+
25
+ - [Fixed] Fix Rails 7 issues.
26
+ - [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,8 +1,7 @@
1
1
  # rails-env
2
2
 
3
- [![Travis-CI](https://travis-ci.org/fnando/rails-env.png)](https://travis-ci.org/fnando/rails-env)
3
+ [![Tests](https://github.com/fnando/rails-env/workflows/ruby-tests/badge.svg)](https://github.com/fnando/rails-env)
4
4
  [![Code Climate](https://codeclimate.com/github/fnando/rails-env/badges/gpa.svg)](https://codeclimate.com/github/fnando/rails-env)
5
- [![Test Coverage](https://codeclimate.com/github/fnando/rails-env/badges/coverage.svg)](https://codeclimate.com/github/fnando/rails-env/coverage)
6
5
  [![Gem](https://img.shields.io/gem/v/rails-env.svg)](https://rubygems.org/gems/rails-env)
7
6
  [![Gem](https://img.shields.io/gem/dt/rails-env.svg)](https://rubygems.org/gems/rails-env)
8
7
 
@@ -10,17 +9,15 @@ Avoid environment detection on Rails.
10
9
 
11
10
  ## Installation
12
11
 
13
- Add this line to your application's Gemfile:
14
-
15
- gem 'rails-env'
16
-
17
- And then execute:
18
-
19
- $ bundle
12
+ ```bash
13
+ gem install rails-env
14
+ ```
20
15
 
21
- Or install it yourself as:
16
+ Or add the following line to your project's Gemfile:
22
17
 
23
- $ gem install rails-env
18
+ ```ruby
19
+ gem "rails-env"
20
+ ```
24
21
 
25
22
  ## Usage
26
23
 
@@ -40,7 +37,9 @@ Rails.env.on(:production) do
40
37
  end
41
38
  ```
42
39
 
43
- 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.
44
43
 
45
44
  To match all environments, use `:any`.
46
45
 
@@ -52,9 +51,12 @@ end
52
51
 
53
52
  ## Gotcha
54
53
 
55
- 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.
56
57
 
57
- 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:
58
60
 
59
61
  - action_controller
60
62
  - action_mailer
@@ -64,12 +66,15 @@ It's hard to automatically propagate every existing option, so we have the most
64
66
  - time_zone
65
67
  - auto/eager load paths
66
68
  - i18n
69
+ - hosts
67
70
 
68
- 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).
69
73
 
70
74
  ## Upgrading from previous versions
71
75
 
72
- 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+.
73
78
 
74
79
  So, instead of using
75
80
 
@@ -87,10 +92,27 @@ Rails.env.on(:development) do
87
92
  end
88
93
  ```
89
94
 
95
+ ## Maintainer
96
+
97
+ - [Nando Vieira](https://github.com/fnando)
98
+
99
+ ## Contributors
100
+
101
+ - https://github.com/fnando/rails-env/contributors
102
+
90
103
  ## Contributing
91
104
 
92
- 1. Fork it ( https://github.com/fnando/rails-env/fork )
93
- 2. Create your feature branch (`git checkout -b my-new-feature`)
94
- 3. Commit your changes (`git commit -am 'Add some feature'`)
95
- 4. Push to the branch (`git push origin my-new-feature`)
96
- 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,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec path: ".."
5
+
6
+ gem "rails", "~> 6.1.0"
@@ -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.7"
4
+ VERSION = "2.0.2"
3
5
  end
data/lib/rails-env.rb CHANGED
@@ -1,17 +1,24 @@
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
12
15
  end
13
16
 
14
17
  module RailsEnv
18
+ def self.deprecations
19
+ @deprecations ||= []
20
+ end
21
+
15
22
  class Railtie < Rails::Railtie
16
23
  initializer "rails-env" do
17
24
  Rails.env.extend(Extension)
@@ -27,8 +34,17 @@ module RailsEnv
27
34
  propagate(:action_mailer, "::ActionMailer::Base")
28
35
  propagate(:action_view, "::ActionView::Base")
29
36
  propagate(:active_job, "::ActiveJob::Base")
30
- propagate(:active_record, "::ActiveRecord::Base")
37
+
38
+ with_rails_constraint("< 7.0.0") do
39
+ propagate(:active_record, "::ActiveRecord::Base")
40
+ end
41
+
42
+ with_rails_constraint(">= 7.0.0") do
43
+ propagate(:active_record, "::ActiveRecord")
44
+ end
45
+
31
46
  propagate(:time_zone, "::Time", :zone)
47
+ propagate_hosts
32
48
  propagate_autoload_paths
33
49
  propagate_i18n
34
50
  propagate_cache_store
@@ -38,12 +54,27 @@ module RailsEnv
38
54
  Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store)
39
55
  end
40
56
 
57
+ def self.propagate_hosts
58
+ Rails.application.config.hosts = config.hosts
59
+ end
60
+
41
61
  def self.propagate_i18n
42
62
  I18n.available_locales = (config.i18n.available_locales || [])
43
- .compact
44
- .map(&:to_sym)
45
- .uniq
46
- I18n.default_locale = config.i18n.default_locale if config.i18n.default_locale
63
+ .compact
64
+ .map(&:to_sym)
65
+ .uniq
66
+
67
+ if config.i18n.default_locale
68
+ I18n.default_locale = config.i18n.default_locale
69
+ end
70
+
71
+ with_rails_constraint("< 7.0.0") do
72
+ if config.i18n.respond_to?(:raise_on_missing_translations)
73
+ ActionView::Base.raise_on_missing_translations =
74
+ config.i18n.raise_on_missing_translations
75
+ end
76
+ end
77
+
47
78
  I18n.locale = config.i18n.locale if config.i18n.locale
48
79
  I18n.load_path += config.i18n.load_path if config.i18n.load_path
49
80
  end
@@ -52,11 +83,17 @@ module RailsEnv
52
83
  all_autoload_paths = (
53
84
  config.autoload_paths +
54
85
  config.eager_load_paths +
55
- config.autoload_once_paths
56
- ).uniq
86
+ config.autoload_once_paths +
87
+ ActiveSupport::Dependencies.autoload_paths
88
+ ).uniq.freeze
89
+
90
+ all_autoload_once_paths = (
91
+ config.autoload_once_paths +
92
+ ActiveSupport::Dependencies.autoload_once_paths
93
+ ).uniq.freeze
57
94
 
58
- ActiveSupport::Dependencies.autoload_paths.unshift(*all_autoload_paths)
59
- ActiveSupport::Dependencies.autoload_once_paths.unshift(*config.autoload_once_paths)
95
+ ActiveSupport::Dependencies.autoload_paths = all_autoload_paths
96
+ ActiveSupport::Dependencies.autoload_once_paths = all_autoload_once_paths
60
97
  end
61
98
 
62
99
  def self.propagate(options_name, target_name, target_property = nil)
@@ -75,6 +112,12 @@ module RailsEnv
75
112
  end
76
113
  end
77
114
 
115
+ def self.with_rails_constraint(constraint)
116
+ yield if Gem::Requirement
117
+ .create(constraint)
118
+ .satisfied_by?(Gem::Version.create(Rails::VERSION::STRING))
119
+ end
120
+
78
121
  module Extension
79
122
  def on(*envs, &block)
80
123
  env_matched = envs.include?(:any) || envs.include?(Rails.env.to_sym)
data/rails-env.gemspec CHANGED
@@ -1,24 +1,47 @@
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"
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"
23
45
  spec.add_development_dependency "simplecov"
46
+ spec.add_development_dependency "sqlite3"
24
47
  end
metadata CHANGED
@@ -1,17 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 2.0.2
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: 2019-03-01 00:00:00.000000000 Z
11
+ date: 2021-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
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
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
45
  - - ">="
@@ -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,7 @@ 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
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -94,33 +122,61 @@ dependencies:
94
122
  - - ">="
95
123
  - !ruby/object:Gem::Version
96
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: sqlite3
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
97
139
  description: Avoid environment detection on Rails
98
140
  email:
99
- - fnando.vieira@gmail.com
141
+ - me@fnando.com
100
142
  executables: []
101
143
  extensions: []
102
144
  extra_rdoc_files: []
103
145
  files:
146
+ - ".github/CODEOWNERS"
147
+ - ".github/FUNDING.yml"
148
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
149
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
150
+ - ".github/PULL_REQUEST_TEMPLATE.md"
151
+ - ".github/dependabot.yml"
152
+ - ".github/workflows/ruby-tests.yml"
104
153
  - ".gitignore"
105
- - ".travis.yml"
154
+ - ".rubocop.yml"
155
+ - CHANGELOG.md
156
+ - CODE_OF_CONDUCT.md
157
+ - CONTRIBUTING.md
106
158
  - Gemfile
107
- - LICENSE.txt
159
+ - LICENSE.md
108
160
  - README.md
109
161
  - Rakefile
110
- - gemfiles/rails_5_0.gemfile
111
- - gemfiles/rails_5_2.gemfile
112
162
  - gemfiles/rails_6_0.gemfile
163
+ - gemfiles/rails_6_1.gemfile
164
+ - gemfiles/rails_7_0.gemfile
113
165
  - lib/rails-env.rb
114
166
  - lib/rails-env/version.rb
115
167
  - rails-env.gemspec
116
- - test/test_helper.rb
117
- - test/unit/rails_env_test.rb
118
- - test/unit/rails_test.rb
119
- homepage: https://github.com/fnando/rails-env
168
+ homepage: https://github.com/fnando/rails_env
120
169
  licenses:
121
170
  - MIT
122
- metadata: {}
123
- post_install_message:
171
+ metadata:
172
+ rubygems_mfa_required: 'true'
173
+ homepage_uri: https://github.com/fnando/rails_env
174
+ bug_tracker_uri: https://github.com/fnando/rails_env/issues
175
+ source_code_uri: https://github.com/fnando/rails_env/tree/v2.0.2
176
+ changelog_uri: https://github.com/fnando/rails_env/tree/v2.0.2/CHANGELOG.md
177
+ documentation_uri: https://github.com/fnando/rails_env/tree/v2.0.2/README.md
178
+ license_uri: https://github.com/fnando/rails_env/tree/v2.0.2/LICENSE.md
179
+ post_install_message:
124
180
  rdoc_options: []
125
181
  require_paths:
126
182
  - lib
@@ -128,18 +184,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
184
  requirements:
129
185
  - - ">="
130
186
  - !ruby/object:Gem::Version
131
- version: '0'
187
+ version: 2.7.0
132
188
  required_rubygems_version: !ruby/object:Gem::Requirement
133
189
  requirements:
134
190
  - - ">="
135
191
  - !ruby/object:Gem::Version
136
192
  version: '0'
137
193
  requirements: []
138
- rubygems_version: 3.0.1
139
- signing_key:
194
+ rubygems_version: 3.2.32
195
+ signing_key:
140
196
  specification_version: 4
141
197
  summary: Avoid environment detection on Rails
142
- test_files:
143
- - test/test_helper.rb
144
- - test/unit/rails_env_test.rb
145
- - test/unit/rails_test.rb
198
+ test_files: []
data/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- sudo: false
2
- cache: bundler
3
- rvm:
4
- - 2.6.1
5
- - 2.5.3
6
- script: bundle exec rake
7
- gemfile:
8
- - gemfiles/rails_6_0.gemfile
9
- - gemfiles/rails_5_2.gemfile
10
- - gemfiles/rails_5_0.gemfile
11
- env:
12
- global:
13
- secure: irnD3t0HmZ2dG0GVHhVtzgitUX7m4GtJ3uK55vGp7JWPHHIL4daQORfHcuu3uJW0OaECf4WQUODy0HM2dArXZ1DrOjm7cnfr03oZKKi7Ft5ECOcQUagvsir7zJ+icBJ8WzcIl7V0p3aHNXEQ9jNIX1/v+Edcs+HXEdlFpp0Vt7Y=
14
- after_script:
15
- - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
16
- before_install:
17
- - gem install bundler
18
- before_script:
19
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
20
- - chmod +x ./cc-test-reporter
21
- - "./cc-test-reporter before-build"
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.
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec path: ".."
3
-
4
- gem "rails", "~> 5.0.0"
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec path: ".."
3
-
4
- gem "rails", "~> 5.2.0"
data/test/test_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- require "simplecov"
2
- SimpleCov.start
3
-
4
- ENV["RAILS_ENV"] = "test"
5
-
6
- require "bundler/setup"
7
- require "rails"
8
- require "action_mailer/railtie"
9
- require "action_view/railtie"
10
- require "action_controller/railtie"
11
- require "active_job/railtie"
12
- require "rails-env"
13
-
14
- require "minitest/utils"
15
- require "minitest/autorun"
16
-
17
- class DummyApp < Rails::Application
18
- config.eager_load = false
19
- config.active_support.test_order = :sorted
20
- end
21
-
22
- 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,74 +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
-
19
- config.cache_store = :memory_store
20
- end
21
- end
22
-
23
- test "assigns extended environment" do
24
- Rails.env = "test"
25
- assert Rails.env.respond_to?(:on)
26
- end
27
-
28
- test "sets url options" do
29
- assert_equal "localhost", ActionMailer::Base.default_url_options[:host]
30
- assert_equal 3000, ActionMailer::Base.default_url_options[:port]
31
- end
32
-
33
- test "sets raise option" do
34
- assert ActionMailer::Base.raise_delivery_errors
35
- end
36
-
37
- test "sets delivery method" do
38
- assert_equal :letter_opener, ActionMailer::Base.delivery_method
39
- end
40
-
41
- test "sets timezone" do
42
- assert_equal "America/Sao_Paulo", Time.zone.name
43
- end
44
-
45
- test "sets locale" do
46
- assert_equal :"pt-BR", I18n.locale
47
- end
48
-
49
- test "sets available locales" do
50
- assert_equal [:"pt-BR"], I18n.available_locales
51
- end
52
-
53
- test "sets raise on missing translations" do
54
- assert ActionView::Base.raise_on_missing_translations
55
- end
56
-
57
- test "sets queue adapter" do
58
- assert_kind_of ActiveJob::QueueAdapters::TestAdapter, ActiveJob::Base.queue_adapter
59
- end
60
-
61
- test "sets autoload_paths" do
62
- assert ActiveSupport::Dependencies.autoload_paths.include?("#{__dir__}/al")
63
- assert ActiveSupport::Dependencies.autoload_paths.include?("#{__dir__}/el")
64
- assert ActiveSupport::Dependencies.autoload_paths.include?("#{__dir__}/alo")
65
- end
66
-
67
- test "sets autoload_once_paths" do
68
- assert ActiveSupport::Dependencies.autoload_once_paths.include?("#{__dir__}/alo")
69
- end
70
-
71
- test "sets cache store" do
72
- assert_kind_of ActiveSupport::Cache::MemoryStore, Rails.cache
73
- end
74
- end