rails-env 1.0.3 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 64a1b33d78a2f6ea1a3f825247a2f9b6d31641df
4
- data.tar.gz: 67ebba6d2ee4cb55d4609fabfe5ce14c442e3eb9
2
+ SHA256:
3
+ metadata.gz: 706a2f8516c67dfa269bb7df652f438191beb28f1304c6fab6bc94d31bf522be
4
+ data.tar.gz: 975baaee9bb6742a6fdc41f7d60d30f8a7b524257ffaa30a804ba430077cd9b8
5
5
  SHA512:
6
- metadata.gz: 5b06243ae47079aa2ca637d0f174da7c2f24107f8411ee968a7edbd3bc88f7618ba7458abc7d2fe9163e7897c15a6a213b35bdc03388abd8321aecf8378e71e8
7
- data.tar.gz: 7091a7be49d361700ced30a828cc0f3891173711ad32d7551d85414b6b5ba7521ce069faff5d9a429b83dbcafd78fa94cf3c25a7dd78d1b75b1c4eca8e1844a9
6
+ metadata.gz: 14cebae619bb0dd942a0b19510a772d291ec3eb9b5fb8144f2f1537a410ed4e73c6e0ba2dc5d4a6e10bbece5fc0feaf38b2d9fb0517b2630fcc63ced7c28d741
7
+ data.tar.gz: 02a7bc847a672840116851668e7399d906a0cdb18cacdc92fe00e5f686c4d18cff303a4aabf396d3c755de506fe3c1695dda8f92a022492a455347fdb19187b2
@@ -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
+ 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/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ gemfiles/*.lock
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
@@ -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
@@ -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.
@@ -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/
@@ -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
@@ -0,0 +1,20 @@
1
+ # The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Nando Vieira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,20 +1,23 @@
1
1
  # rails-env
2
2
 
3
+ [![Tests](https://github.com/fnando/rails-env/workflows/ruby-tests/badge.svg)](https://github.com/fnando/rails-env)
4
+ [![Code Climate](https://codeclimate.com/github/fnando/rails-env/badges/gpa.svg)](https://codeclimate.com/github/fnando/rails-env)
5
+ [![Gem](https://img.shields.io/gem/v/rails-env.svg)](https://rubygems.org/gems/rails-env)
6
+ [![Gem](https://img.shields.io/gem/dt/rails-env.svg)](https://rubygems.org/gems/rails-env)
7
+
3
8
  Avoid environment detection on Rails.
4
9
 
5
10
  ## Installation
6
11
 
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'rails-env'
10
-
11
- And then execute:
12
-
13
- $ bundle
12
+ ```bash
13
+ gem install rails-env
14
+ ```
14
15
 
15
- Or install it yourself as:
16
+ Or add the following line to your project's Gemfile:
16
17
 
17
- $ gem install rails-env
18
+ ```ruby
19
+ gem "rails-env"
20
+ ```
18
21
 
19
22
  ## Usage
20
23
 
@@ -34,7 +37,9 @@ Rails.env.on(:production) do
34
37
  end
35
38
  ```
36
39
 
37
- Looks dumb, but you don't have to use the long `Rails.configuration` or assign it to a local variable. This is useful when you're extracting out things to initializers.
40
+ Looks dumb, but you don't have to use the long `Rails.configuration` or assign
41
+ it to a local variable. This is useful when you're extracting out things to
42
+ initializers.
38
43
 
39
44
  To match all environments, use `:any`.
40
45
 
@@ -44,9 +49,32 @@ Rails.env.on(:any) do
44
49
  end
45
50
  ```
46
51
 
52
+ ## Gotcha
53
+
54
+ Not all options can be defined through `Rails.env`. Rails propagates options on
55
+ its engine file, meaning that every option defined on `config` afterwards must
56
+ be manually propagated.
57
+
58
+ It's hard to automatically propagate every existing option, so we have the most
59
+ common options covered, as you can see in the list below:
60
+
61
+ - action_controller
62
+ - action_mailer
63
+ - action_view
64
+ - active_job
65
+ - active_record
66
+ - time_zone
67
+ - auto/eager load paths
68
+ - i18n
69
+ - hosts
70
+
71
+ If you need to set any option not covered by rails-env,
72
+ [please open a ticket](https://github.com/fnando/rails-env/issues/new).
73
+
47
74
  ## Upgrading from previous versions
48
75
 
49
- Previous versions used to yield the configuration; this is no longer true on 1.0+.
76
+ Previous versions used to yield the configuration; this is no longer true on
77
+ 1.0+.
50
78
 
51
79
  So, instead of using
52
80
 
@@ -64,10 +92,27 @@ Rails.env.on(:development) do
64
92
  end
65
93
  ```
66
94
 
95
+ ## Maintainer
96
+
97
+ - [Nando Vieira](https://github.com/fnando)
98
+
99
+ ## Contributors
100
+
101
+ - https://github.com/fnando/rails-env/contributors
102
+
67
103
  ## Contributing
68
104
 
69
- 1. Fork it ( https://github.com/fnando/rails-env/fork )
70
- 2. Create your feature branch (`git checkout -b my-new-feature`)
71
- 3. Commit your changes (`git commit -am 'Add some feature'`)
72
- 4. Push to the branch (`git push origin my-new-feature`)
73
- 5. Create a new Pull Request
105
+ For more details about how to contribute, please read
106
+ https://github.com/fnando/rails-env/blob/main/CONTRIBUTING.md.
107
+
108
+ ## License
109
+
110
+ The gem is available as open source under the terms of the
111
+ [MIT License](https://opensource.org/licenses/MIT). A copy of the license can be
112
+ found at https://github.com/fnando/rails-env/blob/main/LICENSE.md.
113
+
114
+ ## Code of Conduct
115
+
116
+ Everyone interacting in the rails-env project's codebases, issue trackers, chat
117
+ rooms and mailing lists is expected to follow the
118
+ [code of conduct](https://github.com/fnando/rails-env/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,2 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+ require "rubocop/rake_task"
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << "test"
9
+ t.libs << "lib"
10
+ t.test_files = FileList["test/**/*_test.rb"]
11
+ end
12
+
13
+ RuboCop::RakeTask.new
2
14
 
