rails-env 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +4 -0
- data/.github/FUNDING.yml +4 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +41 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +38 -0
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/ruby-tests.yml +55 -0
- data/.rubocop.yml +17 -0
- data/CHANGELOG.md +16 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +79 -0
- data/Gemfile +3 -2
- data/LICENSE.md +20 -0
- data/README.md +43 -21
- data/Rakefile +9 -4
- data/lib/rails-env.rb +17 -5
- data/lib/rails-env/version.rb +3 -1
- data/rails-env.gemspec +36 -15
- metadata +61 -23
- data/.travis.yml +0 -21
- data/LICENSE.txt +0 -22
- data/test/test_helper.rb +0 -22
- data/test/unit/rails_env_test.rb +0 -43
- data/test/unit/rails_test.rb +0 -74
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 706a2f8516c67dfa269bb7df652f438191beb28f1304c6fab6bc94d31bf522be
|
4
|
+
data.tar.gz: 975baaee9bb6742a6fdc41f7d60d30f8a7b524257ffaa30a804ba430077cd9b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14cebae619bb0dd942a0b19510a772d291ec3eb9b5fb8144f2f1537a410ed4e73c6e0ba2dc5d4a6e10bbece5fc0feaf38b2d9fb0517b2630fcc63ced7c28d741
|
7
|
+
data.tar.gz: 02a7bc847a672840116851668e7399d906a0cdb18cacdc92fe00e5f686c4d18cff303a4aabf396d3c755de506fe3c1695dda8f92a022492a455347fdb19187b2
|
data/.github/CODEOWNERS
ADDED
data/.github/FUNDING.yml
ADDED
@@ -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
|
+
name: ruby-tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- main
|
10
|
+
|
11
|
+
schedule:
|
12
|
+
- cron: "0 10 * * *"
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
build:
|
16
|
+
name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
|
17
|
+
runs-on: "ubuntu-latest"
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
ruby: [2.6.x, 2.7.x]
|
22
|
+
gemfile:
|
23
|
+
- Gemfile
|
24
|
+
|
25
|
+
steps:
|
26
|
+
- uses: actions/checkout@v1
|
27
|
+
|
28
|
+
- uses: actions/cache@v2
|
29
|
+
with:
|
30
|
+
path: vendor/bundle
|
31
|
+
key: >
|
32
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles(matrix.gemfile) }}
|
33
|
+
restore-keys: >
|
34
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles(matrix.gemfile) }}
|
35
|
+
|
36
|
+
- name: Set up Ruby
|
37
|
+
uses: actions/setup-ruby@v1
|
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.6
|
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,16 @@
|
|
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
|
+
- Initial release.
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -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
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
|
-
[![
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
And then execute:
|
18
|
-
|
19
|
-
$ bundle
|
12
|
+
```bash
|
13
|
+
gem install rails-env
|
14
|
+
```
|
20
15
|
|
21
|
-
Or
|
16
|
+
Or add the following line to your project's Gemfile:
|
22
17
|
|
23
|
-
|
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
|
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
|
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
|
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,
|
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
|
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
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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 <<
|
6
|
-
t.
|
7
|
-
t.
|
8
|
+
t.libs << "test"
|
9
|
+
t.libs << "lib"
|
10
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
8
11
|
end
|
9
12
|
|
10
|
-
|
13
|
+
RuboCop::RakeTask.new
|
14
|
+
|
15
|
+
task default: %i[test rubocop]
|
data/lib/rails-env.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
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
11
|
env_method.bind(self).call(env)
|
@@ -29,6 +32,7 @@ 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
|
34
38
|
propagate_cache_store
|
@@ -38,12 +42,18 @@ module RailsEnv
|
|
38
42
|
Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store)
|
39
43
|
end
|
40
44
|
|
45
|
+
def self.propagate_hosts
|
46
|
+
Rails.application.config.hosts = config.hosts
|
47
|
+
end
|
48
|
+
|
41
49
|
def self.propagate_i18n
|
42
50
|
I18n.available_locales = (config.i18n.available_locales || [])
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
51
|
+
.compact
|
52
|
+
.map(&:to_sym)
|
53
|
+
.uniq
|
54
|
+
if config.i18n.default_locale
|
55
|
+
I18n.default_locale = config.i18n.default_locale
|
56
|
+
end
|
47
57
|
I18n.locale = config.i18n.locale if config.i18n.locale
|
48
58
|
I18n.load_path += config.i18n.load_path if config.i18n.load_path
|
49
59
|
end
|
@@ -56,7 +66,9 @@ module RailsEnv
|
|
56
66
|
).uniq
|
57
67
|
|
58
68
|
ActiveSupport::Dependencies.autoload_paths.unshift(*all_autoload_paths)
|
59
|
-
ActiveSupport::Dependencies.autoload_once_paths.unshift(
|
69
|
+
ActiveSupport::Dependencies.autoload_once_paths.unshift(
|
70
|
+
*config.autoload_once_paths
|
71
|
+
)
|
60
72
|
end
|
61
73
|
|
62
74
|
def self.propagate(options_name, target_name, target_property = nil)
|
data/lib/rails-env/version.rb
CHANGED
data/rails-env.gemspec
CHANGED
@@ -1,24 +1,45 @@
|
|
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
|
5
|
-
spec.version
|
6
|
-
spec.authors
|
7
|
-
spec.email
|
8
|
-
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.license
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
spec.name = "rails-env"
|
7
|
+
spec.version = RailsEnv::VERSION
|
8
|
+
spec.authors = ["Nando Vieira"]
|
9
|
+
spec.email = ["me@fnando.com"]
|
10
|
+
|
11
|
+
spec.summary = "Avoid environment detection on Rails"
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
15
|
+
|
16
|
+
github_url = "https://github.com/fnando/rails_env"
|
17
|
+
github_tree_url = "#{github_url}/tree/v#{spec.version}"
|
18
|
+
|
19
|
+
spec.homepage = github_url
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["bug_tracker_uri"] = "#{github_url}/issues"
|
22
|
+
spec.metadata["source_code_uri"] = github_tree_url
|
23
|
+
spec.metadata["changelog_uri"] = "#{github_tree_url}/CHANGELOG.md"
|
24
|
+
spec.metadata["documentation_uri"] = "#{github_tree_url}/README.md"
|
25
|
+
spec.metadata["license_uri"] = "#{github_tree_url}/LICENSE.md"
|
26
|
+
|
27
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
28
|
+
`git ls-files -z`
|
29
|
+
.split("\x0")
|
30
|
+
.reject {|f| f.match(%r{^(test|spec|features)/}) }
|
31
|
+
end
|
32
|
+
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
16
35
|
spec.require_paths = ["lib"]
|
17
36
|
|
18
|
-
spec.add_development_dependency "
|
37
|
+
spec.add_development_dependency "minitest"
|
38
|
+
spec.add_development_dependency "minitest-utils"
|
39
|
+
spec.add_development_dependency "pry-meta"
|
19
40
|
spec.add_development_dependency "rails"
|
20
41
|
spec.add_development_dependency "rake"
|
21
|
-
spec.add_development_dependency "
|
22
|
-
spec.add_development_dependency "
|
42
|
+
spec.add_development_dependency "rubocop"
|
43
|
+
spec.add_development_dependency "rubocop-fnando"
|
23
44
|
spec.add_development_dependency "simplecov"
|
24
45
|
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.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
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:
|
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:
|
98
|
+
name: rubocop-fnando
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
101
|
- - ">="
|
@@ -96,15 +124,25 @@ dependencies:
|
|
96
124
|
version: '0'
|
97
125
|
description: Avoid environment detection on Rails
|
98
126
|
email:
|
99
|
-
- fnando.
|
127
|
+
- me@fnando.com
|
100
128
|
executables: []
|
101
129
|
extensions: []
|
102
130
|
extra_rdoc_files: []
|
103
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"
|
104
139
|
- ".gitignore"
|
105
|
-
- ".
|
140
|
+
- ".rubocop.yml"
|
141
|
+
- CHANGELOG.md
|
142
|
+
- CODE_OF_CONDUCT.md
|
143
|
+
- CONTRIBUTING.md
|
106
144
|
- Gemfile
|
107
|
-
- LICENSE.
|
145
|
+
- LICENSE.md
|
108
146
|
- README.md
|
109
147
|
- Rakefile
|
110
148
|
- gemfiles/rails_5_0.gemfile
|
@@ -113,14 +151,17 @@ files:
|
|
113
151
|
- lib/rails-env.rb
|
114
152
|
- lib/rails-env/version.rb
|
115
153
|
- rails-env.gemspec
|
116
|
-
|
117
|
-
- test/unit/rails_env_test.rb
|
118
|
-
- test/unit/rails_test.rb
|
119
|
-
homepage: https://github.com/fnando/rails-env
|
154
|
+
homepage: https://github.com/fnando/rails_env
|
120
155
|
licenses:
|
121
156
|
- MIT
|
122
|
-
metadata:
|
123
|
-
|
157
|
+
metadata:
|
158
|
+
homepage_uri: https://github.com/fnando/rails_env
|
159
|
+
bug_tracker_uri: https://github.com/fnando/rails_env/issues
|
160
|
+
source_code_uri: https://github.com/fnando/rails_env/tree/v1.0.8
|
161
|
+
changelog_uri: https://github.com/fnando/rails_env/tree/v1.0.8/CHANGELOG.md
|
162
|
+
documentation_uri: https://github.com/fnando/rails_env/tree/v1.0.8/README.md
|
163
|
+
license_uri: https://github.com/fnando/rails_env/tree/v1.0.8/LICENSE.md
|
164
|
+
post_install_message:
|
124
165
|
rdoc_options: []
|
125
166
|
require_paths:
|
126
167
|
- lib
|
@@ -128,18 +169,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
169
|
requirements:
|
129
170
|
- - ">="
|
130
171
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
172
|
+
version: 2.6.0
|
132
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
174
|
requirements:
|
134
175
|
- - ">="
|
135
176
|
- !ruby/object:Gem::Version
|
136
177
|
version: '0'
|
137
178
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
139
|
-
signing_key:
|
179
|
+
rubygems_version: 3.1.4
|
180
|
+
signing_key:
|
140
181
|
specification_version: 4
|
141
182
|
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
|
183
|
+
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.
|
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!
|
data/test/unit/rails_env_test.rb
DELETED
@@ -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
|
data/test/unit/rails_test.rb
DELETED
@@ -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
|