dotenv 3.0.3 → 3.1.0

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
2
  SHA256:
3
- metadata.gz: e2ff4f17537b901cd35363188bcf31b756e7eab87039d76a43ffcf4196c474e2
4
- data.tar.gz: a7703a4ccf3f72491896e8ded3289b457e610323ce0b8276bdd96eb2af15be18
3
+ metadata.gz: 1dc708aad5fcaf487b064451b8f47d5b0e402a7c250385f234306ab3c77fcf20
4
+ data.tar.gz: e939eca5e64f2aef9aeb784bd9765e20a3201057d4ed69c1ea46b1405625920e
5
5
  SHA512:
6
- metadata.gz: 1fdb56b5a23015afb5e86de500a0a14e57fb07332317d552052f200aa4a86e57e6f452b24f6195dc910258d78d467f98748cefbfb225cc3a8c1ddbbf0c145795
7
- data.tar.gz: c7cce79b3636e16388a4e1573865933c0f12a111316404d475d87cd1c06dc4f27565a6e1ffa34b34483aa577f57c42ea614cf75b33752fcc8985fe540a421488
6
+ metadata.gz: 3c7a9b929e7b419a1df9c07bd2dfa7959deea186bc6de9e0e8bdfdc671b7d4c183104715206ac956e81d4689b76d14907dd0a644eb995f4cd48437047e307ad1
7
+ data.tar.gz: de3d64ad2bf4fbec40e7c253c71de40cf1cab82875293f168c73a5098e7419554362014e6eb0c6339d485c41c12cccad82e0f854fee30f7fef18e7cc4afc26ef
data/README.md CHANGED
@@ -54,7 +54,7 @@ require 'dotenv'
54
54
  Dotenv.load('file1.env', 'file2.env')
55
55
  ```
56
56
 
57
- ## Autorestore in tests
57
+ ### Autorestore in tests
58
58
 
59
59
  Since 3.0, dotenv in a Rails app will automatically restore `ENV` after each test. This means you can modify `ENV` in your tests without fear of leaking state to other tests. It works with both `ActiveSupport::TestCase` and `Rspec`.
60
60
 
@@ -181,6 +181,8 @@ Available options:
181
181
 
182
182
  * `Dotenv::Rails.files` - list of files to be loaded, in order of precedence.
183
183
  * `Dotenv::Rails.overwrite` - Overwrite exiting `ENV` variables with contents of `.env*` files
184
+ * `Dotenv::Rails.logger` - The logger to use for dotenv's logging. Defaults to `Rails.logger`
185
+ * `Dotenv::Rails.autorestore` - Enable or disable [autorestore](#autorestore-in-tests)
184
186
 
185
187
  ### Multi-line values
186
188
 
data/lib/dotenv/rails.rb CHANGED
@@ -23,7 +23,7 @@ end
23
23
  module Dotenv
24
24
  # Rails integration for using Dotenv to load ENV variables from a file
25
25
  class Rails < ::Rails::Railtie
26
- delegate :files, :files=, :overwrite, :overwrite=, :autorestore, :autorestore=, :logger, :logger=, to: "config.dotenv"
26
+ delegate :files, :files=, :overwrite, :overwrite=, :autorestore, :autorestore=, :logger, to: "config.dotenv"
27
27
 
28
28
  def initialize
29
29
  super()
@@ -61,6 +61,12 @@ module Dotenv
61
61
  ::Rails.root || Pathname.new(ENV["RAILS_ROOT"] || Dir.pwd)
62
62
  end
63
63
 
64
+ # Set a new logger and replay logs
65
+ def logger=(new_logger)
66
+ logger.replay new_logger if logger.is_a?(ReplayLogger)
67
+ config.dotenv.logger = new_logger
68
+ end
69
+
64
70
  # The current environment that the app is running in.
65
71
  #
66
72
  # When running `rake`, the Rails application is initialized in development, so we have to
@@ -88,11 +94,9 @@ module Dotenv
88
94
  end
89
95
 
90
96
  initializer "dotenv", after: :initialize_logger do |app|
91
- # Set up a new logger once Rails has initialized the logger and replay logs
92
- new_logger = ::Rails.logger
93
- new_logger = new_logger.tagged("dotenv") if new_logger.respond_to?(:tagged)
94
- logger.replay new_logger if logger.respond_to?(:replay)
95
- self.logger = new_logger
97
+ if logger.is_a?(ReplayLogger)
98
+ self.logger = ActiveSupport::TaggedLogging.new(::Rails.logger).tagged("dotenv")
99
+ end
96
100
  end
97
101
 
98
102
  initializer "dotenv.deprecator" do |app|
@@ -1,3 +1,3 @@
1
1
  module Dotenv
2
- VERSION = "3.0.3".freeze
2
+ VERSION = "3.1.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotenv
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Keepers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-26 00:00:00.000000000 Z
11
+ date: 2024-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -84,7 +84,7 @@ homepage: https://github.com/bkeepers/dotenv
84
84
  licenses:
85
85
  - MIT
86
86
  metadata: {}
87
- post_install_message:
87
+ post_install_message:
88
88
  rdoc_options: []
89
89
  require_paths:
90
90
  - lib
@@ -99,8 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.4.10
103
- signing_key:
102
+ rubygems_version: 3.5.3
103
+ signing_key:
104
104
  specification_version: 4
105
105
  summary: Loads environment variables from `.env`.
106
106
  test_files: []