15
+ task default: %i[test rubocop]
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ gemspec path: ".."
3
+
4
+ gem "rails", "~> 5.0.0"
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ gemspec path: ".."
3
+
4
+ gem "rails", "~> 5.2.0"
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ gemspec path: ".."
3
+
4
+ gem "rails", "~> 6.0.0.beta2"
@@ -1,8 +1,11 @@
1
- require 'rails-env/version'
1
+ # frozen_string_literal: true
2
+
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)
@@ -13,7 +16,7 @@ end
13
16
 
14
17
  module RailsEnv
15
18
  class Railtie < Rails::Railtie
16
- initializer 'rails-env' do
19
+ initializer "rails-env" do
17
20
  Rails.env.extend(Extension)
18
21
  end
19
22
  end
@@ -23,24 +26,51 @@ module RailsEnv
23
26
  end
24
27
 
25
28
  def self.propagate_configuration!
26
- propagate(:action_mailer, '::ActionMailer::Base')
27
- propagate(:active_record, '::ActiveRecord::Base')
28
- propagate(:active_job, '::ActiveJob::Base')
29
- propagate(:action_controller, '::ActionController::Base')
30
- propagate(:time_zone, '::Time', :zone)
29
+ propagate(:action_controller, "::ActionController::Base")
30
+ propagate(:action_mailer, "::ActionMailer::Base")
31
+ propagate(:action_view, "::ActionView::Base")
32
+ propagate(:active_job, "::ActiveJob::Base")
33
+ propagate(:active_record, "::ActiveRecord::Base")
34
+ propagate(:time_zone, "::Time", :zone)
35
+ propagate_hosts
36
+ propagate_autoload_paths
31
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
32
47
  end
33
48
 
34
49
  def self.propagate_i18n
35
50
  I18n.available_locales = (config.i18n.available_locales || [])
36
- .compact
37
- .map(&:to_sym)
38
- .uniq
39
- I18n.default_locale = config.i18n.default_locale if config.i18n.default_locale
51
+ .compact
52
+ .map(&:to_sym)
53
+ .uniq
54
+ if config.i18n.default_locale
55
+ I18n.default_locale = config.i18n.default_locale
56
+ end
40
57
  I18n.locale = config.i18n.locale if config.i18n.locale
41
58
  I18n.load_path += config.i18n.load_path if config.i18n.load_path
42
59
  end
43
60
 
61
+ def self.propagate_autoload_paths
62
+ all_autoload_paths = (
63
+ config.autoload_paths +
64
+ config.eager_load_paths +
65
+ config.autoload_once_paths
66
+ ).uniq
67
+
68
+ ActiveSupport::Dependencies.autoload_paths.unshift(*all_autoload_paths)
69
+ ActiveSupport::Dependencies.autoload_once_paths.unshift(
70
+ *config.autoload_once_paths
71
+ )
72
+ end
73
+
44
74
  def self.propagate(options_name, target_name, target_property = nil)
45
75
  return unless Object.const_defined?(target_name)
46
76
  return unless config.respond_to?(options_name)
@@ -48,7 +78,7 @@ module RailsEnv
48
78
  target = Object.const_get(target_name)
49
79
  options = config.public_send(options_name)
50
80
 
51
- if options.kind_of?(Enumerable)
81
+ if options.is_a?(Hash)
52
82
  options.each do |key, value|
53
83
  target.public_send("#{key}=", value) if target.respond_to?("#{key}=")
54
84
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsEnv
2
- VERSION = '1.0.3'
4
+ VERSION = "1.0.8"
3
5
  end
@@ -1,23 +1,45 @@
1
- require './lib/rails-env/version'
1
+ # frozen_string_literal: true
2
+
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)/})
16
- spec.require_paths = ['lib']
17
-
18
- spec.add_development_dependency 'bundler', '~> 1.6'
19
- spec.add_development_dependency 'rails'
20
- spec.add_development_dependency 'rake'
21
- spec.add_development_dependency 'rspec'
22
- spec.add_development_dependency 'pry-meta'
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) }
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_development_dependency "minitest"
38
+ spec.add_development_dependency "minitest-utils"
39
+ spec.add_development_dependency "pry-meta"
40
+ spec.add_development_dependency "rails"
41
+ spec.add_development_dependency "rake"
42
+ spec.add_development_dependency "rubocop"
43
+ spec.add_development_dependency "rubocop-fnando"
44
+ spec.add_development_dependency "simplecov"
23
45
  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.3
4
+ version: 1.0.8
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: 2015-08-31 00:00:00.000000000 Z
11
+ date: 2020-11-18 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: rspec
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: pry-meta
98
+ name: rubocop-fnando
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
115
  - - ">="
@@ -82,28 +124,44 @@ dependencies:
82
124
  version: '0'
83
125
  description: Avoid environment detection on Rails
84
126
  email:
85
- - fnando.vieira@gmail.com
127
+ - me@fnando.com
86
128
  executables: []
87
129
  extensions: []
88
130
  extra_rdoc_files: []
89
131
  files:
132
+ - ".github/CODEOWNERS"
133
+ - ".github/FUNDING.yml"
134
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
135
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
136
+ - ".github/PULL_REQUEST_TEMPLATE.md"
137
+ - ".github/dependabot.yml"
138
+ - ".github/workflows/ruby-tests.yml"
90
139
  - ".gitignore"
91
- - ".rspec"
140
+ - ".rubocop.yml"
141
+ - CHANGELOG.md
142
+ - CODE_OF_CONDUCT.md
143
+ - CONTRIBUTING.md
92
144
  - Gemfile
93
- - LICENSE.txt
145
+ - LICENSE.md
94
146
  - README.md
95
147
  - Rakefile
148
+ - gemfiles/rails_5_0.gemfile
149
+ - gemfiles/rails_5_2.gemfile
150
+ - gemfiles/rails_6_0.gemfile
96
151
  - lib/rails-env.rb
97
152
  - lib/rails-env/version.rb
98
153
  - rails-env.gemspec
99
- - spec/rails-env_spec.rb
100
- - spec/rails_spec.rb
101
- - spec/spec_helper.rb
102
- homepage: https://github.com/fnando/rails-env
154
+ homepage: https://github.com/fnando/rails_env
103
155
  licenses:
104
156
  - MIT
105
- metadata: {}
106
- post_install_message:
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:
107
165
  rdoc_options: []
108
166
  require_paths:
109
167
  - lib
@@ -111,19 +169,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
169
  requirements:
112
170
  - - ">="
113
171
  - !ruby/object:Gem::Version
114
- version: '0'
172
+ version: 2.6.0
115
173
  required_rubygems_version: !ruby/object:Gem::Requirement
116
174
  requirements:
117
175
  - - ">="
118
176
  - !ruby/object:Gem::Version
119
177
  version: '0'
120
178
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.4.5.1
123
- signing_key:
179
+ rubygems_version: 3.1.4
180
+ signing_key:
124
181
  specification_version: 4
125
182
  summary: Avoid environment detection on Rails
126
- test_files:
127
- - spec/rails-env_spec.rb
128
- - spec/rails_spec.rb
129
- - spec/spec_helper.rb
183
+ test_files: []
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
@@ -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,43 +0,0 @@
1
- require 'spec_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
- describe RailsEnv do
16
- it 'runs block when env matches' do
17
- block = Callable.new
18
- Rails.env.on(:test, &block)
19
-
20
- expect(block.configuration).to eq(Rails.configuration)
21
- end
22
-
23
- it 'matches against multiple envs' do
24
- block = Callable.new
25
- Rails.env.on(:development, :test, &block)
26
-
27
- expect(block.configuration).to eq(Rails.configuration)
28
- end
29
-
30
- it 'skips block when env differs' do
31
- block = Callable.new
32
- Rails.env.on(:production, &block)
33
-
34
- expect(block.configuration).to be_nil
35
- end
36
-
37
- it 'runs on any environment' do
38
- block = Callable.new
39
- Rails.env.on(:any, &block)
40
-
41
- expect(block.configuration).to eq(Rails.configuration)
42
- end
43
- end
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RailsEnv, '::ActionMailer' do
4
- before do
5
- Rails.env.on(:test) do
6
- config.action_mailer.default_url_options = {host: 'localhost', port: 3000}
7
- config.action_mailer.raise_delivery_errors = true
8
- config.action_mailer.delivery_method = :letter_opener
9
- config.time_zone = 'America/Sao_Paulo'
10
- config.i18n.available_locales = ['pt-BR']
11
- config.i18n.default_locale = 'pt-BR'
12
- end
13
- end
14
-
15
- it 'assigns extended environment' do
16
- Rails.env = 'test'
17
- expect(Rails.env).to respond_to(:on)
18
- end
19
-
20
- it 'sets url options' do
21
- expect(ActionMailer::Base.default_url_options).to include(host: 'localhost', port: 3000)
22
- end
23
-
24
- it 'sets raise option' do
25
- expect(ActionMailer::Base.raise_delivery_errors).to be_truthy
26
- end
27
-
28
- it 'sets delivery method' do
29
- expect(ActionMailer::Base.delivery_method).to eq(:letter_opener)
30
- end
31
-
32
- it 'sets timezone' do
33
- expect(Time.zone.name).to eq('America/Sao_Paulo')
34
- end
35
-
36
- it 'sets locale' do
37
- expect(I18n.locale).to eq(:'pt-BR')
38
- end
39
-
40
- it 'sets available locales' do
41
- expect(I18n.available_locales).to eq([:'pt-BR'])
42
- end
43
- end
@@ -1,12 +0,0 @@
1
- ENV['RAILS_ENV'] = 'test'
2
-
3
- require 'bundler/setup'
4
- require 'rails'
5
- require 'action_mailer/railtie'
6
- require 'rails-env'
7
-
8
- class DummyApp < Rails::Application
9
- config.eager_load = false
10
- end
11
-
12
- Rails.application.initialize!