[
  {
    "path": ".github/dependabot.yml",
    "content": "version: 2\nupdates:\n  - package-ecosystem: \"bundler\"\n    directory: \"/\"\n    schedule:\n      interval: \"weekly\"\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      interval: \"weekly\"\n"
  },
  {
    "path": ".github/funding.yml",
    "content": "github: [bkeepers]\n"
  },
  {
    "path": ".github/issue_template.md",
    "content": "### Steps to reproduce\nTell us how to reproduce the issue.\nShow how you included dotenv (Gemfile).\nPaste your env using:\n```bash\n$ env | grep MYVARIABLETOSHOW\n```\n**REMOVE ANY SENSITIVE INFORMATION FROM YOUR OUTPUT**\n\n### Expected behavior\nTell us what should happen\n\n### Actual behavior\nTell us what happens instead\n\n### System configuration\n**dotenv version**:\n\n**Rails version**:\n\n**Ruby version**:\n"
  },
  {
    "path": ".github/stale.yml",
    "content": "# Number of days of inactivity before an issue becomes stale\ndaysUntilStale: 60\n# Number of days of inactivity before a stale issue is closed\ndaysUntilClose: 7\n# Issues with these labels will never be considered stale\nexemptLabels:\n  - pinned\n  - security\n# Label to use when marking an issue as stale\nstaleLabel: wontfix\n# Comment to post when marking an issue as stale. Set to `false` to disable\nmarkComment: >\n  This issue has been automatically marked as stale because it has not had\n  recent activity. It will be closed if no further activity occurs. Thank you\n  for your contributions.\n# Comment to post when closing a stale issue. Set to `false` to disable\ncloseComment: false\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: CI\non:\n  push:\n    branches: [main]\n  pull_request:\n  schedule:\n    - cron: \"0 0 * * *\" # Once/day\n\njobs:\n  versions:\n    name: Get latest versions\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        product: [\"ruby\", \"rails\"]\n    outputs:\n      ruby: ${{ steps.supported.outputs.ruby }}\n      rails: ${{ steps.supported.outputs.rails }}\n    steps:\n      - id: supported\n        run: |\n          product=\"${{ matrix.product }}\"\n          data=$(curl https://endoflife.date/api/$product.json)\n          supported=$(echo $data | jq '[.[] | select(.eol > (now | strftime(\"%Y-%m-%d\")))]')\n          echo \"${product}=$(echo $supported | jq -c 'map(.latest)')\" >> $GITHUB_OUTPUT\n  test:\n    needs: versions\n    runs-on: ubuntu-latest\n    name: Test on Ruby ${{ matrix.ruby }} and Rails ${{ matrix.rails }}\n    strategy:\n      fail-fast: false\n      matrix:\n        ruby: ${{ fromJSON(needs.versions.outputs.ruby) }}\n        rails: ${{ fromJSON(needs.versions.outputs.rails) }}\n    env:\n      RAILS_VERSION: ${{ matrix.rails }}\n    steps:\n      - name: Check out repository code\n        uses: actions/checkout@v6\n      - name: Set up Ruby\n        id: setup-ruby\n        uses: ruby/setup-ruby@v1\n        with:\n          bundler-cache: true\n          ruby-version: ${{ matrix.ruby }}\n        continue-on-error: true\n      - name: Incompatible Versions\n        if: steps.setup-ruby.outcome == 'failure'\n        run: echo \"Ruby ${{ matrix.ruby }} is not supported with Rails ${{ matrix.rails }}\"\n      - name: Run Rake\n        if: steps.setup-ruby.outcome != 'failure'\n        run: bundle exec rake\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "name: Publish Gem\non:\n  release:\n    types: [published]\njobs:\n  build:\n    runs-on: ubuntu-latest\n    permissions:\n      id-token: write # mandatory for trusted publishing\n      contents: write # required for `rake release` to push the release tag\n    steps:\n      - uses: actions/checkout@v6\n      - name: Set up Ruby\n        uses: ruby/setup-ruby@v1\n        with:\n          bundler-cache: true\n          ruby-version: ruby\n      - uses: rubygems/release-gem@v1\n"
  },
  {
    "path": ".gitignore",
    "content": "*.gem\n*.rbc\n.bundle\n.config\n.ruby-version\n.yardoc\nGemfile.lock\ntmp\nvendor\n.DS_Store\n"
  },
  {
    "path": ".standard.yml",
    "content": "ruby_version: 3.0\n\nignore:\n  - lib/dotenv/parser.rb:\n      - Lint/InheritException\n"
  },
  {
    "path": "Changelog.md",
    "content": "See [Releases](https://github.com/bkeepers/dotenv/releases) for the latest releases and changelogs.\n\n[View older releases](https://github.com/bkeepers/dotenv/blob/2840d9c4085a398cbde9f164465515b01c26a402/Changelog.md)\n"
  },
  {
    "path": "Gemfile",
    "content": "source \"https://rubygems.org\"\ngemspec name: \"dotenv\"\ngemspec name: \"dotenv-rails\"\n\ngem \"railties\", \"~> #{ENV[\"RAILS_VERSION\"] || \"7.1\"}\"\ngem \"benchmark-ips\"\ngem \"stackprof\"\n\ngroup :guard do\n  gem \"guard-rspec\"\n  gem \"guard-bundler\"\n  gem \"rb-fsevent\"\nend\n"
  },
  {
    "path": "Guardfile",
    "content": "guard \"bundler\" do\n  watch(\"Gemfile\")\nend\n\nguard \"rspec\", cmd: \"bundle exec rspec\" do\n  watch(%r{^spec/.+_spec\\.rb$})\n  watch(%r{^spec/spec_helper.rb$}) { \"spec\" }\n  watch(%r{^lib/(.+)\\.rb$}) { |m| \"spec/#{m[1]}_spec.rb\" }\nend\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2012 Brandon Keepers\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
  },
  {
    "path": "OWNERS",
    "content": "# This project is maintained by:\n@bkeepers\n\n# For more information on the OWNERS file, see:\n# https://github.com/bkeepers/OWNERS\n"
  },
  {
    "path": "README.md",
    "content": "# dotenv [![Gem Version](https://badge.fury.io/rb/dotenv.svg)](https://badge.fury.io/rb/dotenv)\n\nShim to load environment variables from `.env` into `ENV` in *development*.\n\nStoring [configuration in the environment](http://12factor.net/config) is one of the tenets of a [twelve-factor app](http://12factor.net). Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables.\n\nBut it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. dotenv loads variables from a `.env` file into `ENV` when the environment is bootstrapped.\n\n## Installation\n\nAdd this line to the top of your application's Gemfile and run `bundle install`:\n\n```ruby\ngem 'dotenv', groups: [:development, :test]\n```\n\n## Usage\n\nAdd your application configuration to your `.env` file in the root of your project:\n\n```shell\nS3_BUCKET=YOURS3BUCKET\nSECRET_KEY=YOURSECRETKEYGOESHERE\n```\n\nWhenever your application loads, these variables will be available in `ENV`:\n\n```ruby\nconfig.fog_directory = ENV['S3_BUCKET']\n```\n\nSee the [API Docs](https://rubydoc.info/github/bkeepers/dotenv/main) for more.\n\n### Rails\n\nDotenv will automatically load when your Rails app boots. See [Customizing Rails](#customizing-rails) to change which files are loaded and when.\n\n### Sinatra / Ruby\n\nLoad Dotenv as early as possible in your application bootstrap process:\n\n```ruby\nrequire 'dotenv/load'\n\n# or\nrequire 'dotenv'\nDotenv.load\n```\n\nBy default, `load` will look for a file called `.env` in the current working directory.\nPass in multiple files and they will be loaded in order.\nThe first value set for a variable will win.\nExisting environment variables will not be overwritten unless you set `overwrite: true`.\n\n```ruby\nrequire 'dotenv'\nDotenv.load('file1.env', 'file2.env')\n```\n\n### Autorestore in tests\n\nSince 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`.\n\nTo disable this behavior, set `config.dotenv.autorestore = false` in `config/application.rb` or `config/environments/test.rb`. It is disabled by default if your app uses [climate_control](https://github.com/thoughtbot/climate_control) or [ice_age](https://github.com/dpep/ice_age_rb).\n\nTo use this behavior outside of a Rails app, just `require \"dotenv/autorestore\"` in your test suite.\n\nSee [`Dotenv.save`](https://rubydoc.info/github/bkeepers/dotenv/main/Dotenv:save), [Dotenv.restore](https://rubydoc.info/github/bkeepers/dotenv/main/Dotenv:restore), and [`Dotenv.modify(hash) { ... }`](https://rubydoc.info/github/bkeepers/dotenv/main/Dotenv:modify) for manual usage.\n\n### Rake\n\nTo ensure `.env` is loaded in rake, load the tasks:\n\n```ruby\nrequire 'dotenv/tasks'\n\ntask mytask: :dotenv do\n  # things that require .env\nend\n```\n\n### CLI\n\nYou can use the `dotenv` executable load `.env` before launching your application:\n\n```console\n$ dotenv ./script.rb\n```\n\nThe `dotenv` executable also accepts the flag `-f`. Its value should be a comma-separated list of configuration files, in the order of the most important to the least important. All of the files must exist. There _must_ be a space between the flag and its value.\n\n```console\n$ dotenv -f \".env.local,.env\" ./script.rb\n```\n\nThe `dotenv` executable can optionally ignore missing files with the `-i` or `--ignore` flag. For example, if the `.env.local` file does not exist, the following will ignore the missing file and only load the `.env` file.\n\n```console\n$ dotenv -i -f \".env.local,.env\" ./script.rb\n```\n\n### Load Order\n\nIf you use gems that require environment variables to be set before they are loaded, then list `dotenv` in the `Gemfile` before those other gems and require `dotenv/load`.\n\n```ruby\ngem 'dotenv', require: 'dotenv/load'\ngem 'gem-that-requires-env-variables'\n```\n\n### Customizing Rails\n\nDotenv will load the following files depending on `RAILS_ENV`, with the first file having the highest precedence, and `.env` having the lowest precedence:\n\n<table>\n  <thead>\n    <tr>\n      <th>Priority</th>\n      <th colspan=\"3\">Environment</th>\n      <th><code>.gitignore</code>it?</th>\n      <th>Notes</th>\n    </tr>\n    <tr>\n      <th></th>\n      <th>development</th>\n      <th>test</th>\n      <th>production</th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tr>\n    <td>highest</td>\n    <td><code>.env.development.local</code></td>\n    <td><code>.env.test.local</code></td>\n    <td><code>.env.production.local</code></td>\n    <td>Yes</td>\n    <td>Environment-specific local overrides</td>\n  </tr>\n  <tr>\n    <td>2nd</td>\n    <td><code>.env.local</code></td>\n    <td><strong>N/A</strong></td>\n    <td><code>.env.local</code></td>\n    <td>Yes</td>\n    <td>Local overrides</td>\n  </tr>\n  <tr>\n    <td>3rd</td>\n    <td><code>.env.development</code></td>\n    <td><code>.env.test</code></td>\n    <td><code>.env.production</code></td>\n    <td>No</td>\n    <td>Shared environment-specific variables</td>\n  </tr>\n  <tr>\n    <td>last</td>\n    <td><code>.env</code></td>\n    <td><code>.env</code></td>\n    <td><code>.env</code></td>\n    <td><a href=\"#should-i-commit-my-env-file\">Maybe</a></td>\n    <td>Shared for all environments</td>\n  </tr>\n</table>\n\n\nThese files are loaded during the `before_configuration` callback, which is fired when the `Application` constant is defined in `config/application.rb` with `class Application < Rails::Application`. If you need it to be initialized sooner, or need to customize the loading process, you can do so at the top of `application.rb`\n\n```ruby\n# config/application.rb\nBundler.require(*Rails.groups)\n\n# Load .env.local in test\nDotenv::Rails.files.unshift(\".env.local\") if ENV[\"RAILS_ENV\"] == \"test\"\n\nmodule YourApp\n  class Application < Rails::Application\n    # ...\n  end\nend\n```\n\nAvailable options:\n\n* `Dotenv::Rails.files` - list of files to be loaded, in order of precedence.\n* `Dotenv::Rails.overwrite` - Overwrite existing `ENV` variables with contents of `.env*` files\n* `Dotenv::Rails.logger` - The logger to use for dotenv's logging. Defaults to `Rails.logger`\n* `Dotenv::Rails.autorestore` - Enable or disable [autorestore](#autorestore-in-tests)\n\n### Multi-line values\n\nMulti-line values with line breaks must be surrounded with double quotes.\n\n```shell\nPRIVATE_KEY=\"-----BEGIN RSA PRIVATE KEY-----\n...\nHkVN9...\n...\n-----END DSA PRIVATE KEY-----\"\n```\n\nPrior to 3.0, dotenv would replace `\\n` in quoted strings with a newline, but that behavior is deprecated. To use the old behavior, set `DOTENV_LINEBREAK_MODE=legacy` before any variables that include `\\n`:\n\n```shell\nDOTENV_LINEBREAK_MODE=legacy\nPRIVATE_KEY=\"-----BEGIN RSA PRIVATE KEY-----\\nHkVN9...\\n-----END DSA PRIVATE KEY-----\\n\"\n```\n\n### Command Substitution\n\nYou need to add the output of a command in one of your variables? Simply add it with `$(your_command)`:\n\n```shell\nDATABASE_URL=\"postgres://$(whoami)@localhost/my_database\"\n```\n\n### Variable Substitution\n\nYou need to add the value of another variable in one of your variables? You can reference the variable with `${VAR}` or often just `$VAR` in unquoted or double-quoted values.\n\n```shell\nDATABASE_URL=\"postgres://${USER}@localhost/my_database\"\n```\n\nIf a value contains a `$` and it is not intended to be a variable, wrap it in single quotes.\n\n```shell\nPASSWORD='pas$word'\n```\n\n### Comments\n\nComments may be added to your file as such:\n\n```shell\n# This is a comment\nSECRET_KEY=YOURSECRETKEYGOESHERE # comment\nSECRET_HASH=\"something-with-a-#-hash\"\n```\n\n### Exports\n\nFor compatability, you may also add `export` in front of each line so you can `source` the file in bash:\n\n```shell\nexport S3_BUCKET=YOURS3BUCKET\nexport SECRET_KEY=YOURSECRETKEYGOESHERE\n```\n\n### Required Keys\n\nIf a particular configuration value is required but not set, it's appropriate to raise an error.\n\nTo require configuration keys:\n\n```ruby\n# config/initializers/dotenv.rb\n\nDotenv.require_keys(\"SERVICE_APP_ID\", \"SERVICE_KEY\", \"SERVICE_SECRET\")\n```\n\nIf any of the configuration keys above are not set, your application will raise an error during initialization. This method is preferred because it prevents runtime errors in a production application due to improper configuration.\n\n### Parsing\n\nTo parse a list of env files for programmatic inspection without modifying the ENV:\n\n```ruby\nDotenv.parse(\".env.local\", \".env\")\n# => {'S3_BUCKET' => 'YOURS3BUCKET', 'SECRET_KEY' => 'YOURSECRETKEYGOESHERE', ...}\n```\n\nThis method returns a hash of the ENV var name/value pairs.\n\n### Templates\n\nYou can use the `-t` or `--template` flag on the dotenv cli to create a template of your `.env` file.\n\n```console\n$ dotenv -t .env\n```\nA template will be created in your working directory named `{FILENAME}.template`. So in the above example, it would create a `.env.template` file.\n\nThe template will contain all the environment variables in your `.env` file but with their values set to the variable names.\n\n```shell\n# .env\nS3_BUCKET=YOURS3BUCKET\nSECRET_KEY=YOURSECRETKEYGOESHERE\n```\n\nWould become\n\n```shell\n# .env.template\nS3_BUCKET=S3_BUCKET\nSECRET_KEY=SECRET_KEY\n```\n\n## Frequently Answered Questions\n\n### Can I use dotenv in production?\n\ndotenv was originally created to load configuration variables into `ENV` in *development*. There are typically better ways to manage configuration in production environments - such as `/etc/environment` managed by [Puppet](https://github.com/puppetlabs/puppet) or [Chef](https://github.com/chef/chef), `heroku config`, etc.\n\nHowever, some find dotenv to be a convenient way to configure Rails applications in staging and production environments, and you can do that by defining environment-specific files like `.env.production` or `.env.test`.\n\nIf you use this gem to handle env vars for multiple Rails environments (development, test, production, etc.), please note that env vars that are general to all environments should be stored in `.env`. Then, environment specific env vars should be stored in `.env.<that environment's name>`.\n\n### Should I commit my .env file?\n\nCredentials should only be accessible on the machines that need access to them. Never commit sensitive information to a repository that is not needed by every development machine and server.\n\nPersonally, I prefer to commit the `.env` file with development-only settings. This makes it easy for other developers to get started on the project without compromising credentials for other environments. If you follow this advice, make sure that all the credentials for your development environment are different from your other deployments and that the development credentials do not have access to any confidential data.\n\n### Why is it not overwriting existing `ENV` variables?\n\nBy default, it **won't** overwrite existing environment variables as dotenv assumes the deployment environment has more knowledge about configuration than the application does. To overwrite existing environment variables you can use `Dotenv.load files, overwrite: true`.\n\nTo warn when a value was not overwritten (e.g. to make users aware of this gotcha),\nuse `Dotenv.load files, overwrite: :warn`.\n\nYou can also use the `-o` or `--overwrite` flag on the dotenv cli to overwrite existing `ENV` variables.\n\n```console\n$ dotenv -o -f \".env.local,.env\"\n```\n\n## Contributing\n\nIf you want a better idea of how dotenv works, check out the [Ruby Rogues Code Reading of dotenv](https://www.youtube.com/watch?v=lKmY_0uY86s).\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n"
  },
  {
    "path": "Rakefile",
    "content": "#!/usr/bin/env rake\n\nrequire \"bundler/gem_helper\"\nrequire \"rspec/core/rake_task\"\nrequire \"rake/testtask\"\nrequire \"standard/rake\"\n\nnamespace \"dotenv\" do\n  Bundler::GemHelper.install_tasks name: \"dotenv\"\nend\n\nclass DotenvRailsGemHelper < Bundler::GemHelper\n  def guard_already_tagged\n    # noop\n  end\n\n  def tag_version\n    # noop\n  end\nend\n\nnamespace \"dotenv-rails\" do\n  DotenvRailsGemHelper.install_tasks name: \"dotenv-rails\"\nend\n\ntask build: [\"dotenv:build\", \"dotenv-rails:build\"]\ntask install: [\"dotenv:install\", \"dotenv-rails:install\"]\ntask release: [\"dotenv:release\", \"dotenv-rails:release\"]\n\ndesc \"Run all specs\"\nRSpec::Core::RakeTask.new(:spec) do |t|\n  t.rspec_opts = %w[--color]\n  t.verbose = false\nend\n\nRake::TestTask.new do |t|\n  t.test_files = Dir[\"test/**/*_test.rb\"]\nend\n\ntask default: [:spec, :test, :standard]\n"
  },
  {
    "path": "benchmark/parse_ips.rb",
    "content": "require \"bundler/setup\"\nrequire \"dotenv\"\nrequire \"benchmark/ips\"\nrequire \"tempfile\"\n\nf = Tempfile.create(\"benchmark_ips.env\")\n1000.times.map { |i| f.puts \"VAR_#{i}=#{i}\" }\nf.close\n\nBenchmark.ips do |x|\n  x.report(\"parse, overwrite:false\") { Dotenv.parse(f.path, overwrite: false) }\n  x.report(\"parse, overwrite:true\") { Dotenv.parse(f.path, overwrite: true) }\nend\n\nFile.unlink(f.path)\n"
  },
  {
    "path": "benchmark/parse_profile.rb",
    "content": "require \"bundler/setup\"\nrequire \"dotenv\"\nrequire \"stackprof\"\nrequire \"benchmark/ips\"\nrequire \"tempfile\"\n\nf = Tempfile.create(\"benchmark_ips.env\")\n1000.times.map { |i| f.puts \"VAR_#{i}=#{i}\" }\nf.close\n\nprofile = StackProf.run(mode: :wall, interval: 1_000) do\n  10_000.times do\n    Dotenv.parse(f.path, overwrite: false)\n  end\nend\n\nresult = StackProf::Report.new(profile)\nputs\nresult.print_text\nputs \"\\n\\n\\n\"\nresult.print_method(/Dotenv.parse/)\n\nFile.unlink(f.path)\n"
  },
  {
    "path": "bin/dotenv",
    "content": "#!/usr/bin/env ruby\n\nrequire \"dotenv/cli\"\nDotenv::CLI.new(ARGV).run\n"
  },
  {
    "path": "dotenv-rails.gemspec",
    "content": "require File.expand_path(\"../lib/dotenv/version\", __FILE__)\nrequire \"English\"\n\nGem::Specification.new \"dotenv-rails\", Dotenv::VERSION do |gem|\n  gem.authors = [\"Brandon Keepers\"]\n  gem.email = [\"brandon@opensoul.org\"]\n  gem.description = gem.summary = \"Autoload dotenv in Rails.\"\n  gem.homepage = \"https://github.com/bkeepers/dotenv\"\n  gem.license = \"MIT\"\n  gem.files = `git ls-files lib | grep dotenv-rails.rb`.split(\"\\n\") + [\"README.md\", \"LICENSE\"]\n\n  gem.add_dependency \"dotenv\", Dotenv::VERSION\n  gem.add_dependency \"railties\", \">= 6.1\"\n\n  gem.add_development_dependency \"spring\"\n\n  gem.metadata = {\n    \"changelog_uri\" => \"https://github.com/bkeepers/dotenv/releases\",\n    \"funding_uri\" => \"https://github.com/sponsors/bkeepers\"\n  }\nend\n"
  },
  {
    "path": "dotenv.gemspec",
    "content": "require File.expand_path(\"../lib/dotenv/version\", __FILE__)\nrequire \"English\"\n\nGem::Specification.new \"dotenv\", Dotenv::VERSION do |gem|\n  gem.authors = [\"Brandon Keepers\"]\n  gem.email = [\"brandon@opensoul.org\"]\n  gem.description = gem.summary = \"Loads environment variables from `.env`.\"\n  gem.homepage = \"https://github.com/bkeepers/dotenv\"\n  gem.license = \"MIT\"\n\n  gem.files = `git ls-files README.md LICENSE lib bin | grep -v dotenv-rails.rb`.split(\"\\n\")\n  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }\n\n  gem.add_development_dependency \"rake\"\n  gem.add_development_dependency \"rspec\"\n  gem.add_development_dependency \"standard\"\n\n  gem.required_ruby_version = \">= 3.0\"\n\n  gem.metadata = {\n    \"changelog_uri\" => \"https://github.com/bkeepers/dotenv/releases\",\n    \"funding_uri\" => \"https://github.com/sponsors/bkeepers\"\n  }\nend\n"
  },
  {
    "path": "lib/dotenv/autorestore.rb",
    "content": "# Automatically restore `ENV` to its original state after\n\nif defined?(RSpec.configure)\n  RSpec.configure do |config|\n    # Save ENV before the suite starts\n    config.before(:suite) { Dotenv.save }\n\n    # Restore ENV after each example\n    config.after { Dotenv.restore }\n  end\nend\n\nif defined?(ActiveSupport)\n  ActiveSupport.on_load(:active_support_test_case) do\n    ActiveSupport::TestCase.class_eval do\n      # Save ENV before each test\n      setup { Dotenv.save }\n\n      # Restore ENV after each test\n      teardown do\n        Dotenv.restore\n      rescue ThreadError => e\n        # Restore will fail if running tests in parallel.\n        warn e.message\n        warn \"Set `config.dotenv.autorestore = false` in `config/initializers/test.rb`\" if defined?(Dotenv::Rails)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/dotenv/cli.rb",
    "content": "require \"dotenv\"\nrequire \"dotenv/version\"\nrequire \"dotenv/template\"\nrequire \"optparse\"\n\nmodule Dotenv\n  # The `dotenv` command line interface. Run `$ dotenv --help` to see usage.\n  class CLI < OptionParser\n    attr_reader :argv, :filenames, :overwrite\n\n    def initialize(argv = [])\n      @argv = argv.dup\n      @filenames = []\n      @ignore = false\n      @overwrite = false\n\n      super(\"Usage: dotenv [options]\")\n      separator \"\"\n\n      on(\"-f FILES\", Array, \"List of env files to parse\") do |list|\n        @filenames = list\n      end\n\n      on(\"-i\", \"--ignore\", \"ignore missing env files\") do\n        @ignore = true\n      end\n\n      on(\"-o\", \"--overwrite\", \"overwrite existing ENV variables\") do\n        @overwrite = true\n      end\n      on(\"--overload\") { @overwrite = true }\n\n      on(\"-h\", \"--help\", \"Display help\") do\n        puts self\n        exit\n      end\n\n      on(\"-v\", \"--version\", \"Show version\") do\n        puts \"dotenv #{Dotenv::VERSION}\"\n        exit\n      end\n\n      on(\"-t\", \"--template=FILE\", \"Create a template env file\") do |file|\n        template = Dotenv::EnvTemplate.new(file)\n        template.create_template\n      end\n\n      order!(@argv)\n    end\n\n    def run\n      Dotenv.load(*@filenames, overwrite: @overwrite, ignore: @ignore)\n    rescue Errno::ENOENT => e\n      abort e.message\n    else\n      exec(*@argv) unless @argv.empty?\n    end\n  end\nend\n"
  },
  {
    "path": "lib/dotenv/diff.rb",
    "content": "module Dotenv\n  # A diff between multiple states of ENV.\n  class Diff\n    # The initial state\n    attr_reader :a\n\n    # The final or current state\n    attr_reader :b\n\n    # Create a new diff. If given a block, the state of ENV after the block will be preserved as\n    # the final state for comparison. Otherwise, the current ENV will be the final state.\n    #\n    # @param a [Hash] the initial state, defaults to a snapshot of current ENV\n    # @param b [Hash] the final state, defaults to the current ENV\n    # @yield [diff] a block to execute before recording the final state\n    def initialize(a: snapshot, b: ENV, &block)\n      @a, @b = a, b\n      block&.call self\n    ensure\n      @b = snapshot if block\n    end\n\n    # Return a Hash of keys added with their new values\n    def added\n      b.slice(*(b.keys - a.keys))\n    end\n\n    # Returns a Hash of keys removed with their previous values\n    def removed\n      a.slice(*(a.keys - b.keys))\n    end\n\n    # Returns of Hash of keys changed with an array of their previous and new values\n    def changed\n      (b.slice(*a.keys).to_a - a.to_a).map do |(k, v)|\n        [k, [a[k], v]]\n      end.to_h\n    end\n\n    # Returns a Hash of all added, changed, and removed keys and their new values\n    def env\n      b.slice(*(added.keys + changed.keys)).merge(removed.transform_values { |v| nil })\n    end\n\n    # Returns true if any keys were added, removed, or changed\n    def any?\n      [added, removed, changed].any?(&:any?)\n    end\n\n    private\n\n    def snapshot\n      # `dup` should not be required here, but some people use `stub_const` to replace ENV with\n      # a `Hash`. This ensures that we get a frozen copy of that instead of freezing the original.\n      # https://github.com/bkeepers/dotenv/issues/482\n      ENV.to_h.dup.freeze\n    end\n  end\nend\n"
  },
  {
    "path": "lib/dotenv/environment.rb",
    "content": "module Dotenv\n  # A `.env` file that will be read and parsed into a Hash\n  class Environment < Hash\n    attr_reader :filename, :overwrite\n\n    # Create a new Environment\n    #\n    # @param filename [String] the path to the file to read\n    # @param overwrite [Boolean] whether the parser should assume existing values will be overwritten\n    def initialize(filename, overwrite: false)\n      super()\n      @filename = filename\n      @overwrite = overwrite\n      load\n    end\n\n    def load\n      update Parser.call(read, overwrite: overwrite)\n    end\n\n    def read\n      File.open(@filename, \"rb:bom|utf-8\", &:read)\n    end\n  end\nend\n"
  },
  {
    "path": "lib/dotenv/load.rb",
    "content": "require \"dotenv\"\n\ndefined?(Dotenv::Rails) ? Dotenv::Rails.load : Dotenv.load\n"
  },
  {
    "path": "lib/dotenv/log_subscriber.rb",
    "content": "require \"active_support/log_subscriber\"\n\nmodule Dotenv\n  # Logs instrumented events\n  #\n  # Usage:\n  #   require \"active_support/notifications\"\n  #   require \"dotenv/log_subscriber\"\n  #   Dotenv.instrumenter = ActiveSupport::Notifications\n  #\n  class LogSubscriber < ActiveSupport::LogSubscriber\n    attach_to :dotenv\n\n    def logger\n      Dotenv::Rails.logger\n    end\n\n    def load(event)\n      env = event.payload[:env]\n\n      info \"Loaded #{color_filename(env.filename)}\"\n    end\n\n    def update(event)\n      diff = event.payload[:diff]\n      changed = diff.env.keys.map { |key| color_var(key) }\n      debug \"Set #{changed.join(\", \")}\" if diff.any?\n    end\n\n    def save(event)\n      info \"Saved a snapshot of #{color_env_constant}\"\n    end\n\n    def restore(event)\n      diff = event.payload[:diff]\n\n      removed = diff.removed.keys.map { |key| color(key, :RED) }\n      restored = (diff.changed.keys + diff.added.keys).map { |key| color_var(key) }\n\n      if removed.any? || restored.any?\n        info \"Restored snapshot of #{color_env_constant}\"\n        debug \"Unset #{removed.join(\", \")}\" if removed.any?\n        debug \"Restored #{restored.join(\", \")}\" if restored.any?\n      end\n    end\n\n    private\n\n    def color_filename(filename)\n      color(Pathname.new(filename).relative_path_from(Dotenv::Rails.root.to_s).to_s, :YELLOW)\n    end\n\n    def color_var(name)\n      color(name, :CYAN)\n    end\n\n    def color_env_constant\n      color(\"ENV\", :GREEN)\n    end\n  end\nend\n"
  },
  {
    "path": "lib/dotenv/missing_keys.rb",
    "content": "module Dotenv\n  class Error < StandardError; end\n\n  class MissingKeys < Error # :nodoc:\n    def initialize(keys)\n      key_word = \"key#{\"s\" if keys.size > 1}\"\n      super(\"Missing required configuration #{key_word}: #{keys.inspect}\")\n    end\n  end\nend\n"
  },
  {
    "path": "lib/dotenv/parser.rb",
    "content": "require \"dotenv/substitutions/variable\"\nrequire \"dotenv/substitutions/command\" if RUBY_VERSION > \"1.8.7\"\n\nmodule Dotenv\n  # Error raised when encountering a syntax error while parsing a .env file.\n  class FormatError < SyntaxError; end\n\n  # Parses the `.env` file format into key/value pairs.\n  # It allows for variable substitutions, command substitutions, and exporting of variables.\n  class Parser\n    @substitutions = [\n      Dotenv::Substitutions::Command,\n      Dotenv::Substitutions::Variable\n    ]\n\n    LINE = /\n      (?:^|\\A)                # beginning of line\n      \\s*                     # leading whitespace\n      (?<export>export\\s+)?   # optional export\n      (?<key>[\\w.]+)          # key\n      (?:                     # optional separator and value\n        (?:\\s*=\\s*?|:\\s+?)    #   separator\n        (?<value>             #   optional value begin\n          \\s*'(?:\\\\'|[^'])*'  #     single quoted value\n          |                   #     or\n          \\s*\"(?:\\\\\"|[^\"])*\"  #     double quoted value\n          |                   #     or\n          [^\\#\\n]+            #     unquoted value\n        )?                    #   value end\n      )?                      # separator and value end\n      \\s*                     # trailing whitespace\n      (?:\\#.*)?               # optional comment\n      (?:$|\\z)                # end of line\n    /x\n\n    QUOTED_STRING = /\\A(['\"])(.*)\\1\\z/m\n\n    class << self\n      attr_reader :substitutions\n\n      def call(...)\n        new(...).call\n      end\n    end\n\n    def initialize(string, overwrite: false)\n      # Convert line breaks to same format\n      @string = string.gsub(/\\r\\n?/, \"\\n\")\n      @hash = {}\n      @overwrite = overwrite\n    end\n\n    def call\n      @string.scan(LINE) do\n        match = $LAST_MATCH_INFO\n\n        if existing?(match[:key])\n          # Use value from already defined variable\n          @hash[match[:key]] = ENV[match[:key]]\n        elsif match[:export] && !match[:value]\n          # Check for exported variable with no value\n          if !@hash.member?(match[:key])\n            raise FormatError, \"Line #{match.to_s.inspect} has an unset variable\"\n          end\n        else\n          @hash[match[:key]] = parse_value(match[:value] || \"\")\n        end\n      end\n\n      @hash\n    end\n\n    private\n\n    # Determine if a variable is already defined and should not be overwritten.\n    def existing?(key)\n      !@overwrite && key != \"DOTENV_LINEBREAK_MODE\" && ENV.key?(key)\n    end\n\n    def parse_value(value)\n      # Remove surrounding quotes\n      value = value.strip.sub(QUOTED_STRING, '\\2')\n      maybe_quote = Regexp.last_match(1)\n\n      # Expand new lines in double quoted values\n      value = expand_newlines(value) if maybe_quote == '\"'\n\n      # Unescape characters and performs substitutions unless value is single quoted\n      if maybe_quote != \"'\"\n        value = unescape_characters(value)\n        self.class.substitutions.each { |proc| value = proc.call(value, @hash) }\n      end\n\n      value\n    end\n\n    def unescape_characters(value)\n      value.gsub(/\\\\([^$])/, '\\1')\n    end\n\n    def expand_newlines(value)\n      if (@hash[\"DOTENV_LINEBREAK_MODE\"] || ENV[\"DOTENV_LINEBREAK_MODE\"]) == \"legacy\"\n        value.gsub('\\n', \"\\n\").gsub('\\r', \"\\r\")\n      else\n        value.gsub('\\n', \"\\\\\\\\\\\\n\").gsub('\\r', \"\\\\\\\\\\\\r\")\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/dotenv/rails-now.rb",
    "content": "# If you use gems that require environment variables to be set before they are\n# loaded, then list `dotenv` in the `Gemfile` before those other gems and\n# require `dotenv/load`.\n#\n#     gem \"dotenv\", require: \"dotenv/load\"\n#     gem \"gem-that-requires-env-variables\"\n#\n\nrequire \"dotenv/load\"\nwarn '[DEPRECATION] `require \"dotenv/rails-now\"` is deprecated. Use `require \"dotenv/load\"` instead.', caller(1..1).first\n"
  },
  {
    "path": "lib/dotenv/rails.rb",
    "content": "# Since rubygems doesn't support optional dependencies, we have to manually check\nunless Gem::Requirement.new(\">= 6.1\").satisfied_by?(Gem::Version.new(Rails.version))\n  warn \"dotenv 3.0 only supports Rails 6.1 or later. Use dotenv ~> 2.0.\"\n  return\nend\n\nrequire \"dotenv/replay_logger\"\nrequire \"dotenv/log_subscriber\"\n\nDotenv.instrumenter = ActiveSupport::Notifications\n\n# Watch all loaded env files with Spring\nActiveSupport::Notifications.subscribe(\"load.dotenv\") do |*args|\n  if defined?(Spring) && Spring.respond_to?(:watch)\n    event = ActiveSupport::Notifications::Event.new(*args)\n    Spring.watch event.payload[:env].filename if Rails.application\n  end\nend\n\nmodule Dotenv\n  # Rails integration for using Dotenv to load ENV variables from a file\n  class Rails < ::Rails::Railtie\n    delegate :files, :files=, :overwrite, :overwrite=, :autorestore, :autorestore=, :logger, to: \"config.dotenv\"\n\n    def initialize\n      super\n      config.dotenv = ActiveSupport::OrderedOptions.new.update(\n        # Rails.logger is not available yet, so we'll save log messages and replay them when it is\n        logger: Dotenv::ReplayLogger.new,\n        overwrite: false,\n        files: [\n          \".env.#{env}.local\",\n          (\".env.local\" unless env.test?),\n          \".env.#{env}\",\n          \".env\"\n        ].compact,\n        autorestore: env.test? && !defined?(ClimateControl) && !defined?(IceAge)\n      )\n    end\n\n    # Public: Load dotenv\n    #\n    # This will get called during the `before_configuration` callback, but you\n    # can manually call `Dotenv::Rails.load` if you needed it sooner.\n    def load\n      Dotenv.load(*files.map { |file| root.join(file).to_s }, overwrite: overwrite)\n    end\n\n    def overload\n      deprecator.warn(\"Dotenv::Rails.overload is deprecated. Set `Dotenv::Rails.overwrite = true` and call Dotenv::Rails.load instead.\")\n      Dotenv.load(*files.map { |file| root.join(file).to_s }, overwrite: true)\n    end\n\n    # Internal: `Rails.root` is nil in Rails 4.1 before the application is\n    # initialized, so this falls back to the `RAILS_ROOT` environment variable,\n    # or the current working directory.\n    def root\n      ::Rails.root || Pathname.new(ENV[\"RAILS_ROOT\"] || Dir.pwd)\n    end\n\n    # Set a new logger and replay logs\n    def logger=(new_logger)\n      logger.replay new_logger if logger.is_a?(ReplayLogger)\n      config.dotenv.logger = new_logger\n    end\n\n    # The current environment that the app is running in.\n    #\n    # When running `rake`, the Rails application is initialized in development, so we have to\n    # check which rake tasks are being run to determine the environment.\n    #\n    # See https://github.com/bkeepers/dotenv/issues/219\n    def env\n      @env ||= if defined?(Rake.application) && Rake.application.top_level_tasks.grep(TEST_RAKE_TASKS).any?\n        env = Rake.application.options.show_tasks ? \"development\" : \"test\"\n        ActiveSupport::EnvironmentInquirer.new(env)\n      else\n        ::Rails.env\n      end\n    end\n    TEST_RAKE_TASKS = /^(default$|test(:|$)|parallel:spec|spec(:|$))/\n\n    def deprecator # :nodoc:\n      @deprecator ||= ActiveSupport::Deprecation.new\n    end\n\n    # Rails uses `#method_missing` to delegate all class methods to the\n    # instance, which means `Kernel#load` gets called here. We don't want that.\n    def self.load\n      instance.load\n    end\n\n    initializer \"dotenv\", after: :initialize_logger do |app|\n      if logger.is_a?(ReplayLogger)\n        self.logger = ActiveSupport::TaggedLogging.new(::Rails.logger).tagged(\"dotenv\")\n      end\n    end\n\n    initializer \"dotenv.deprecator\" do |app|\n      app.deprecators[:dotenv] = deprecator if app.respond_to?(:deprecators)\n    end\n\n    initializer \"dotenv.autorestore\" do |app|\n      require \"dotenv/autorestore\" if autorestore\n    end\n\n    config.before_configuration { load }\n  end\n\n  Railtie = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(\"Dotenv::Railtie\", \"Dotenv::Rails\", Dotenv::Rails.deprecator)\nend\n"
  },
  {
    "path": "lib/dotenv/replay_logger.rb",
    "content": "module Dotenv\n  # A logger that can be used before the apps real logger is initialized.\n  class ReplayLogger < Logger\n    def initialize\n      super(nil) # Doesn't matter what this is, it won't be used.\n      @logs = []\n    end\n\n    # Override the add method to store logs so we can replay them to a real logger later.\n    def add(*args, &block)\n      @logs.push([args, block])\n    end\n\n    # Replay the store logs to a real logger.\n    def replay(logger)\n      @logs.each { |args, block| logger.add(*args, &block) }\n      @logs.clear\n    end\n  end\nend\n"
  },
  {
    "path": "lib/dotenv/substitutions/command.rb",
    "content": "require \"English\"\n\nmodule Dotenv\n  module Substitutions\n    # Substitute shell commands in a value.\n    #\n    #   SHA=$(git rev-parse HEAD)\n    #\n    module Command\n      class << self\n        INTERPOLATED_SHELL_COMMAND = /\n          (?<backslash>\\\\)?   # is it escaped with a backslash?\n          \\$                  # literal $\n          (?<cmd>             # collect command content for eval\n            \\(                # require opening paren\n            (?:[^()]|\\g<cmd>)+  # allow any number of non-parens, or balanced\n                              # parens (by nesting the <cmd> expression\n                              # recursively)\n            \\)                # require closing paren\n          )\n        /x\n\n        def call(value, env)\n          # Process interpolated shell commands\n          value.gsub(INTERPOLATED_SHELL_COMMAND) do |*|\n            # Eliminate opening and closing parentheses\n            command = $LAST_MATCH_INFO[:cmd][1..-2]\n\n            if $LAST_MATCH_INFO[:backslash]\n              # Command is escaped, don't replace it.\n              $LAST_MATCH_INFO[0][1..]\n            else\n              # Execute the command and return the value\n              `#{Variable.call(command, env)}`.chomp\n            end\n          end\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/dotenv/substitutions/variable.rb",
    "content": "require \"English\"\n\nmodule Dotenv\n  module Substitutions\n    # Substitute variables in a value.\n    #\n    #   HOST=example.com\n    #   URL=\"https://$HOST\"\n    #\n    module Variable\n      class << self\n        VARIABLE = /\n          (\\\\)?         # is it escaped with a backslash?\n          (\\$)          # literal $\n          (?!\\()        # shouldn't be followed by parenthesis\n          \\{?           # allow brace wrapping\n          ([A-Z0-9_]+)? # optional alpha nums\n          \\}?           # closing brace\n        /xi\n\n        def call(value, env)\n          value.gsub(VARIABLE) do |variable|\n            match = $LAST_MATCH_INFO\n\n            if match[1] == \"\\\\\"\n              variable[1..]\n            elsif match[3]\n              env[match[3]] || ENV[match[3]] || \"\"\n            else\n              variable\n            end\n          end\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/dotenv/tasks.rb",
    "content": "desc \"Load environment settings from .env\"\ntask :dotenv do\n  require \"dotenv\"\n  Dotenv.load\nend\n\ntask environment: :dotenv\n"
  },
  {
    "path": "lib/dotenv/template.rb",
    "content": "module Dotenv\n  EXPORT_COMMAND = \"export \".freeze\n  # Class for creating a template from a env file\n  class EnvTemplate\n    def initialize(env_file)\n      @env_file = env_file\n    end\n\n    def create_template\n      File.open(@env_file, \"r\") do |env_file|\n        File.open(\"#{@env_file}.template\", \"w\") do |env_template|\n          env_file.each do |line|\n            if is_comment?(line)\n              env_template.puts line\n            elsif (var = var_defined?(line))\n              if line.match(EXPORT_COMMAND)\n                env_template.puts \"export #{var}=#{var}\"\n              else\n                env_template.puts \"#{var}=#{var}\"\n              end\n            elsif line_blank?(line)\n              env_template.puts\n            end\n          end\n        end\n      end\n    end\n\n    private\n\n    def is_comment?(line)\n      line.strip.start_with?(\"#\")\n    end\n\n    def var_defined?(line)\n      match = Dotenv::Parser::LINE.match(line)\n      match && match[:key]\n    end\n\n    def line_blank?(line)\n      line.strip.length.zero?\n    end\n  end\nend\n"
  },
  {
    "path": "lib/dotenv/version.rb",
    "content": "module Dotenv\n  VERSION = \"3.2.0\".freeze\nend\n"
  },
  {
    "path": "lib/dotenv-rails.rb",
    "content": "require \"dotenv\"\n"
  },
  {
    "path": "lib/dotenv.rb",
    "content": "require \"dotenv/version\"\nrequire \"dotenv/parser\"\nrequire \"dotenv/environment\"\nrequire \"dotenv/missing_keys\"\nrequire \"dotenv/diff\"\n\n# Shim to load environment variables from `.env files into `ENV`.\nmodule Dotenv\n  extend self\n\n  # An internal monitor to synchronize access to ENV in multi-threaded environments.\n  SEMAPHORE = Monitor.new\n  private_constant :SEMAPHORE\n\n  attr_accessor :instrumenter\n\n  # Loads environment variables from one or more `.env` files. See `#parse` for more details.\n  def load(*filenames, overwrite: false, ignore: true)\n    parse(*filenames, overwrite: overwrite, ignore: ignore) do |env|\n      instrument(:load, env: env) do |payload|\n        update(env, overwrite: overwrite)\n      end\n    end\n  end\n\n  # Same as `#load`, but raises Errno::ENOENT if any files don't exist\n  def load!(*filenames)\n    load(*filenames, ignore: false)\n  end\n\n  # same as `#load`, but will overwrite existing values in `ENV`\n  def overwrite(*filenames)\n    load(*filenames, overwrite: true)\n  end\n  alias_method :overload, :overwrite\n\n  # same as `#overwrite`, but raises Errno::ENOENT if any files don't exist\n  def overwrite!(*filenames)\n    load(*filenames, overwrite: true, ignore: false)\n  end\n  alias_method :overload!, :overwrite!\n\n  # Parses the given files, yielding for each file if a block is given.\n  #\n  # @param filenames [String, Array<String>] Files to parse\n  # @param overwrite [Boolean] Overwrite existing `ENV` values\n  # @param ignore [Boolean] Ignore non-existent files\n  # @param block [Proc] Block to yield for each parsed `Dotenv::Environment`\n  # @return [Hash] parsed key/value pairs\n  def parse(*filenames, overwrite: false, ignore: true, &block)\n    filenames << \".env\" if filenames.empty?\n    filenames = filenames.reverse if overwrite\n\n    filenames.reduce({}) do |hash, filename|\n      begin\n        env = Environment.new(File.expand_path(filename), overwrite: overwrite)\n        env = block.call(env) if block\n      rescue Errno::ENOENT, Errno::EISDIR\n        raise unless ignore\n      end\n\n      hash.merge! env || {}\n    end\n  end\n\n  # Save the current `ENV` to be restored later\n  def save\n    instrument(:save) do |payload|\n      @diff = payload[:diff] = Dotenv::Diff.new\n    end\n  end\n\n  # Restore `ENV` to a given state\n  #\n  # @param env [Hash] Hash of keys and values to restore, defaults to the last saved state\n  # @param safe [Boolean] Is it safe to modify `ENV`? Defaults to `true` in the main thread, otherwise raises an error.\n  def restore(env = @diff&.a, safe: Thread.current == Thread.main)\n    # No previously saved or provided state to restore\n    return unless env\n\n    diff = Dotenv::Diff.new(b: env)\n    return unless diff.any?\n\n    unless safe\n      raise ThreadError, <<~EOE.tr(\"\\n\", \" \")\n        Dotenv.restore is not thread safe. Use `Dotenv.modify { }` to update ENV for the duration\n        of the block in a thread safe manner, or call `Dotenv.restore(safe: true)` to ignore\n        this error.\n      EOE\n    end\n    instrument(:restore, diff: diff) { ENV.replace(env) }\n  end\n\n  # Update `ENV` with the given hash of keys and values\n  #\n  # @param env [Hash] Hash of keys and values to set in `ENV`\n  # @param overwrite [Boolean|:warn] Overwrite existing `ENV` values\n  def update(env = {}, overwrite: false)\n    instrument(:update) do |payload|\n      diff = payload[:diff] = Dotenv::Diff.new do\n        ENV.update(env.transform_keys(&:to_s)) do |key, old_value, new_value|\n          # This block is called when a key exists. Return the new value if overwrite is true.\n          case overwrite\n          when :warn\n            # not printing the value since that could be a secret\n            warn \"Warning: dotenv not overwriting ENV[#{key.inspect}]\"\n            old_value\n          when true then new_value\n          when false then old_value\n          else raise ArgumentError, \"Invalid value for overwrite: #{overwrite.inspect}\"\n          end\n        end\n      end\n      diff.env\n    end\n  end\n\n  # Modify `ENV` for the block and restore it to its previous state afterwards.\n  #\n  # Note that the block is synchronized to prevent concurrent modifications to `ENV`,\n  # so multiple threads will be executed serially.\n  #\n  # @param env [Hash] Hash of keys and values to set in `ENV`\n  def modify(env = {}, &block)\n    SEMAPHORE.synchronize do\n      diff = Dotenv::Diff.new\n      update(env, overwrite: true)\n      block.call\n    ensure\n      restore(diff.a, safe: true)\n    end\n  end\n\n  def require_keys(*keys)\n    missing_keys = keys.flatten - ::ENV.keys\n    return if missing_keys.empty?\n    raise MissingKeys, missing_keys\n  end\n\n  private\n\n  def instrument(name, payload = {}, &block)\n    if instrumenter\n      instrumenter.instrument(\"#{name}.dotenv\", payload, &block)\n    else\n      block&.call payload\n    end\n  end\nend\n\nrequire \"dotenv/rails\" if defined?(Rails::Railtie)\n"
  },
  {
    "path": "spec/dotenv/cli_spec.rb",
    "content": "require \"spec_helper\"\nrequire \"dotenv/cli\"\n\ndescribe \"dotenv binary\" do\n  before do\n    Dir.chdir(File.expand_path(\"../../fixtures\", __FILE__))\n  end\n\n  def run(*args)\n    Dotenv::CLI.new(args).run\n  end\n\n  it \"loads from .env by default\" do\n    expect(ENV).not_to have_key(\"DOTENV\")\n    run\n    expect(ENV).to have_key(\"DOTENV\")\n  end\n\n  it \"loads from file specified by -f\" do\n    expect(ENV).not_to have_key(\"OPTION_A\")\n    run \"-f\", \"plain.env\"\n    expect(ENV).to have_key(\"OPTION_A\")\n  end\n\n  it \"dies if file specified by -f doesn't exist\" do\n    expect do\n      capture_output { run \"-f\", \".doesnotexist\" }\n    end.to raise_error(SystemExit, /No such file/)\n  end\n\n  it \"ignores missing files when --ignore flag given\" do\n    expect do\n      run \"--ignore\", \"-f\", \".doesnotexist\"\n    end.not_to raise_error\n  end\n\n  it \"loads from multiple files specified by -f\" do\n    expect(ENV).not_to have_key(\"PLAIN\")\n    expect(ENV).not_to have_key(\"QUOTED\")\n\n    run \"-f\", \"plain.env,quoted.env\"\n\n    expect(ENV).to have_key(\"PLAIN\")\n    expect(ENV).to have_key(\"QUOTED\")\n  end\n\n  it \"does not consume non-dotenv flags by accident\" do\n    cli = Dotenv::CLI.new([\"-f\", \"plain.env\", \"foo\", \"--switch\"])\n\n    expect(cli.filenames).to eql([\"plain.env\"])\n    expect(cli.argv).to eql([\"foo\", \"--switch\"])\n  end\n\n  it \"does not consume dotenv flags from subcommand\" do\n    cli = Dotenv::CLI.new([\"foo\", \"-f\", \"something\"])\n\n    expect(cli.filenames).to eql([])\n    expect(cli.argv).to eql([\"foo\", \"-f\", \"something\"])\n  end\n\n  it \"does not mess with quoted args\" do\n    cli = Dotenv::CLI.new([\"foo something\"])\n\n    expect(cli.filenames).to eql([])\n    expect(cli.argv).to eql([\"foo something\"])\n  end\n\n  describe \"templates a file specified by -t\" do\n    before do\n      @buffer = StringIO.new\n      @origin_filename = \"plain.env\"\n      @template_filename = \"plain.env.template\"\n    end\n    it \"templates variables\" do\n      @input = StringIO.new(\"FOO=BAR\\nFOO2=BAR2\")\n      allow(File).to receive(:open).with(@origin_filename, \"r\").and_yield(@input)\n      allow(File).to receive(:open).with(@template_filename, \"w\").and_yield(@buffer)\n      # call the function that writes to the file\n      Dotenv::CLI.new([\"-t\", @origin_filename])\n      # reading the buffer and checking its content.\n      expect(@buffer.string).to eq(\"FOO=FOO\\nFOO2=FOO2\\n\")\n    end\n\n    it \"templates variables with export prefix\" do\n      @input = StringIO.new(\"export FOO=BAR\\nexport FOO2=BAR2\")\n      allow(File).to receive(:open).with(@origin_filename, \"r\").and_yield(@input)\n      allow(File).to receive(:open).with(@template_filename, \"w\").and_yield(@buffer)\n      Dotenv::CLI.new([\"-t\", @origin_filename])\n      expect(@buffer.string).to eq(\"export FOO=FOO\\nexport FOO2=FOO2\\n\")\n    end\n\n    it \"templates multi-line variables\" do\n      @input = StringIO.new(<<~TEXT)\n        FOO=BAR\n        FOO2=\"BAR2\n        BAR2\"\n      TEXT\n      allow(File).to receive(:open).with(@origin_filename, \"r\").and_yield(@input)\n      allow(File).to receive(:open).with(@template_filename, \"w\").and_yield(@buffer)\n      # call the function that writes to the file\n      Dotenv::CLI.new([\"-t\", @origin_filename])\n      # reading the buffer and checking its content.\n      expect(@buffer.string).to eq(\"FOO=FOO\\nFOO2=FOO2\\n\")\n    end\n\n    it \"ignores blank lines\" do\n      @input = StringIO.new(\"\\nFOO=BAR\\nFOO2=BAR2\")\n      allow(File).to receive(:open).with(@origin_filename, \"r\").and_yield(@input)\n      allow(File).to receive(:open).with(@template_filename, \"w\").and_yield(@buffer)\n      Dotenv::CLI.new([\"-t\", @origin_filename])\n      expect(@buffer.string).to eq(\"\\nFOO=FOO\\nFOO2=FOO2\\n\")\n    end\n\n    it \"ignores comments\" do\n      @comment_input = StringIO.new(\"#Heading comment\\nFOO=BAR\\nFOO2=BAR2\\n\")\n      allow(File).to receive(:open).with(@origin_filename, \"r\").and_yield(@comment_input)\n      allow(File).to receive(:open).with(@template_filename, \"w\").and_yield(@buffer)\n      Dotenv::CLI.new([\"-t\", @origin_filename])\n      expect(@buffer.string).to eq(\"#Heading comment\\nFOO=FOO\\nFOO2=FOO2\\n\")\n    end\n\n    it \"ignores comments with =\" do\n      @comment_with_equal_input = StringIO.new(\"#Heading=comment\\nFOO=BAR\\nFOO2=BAR2\")\n      allow(File).to receive(:open).with(@origin_filename, \"r\").and_yield(@comment_with_equal_input)\n      allow(File).to receive(:open).with(@template_filename, \"w\").and_yield(@buffer)\n      Dotenv::CLI.new([\"-t\", @origin_filename])\n      expect(@buffer.string).to eq(\"#Heading=comment\\nFOO=FOO\\nFOO2=FOO2\\n\")\n    end\n\n    it \"ignores comments with leading spaces\" do\n      @comment_leading_spaces_input = StringIO.new(\"  #Heading comment\\nFOO=BAR\\nFOO2=BAR2\")\n      allow(File).to receive(:open).with(@origin_filename, \"r\").and_yield(@comment_leading_spaces_input)\n      allow(File).to receive(:open).with(@template_filename, \"w\").and_yield(@buffer)\n      Dotenv::CLI.new([\"-t\", @origin_filename])\n      expect(@buffer.string).to eq(\"  #Heading comment\\nFOO=FOO\\nFOO2=FOO2\\n\")\n    end\n  end\nend\n"
  },
  {
    "path": "spec/dotenv/diff_spec.rb",
    "content": "require \"spec_helper\"\n\ndescribe Dotenv::Diff do\n  let(:before) { {} }\n  let(:after) { {} }\n  subject { Dotenv::Diff.new(a: before, b: after) }\n\n  context \"no changes\" do\n    let(:before) { {\"A\" => 1} }\n    let(:after) { {\"A\" => 1} }\n\n    it { expect(subject.added).to eq({}) }\n    it { expect(subject.removed).to eq({}) }\n    it { expect(subject.changed).to eq({}) }\n    it { expect(subject.any?).to eq(false) }\n    it { expect(subject.env).to eq({}) }\n  end\n\n  context \"key added\" do\n    let(:after) { {\"A\" => 1} }\n\n    it { expect(subject.added).to eq(\"A\" => 1) }\n    it { expect(subject.removed).to eq({}) }\n    it { expect(subject.changed).to eq({}) }\n    it { expect(subject.any?).to eq(true) }\n    it { expect(subject.env).to eq(\"A\" => 1) }\n  end\n\n  context \"key removed\" do\n    let(:before) { {\"A\" => 1} }\n\n    it { expect(subject.added).to eq({}) }\n    it { expect(subject.removed).to eq(\"A\" => 1) }\n    it { expect(subject.changed).to eq({}) }\n    it { expect(subject.any?).to eq(true) }\n    it { expect(subject.env).to eq(\"A\" => nil) }\n  end\n\n  context \"key changed\" do\n    let(:before) { {\"A\" => 1} }\n    let(:after) { {\"A\" => 2} }\n\n    it { expect(subject.added).to eq({}) }\n    it { expect(subject.removed).to eq({}) }\n    it { expect(subject.changed).to eq(\"A\" => [1, 2]) }\n    it { expect(subject.any?).to eq(true) }\n    it { expect(subject.env).to eq(\"A\" => 2) }\n  end\nend\n"
  },
  {
    "path": "spec/dotenv/environment_spec.rb",
    "content": "require \"spec_helper\"\n\ndescribe Dotenv::Environment do\n  subject { env(\"OPTION_A=1\\nOPTION_B=2\") }\n\n  describe \"initialize\" do\n    it \"reads the file\" do\n      expect(subject[\"OPTION_A\"]).to eq(\"1\")\n      expect(subject[\"OPTION_B\"]).to eq(\"2\")\n    end\n\n    it \"fails if file does not exist\" do\n      expect do\n        Dotenv::Environment.new(\".does_not_exists\")\n      end.to raise_error(Errno::ENOENT)\n    end\n  end\n\n  require \"tempfile\"\n  def env(text, ...)\n    file = Tempfile.new(\"dotenv\")\n    file.write text\n    file.close\n    env = Dotenv::Environment.new(file.path, ...)\n    file.unlink\n    env\n  end\nend\n"
  },
  {
    "path": "spec/dotenv/log_subscriber_spec.rb",
    "content": "require \"spec_helper\"\nrequire \"active_support/all\"\nrequire \"rails\"\nrequire \"dotenv/rails\"\n\ndescribe Dotenv::LogSubscriber do\n  let(:logs) { StringIO.new }\n\n  before do\n    Dotenv.instrumenter = ActiveSupport::Notifications\n    Dotenv::Rails.logger = Logger.new(logs)\n  end\n\n  describe \"load\" do\n    it \"logs when a file is loaded\" do\n      Dotenv.load(fixture_path(\"plain.env\"))\n      expect(logs.string).to match(/Loaded.*plain.env/)\n      expect(logs.string).to match(/Set.*PLAIN/)\n    end\n  end\n\n  context \"update\" do\n    it \"logs when a new instance variable is set\" do\n      Dotenv.update({\"PLAIN\" => \"true\"})\n      expect(logs.string).to match(/Set.*PLAIN/)\n    end\n\n    it \"logs when an instance variable is overwritten\" do\n      ENV[\"PLAIN\"] = \"nope\"\n      Dotenv.update({\"PLAIN\" => \"true\"}, overwrite: true)\n      expect(logs.string).to match(/Set.*PLAIN/)\n    end\n\n    it \"does not log when an instance variable is not overwritten\" do\n      ENV[\"FOO\"] = \"existing\"\n      Dotenv.update({\"FOO\" => \"new\"})\n      expect(logs.string).not_to match(/FOO/)\n    end\n\n    it \"does not log when an instance variable is unchanged\" do\n      ENV[\"PLAIN\"] = \"true\"\n      Dotenv.update({\"PLAIN\" => \"true\"}, overwrite: true)\n      expect(logs.string).not_to match(/PLAIN/)\n    end\n  end\n\n  context \"save\" do\n    it \"logs when a snapshot is saved\" do\n      Dotenv.save\n      expect(logs.string).to match(/Saved/)\n    end\n  end\n\n  context \"restore\" do\n    it \"logs restored keys\" do\n      previous_value = ENV[\"PWD\"]\n      ENV[\"PWD\"] = \"/tmp\"\n      Dotenv.restore\n\n      expect(logs.string).to match(/Restored.*PWD/)\n\n      # Does not log value\n      expect(logs.string).not_to include(previous_value)\n    end\n\n    it \"logs unset keys\" do\n      ENV[\"DOTENV_TEST\"] = \"LogSubscriber\"\n      Dotenv.restore\n      expect(logs.string).to match(/Unset.*DOTENV_TEST/)\n    end\n\n    it \"does not log if no keys unset or restored\" do\n      Dotenv.restore\n      expect(logs.string).not_to match(/Restored|Unset/)\n    end\n  end\nend\n"
  },
  {
    "path": "spec/dotenv/parser_spec.rb",
    "content": "require \"spec_helper\"\n\ndescribe Dotenv::Parser do\n  def env(...)\n    Dotenv::Parser.call(...)\n  end\n\n  it \"parses unquoted values\" do\n    expect(env(\"FOO=bar\")).to eql(\"FOO\" => \"bar\")\n  end\n\n  it \"parses unquoted values with spaces after seperator\" do\n    expect(env(\"FOO= bar\")).to eql(\"FOO\" => \"bar\")\n  end\n\n  it \"parses unquoted escape characters correctly\" do\n    expect(env(\"FOO=bar\\\\ bar\")).to eql(\"FOO\" => \"bar bar\")\n  end\n\n  it \"parses values with spaces around equal sign\" do\n    expect(env(\"FOO =bar\")).to eql(\"FOO\" => \"bar\")\n    expect(env(\"FOO= bar\")).to eql(\"FOO\" => \"bar\")\n  end\n\n  it \"parses values with leading spaces\" do\n    expect(env(\"  FOO=bar\")).to eql(\"FOO\" => \"bar\")\n  end\n\n  it \"parses values with following spaces\" do\n    expect(env(\"FOO=bar  \")).to eql(\"FOO\" => \"bar\")\n  end\n\n  it \"parses double quoted values\" do\n    expect(env('FOO=\"bar\"')).to eql(\"FOO\" => \"bar\")\n  end\n\n  it \"parses double quoted values with following spaces\" do\n    expect(env('FOO=\"bar\"  ')).to eql(\"FOO\" => \"bar\")\n  end\n\n  it \"parses single quoted values\" do\n    expect(env(\"FOO='bar'\")).to eql(\"FOO\" => \"bar\")\n  end\n\n  it \"parses single quoted values with following spaces\" do\n    expect(env(\"FOO='bar'  \")).to eql(\"FOO\" => \"bar\")\n  end\n\n  it \"parses escaped double quotes\" do\n    expect(env('FOO=\"escaped\\\"bar\"')).to eql(\"FOO\" => 'escaped\"bar')\n  end\n\n  it \"parses empty values\" do\n    expect(env(\"FOO=\")).to eql(\"FOO\" => \"\")\n  end\n\n  it \"expands variables found in values\" do\n    expect(env(\"FOO=test\\nBAR=$FOO\")).to eql(\"FOO\" => \"test\", \"BAR\" => \"test\")\n  end\n\n  it \"parses variables wrapped in brackets\" do\n    expect(env(\"FOO=test\\nBAR=${FOO}bar\"))\n      .to eql(\"FOO\" => \"test\", \"BAR\" => \"testbar\")\n  end\n\n  it \"expands variables from ENV if not found in .env\" do\n    ENV[\"FOO\"] = \"test\"\n    expect(env(\"BAR=$FOO\")).to eql(\"BAR\" => \"test\")\n  end\n\n  it \"expands variables from ENV if found in .env during load\" do\n    ENV[\"FOO\"] = \"test\"\n    expect(env(\"FOO=development\\nBAR=${FOO}\")[\"BAR\"])\n      .to eql(\"test\")\n  end\n\n  it \"doesn't expand variables from ENV if in local env in overwrite\" do\n    ENV[\"FOO\"] = \"test\"\n    expect(env(\"FOO=development\\nBAR=${FOO}\")[\"BAR\"])\n      .to eql(\"test\")\n  end\n\n  it \"expands undefined variables to an empty string\" do\n    expect(env(\"BAR=$FOO\")).to eql(\"BAR\" => \"\")\n  end\n\n  it \"expands variables in double quoted strings\" do\n    expect(env(\"FOO=test\\nBAR=\\\"quote $FOO\\\"\"))\n      .to eql(\"FOO\" => \"test\", \"BAR\" => \"quote test\")\n  end\n\n  it \"does not expand variables in single quoted strings\" do\n    expect(env(\"BAR='quote $FOO'\")).to eql(\"BAR\" => \"quote $FOO\")\n  end\n\n  it \"does not expand escaped variables\" do\n    expect(env('FOO=\"foo\\$BAR\"')).to eql(\"FOO\" => \"foo$BAR\")\n    expect(env('FOO=\"foo\\${BAR}\"')).to eql(\"FOO\" => \"foo${BAR}\")\n    expect(env(\"FOO=test\\nBAR=\\\"foo\\\\${FOO} ${FOO}\\\"\"))\n      .to eql(\"FOO\" => \"test\", \"BAR\" => \"foo${FOO} test\")\n  end\n\n  it \"parses yaml style options\" do\n    expect(env(\"OPTION_A: 1\")).to eql(\"OPTION_A\" => \"1\")\n  end\n\n  it \"parses export keyword\" do\n    expect(env(\"export OPTION_A=2\")).to eql(\"OPTION_A\" => \"2\")\n  end\n\n  it \"allows export line if you want to do it that way\" do\n    expect(env('OPTION_A=2\nexport OPTION_A')).to eql(\"OPTION_A\" => \"2\")\n  end\n\n  it \"allows export line if you want to do it that way and checks for unset variables\" do\n    expect do\n      env('OPTION_A=2\nexport OH_NO_NOT_SET')\n    end.to raise_error(Dotenv::FormatError, 'Line \"export OH_NO_NOT_SET\" has an unset variable')\n  end\n\n  it 'escapes \\n in quoted strings' do\n    expect(env('FOO=\"bar\\nbaz\"')).to eql(\"FOO\" => \"bar\\\\nbaz\")\n    expect(env('FOO=\"bar\\\\nbaz\"')).to eql(\"FOO\" => \"bar\\\\nbaz\")\n  end\n\n  it 'expands \\n and \\r in quoted strings with DOTENV_LINEBREAK_MODE=legacy in current file' do\n    ENV[\"DOTENV_LINEBREAK_MODE\"] = \"strict\"\n\n    contents = [\n      \"DOTENV_LINEBREAK_MODE=legacy\",\n      'FOO=\"bar\\nbaz\\rfizz\"'\n    ].join(\"\\n\")\n    expect(env(contents)).to eql(\"DOTENV_LINEBREAK_MODE\" => \"legacy\", \"FOO\" => \"bar\\nbaz\\rfizz\")\n  end\n\n  it 'expands \\n and \\r in quoted strings with DOTENV_LINEBREAK_MODE=legacy in ENV' do\n    ENV[\"DOTENV_LINEBREAK_MODE\"] = \"legacy\"\n    contents = 'FOO=\"bar\\nbaz\\rfizz\"'\n    expect(env(contents)).to eql(\"FOO\" => \"bar\\nbaz\\rfizz\")\n  end\n\n  it 'parses variables with \".\" in the name' do\n    expect(env(\"FOO.BAR=foobar\")).to eql(\"FOO.BAR\" => \"foobar\")\n  end\n\n  it \"strips unquoted values\" do\n    expect(env(\"foo=bar \")).to eql(\"foo\" => \"bar\") # not 'bar '\n  end\n\n  it \"ignores lines that are not variable assignments\" do\n    expect(env(\"lol$wut\")).to eql({})\n  end\n\n  it \"ignores empty lines\" do\n    expect(env(\"\\n \\t  \\nfoo=bar\\n \\nfizz=buzz\"))\n      .to eql(\"foo\" => \"bar\", \"fizz\" => \"buzz\")\n  end\n\n  it \"does not ignore empty lines in quoted string\" do\n    value = \"a\\n\\nb\\n\\nc\"\n    expect(env(\"FOO=\\\"#{value}\\\"\")).to eql(\"FOO\" => value)\n  end\n\n  it \"ignores inline comments\" do\n    expect(env(\"foo=bar # this is foo\")).to eql(\"foo\" => \"bar\")\n  end\n\n  it \"allows # in quoted value\" do\n    expect(env('foo=\"bar#baz\" # comment')).to eql(\"foo\" => \"bar#baz\")\n  end\n\n  it \"allows # in quoted value with spaces after seperator\" do\n    expect(env('foo= \"bar#baz\" # comment')).to eql(\"foo\" => \"bar#baz\")\n  end\n\n  it \"ignores comment lines\" do\n    expect(env(\"\\n\\n\\n # HERE GOES FOO \\nfoo=bar\")).to eql(\"foo\" => \"bar\")\n  end\n\n  it \"ignores commented out variables\" do\n    expect(env(\"# HELLO=world\\n\")).to eql({})\n  end\n\n  it \"ignores comment\" do\n    expect(env(\"# Uncomment to activate:\\n\")).to eql({})\n  end\n\n  it \"includes variables without values\" do\n    input = 'DATABASE_PASSWORD=\nDATABASE_USERNAME=root\nDATABASE_HOST=/tmp/mysql.sock'\n\n    output = {\n      \"DATABASE_PASSWORD\" => \"\",\n      \"DATABASE_USERNAME\" => \"root\",\n      \"DATABASE_HOST\" => \"/tmp/mysql.sock\"\n    }\n\n    expect(env(input)).to eql(output)\n  end\n\n  it \"parses # in quoted values\" do\n    expect(env('foo=\"ba#r\"')).to eql(\"foo\" => \"ba#r\")\n    expect(env(\"foo='ba#r'\")).to eql(\"foo\" => \"ba#r\")\n  end\n\n  it \"parses # in quoted values with following spaces\" do\n    expect(env('foo=\"ba#r\"  ')).to eql(\"foo\" => \"ba#r\")\n    expect(env(\"foo='ba#r'  \")).to eql(\"foo\" => \"ba#r\")\n  end\n\n  it \"parses empty values\" do\n    expect(env(\"foo=\")).to eql(\"foo\" => \"\")\n  end\n\n  it \"allows multi-line values in single quotes\" do\n    env_file = %(OPTION_A=first line\nexport OPTION_B='line 1\nline 2\nline 3'\nOPTION_C=\"last line\"\nOPTION_ESCAPED='line one\nthis is \\\\'quoted\\\\'\none more line')\n\n    expected_result = {\n      \"OPTION_A\" => \"first line\",\n      \"OPTION_B\" => \"line 1\\nline 2\\nline 3\",\n      \"OPTION_C\" => \"last line\",\n      \"OPTION_ESCAPED\" => \"line one\\nthis is \\\\'quoted\\\\'\\none more line\"\n    }\n    expect(env(env_file)).to eql(expected_result)\n  end\n\n  it \"allows multi-line values in double quotes\" do\n    env_file = %(OPTION_A=first line\nexport OPTION_B=\"line 1\nline 2\nline 3\"\nOPTION_C=\"last line\"\nOPTION_ESCAPED=\"line one\nthis is \\\\\"quoted\\\\\"\none more line\")\n\n    expected_result = {\n      \"OPTION_A\" => \"first line\",\n      \"OPTION_B\" => \"line 1\\nline 2\\nline 3\",\n      \"OPTION_C\" => \"last line\",\n      \"OPTION_ESCAPED\" => \"line one\\nthis is \\\"quoted\\\"\\none more line\"\n    }\n    expect(env(env_file)).to eql(expected_result)\n  end\n\n  if RUBY_VERSION > \"1.8.7\"\n    it \"parses shell commands interpolated in $()\" do\n      expect(env(\"echo=$(echo hello)\")).to eql(\"echo\" => \"hello\")\n    end\n\n    it \"allows balanced parentheses within interpolated shell commands\" do\n      expect(env('echo=$(echo \"$(echo \"$(echo \"$(echo hello)\")\")\")'))\n        .to eql(\"echo\" => \"hello\")\n    end\n\n    it \"doesn't interpolate shell commands when escape says not to\" do\n      expect(env('echo=escaped-\\$(echo hello)'))\n        .to eql(\"echo\" => \"escaped-$(echo hello)\")\n    end\n\n    it \"is not thrown off by quotes in interpolated shell commands\" do\n      expect(env('interp=$(echo \"Quotes won\\'t be a problem\")')[\"interp\"])\n        .to eql(\"Quotes won't be a problem\")\n    end\n\n    it \"handles parentheses in variables in commands\" do\n      expect(env(\"FOO='passwo(rd'\\nBAR=$(echo '$FOO')\")).to eql(\"FOO\" => \"passwo(rd\", \"BAR\" => \"passwo(rd\")\n    end\n\n    it \"handles command to variable to command chain\" do\n      expect(env(\"FOO=$(echo bar)\\nBAR=$(echo $FOO)\")).to eql(\"FOO\" => \"bar\", \"BAR\" => \"bar\")\n    end\n\n    it \"supports carriage return\" do\n      expect(env(\"FOO=bar\\rbaz=fbb\")).to eql(\"FOO\" => \"bar\", \"baz\" => \"fbb\")\n    end\n\n    it \"supports carriage return combine with new line\" do\n      expect(env(\"FOO=bar\\r\\nbaz=fbb\")).to eql(\"FOO\" => \"bar\", \"baz\" => \"fbb\")\n    end\n\n    it \"escapes carriage return in quoted strings\" do\n      expect(env('FOO=\"bar\\rbaz\"')).to eql(\"FOO\" => \"bar\\\\rbaz\")\n    end\n\n    it \"escape $ properly when no alphabets/numbers/_  are followed by it\" do\n      expect(env(\"FOO=\\\"bar\\\\$ \\\\$\\\\$\\\"\")).to eql(\"FOO\" => \"bar$ $$\")\n    end\n\n    # echo bar $ -> prints bar $ in the shell\n    it \"ignore $ when it is not escaped and no variable is followed by it\" do\n      expect(env(\"FOO=\\\"bar $ \\\"\")).to eql(\"FOO\" => \"bar $ \")\n    end\n\n    # This functionality is not supported on JRuby or Rubinius\n    if (!defined?(RUBY_ENGINE) || RUBY_ENGINE != \"jruby\") &&\n        !defined?(Rubinius)\n      it \"substitutes shell variables within interpolated shell commands\" do\n        expect(env(%(VAR1=var1\\ninterp=$(echo \"VAR1 is $VAR1\")))[\"interp\"])\n          .to eql(\"VAR1 is var1\")\n      end\n    end\n  end\n\n  it \"returns existing value for redefined variable\" do\n    ENV[\"FOO\"] = \"existing\"\n    expect(env(\"FOO=bar\")).to eql(\"FOO\" => \"existing\")\n  end\nend\n"
  },
  {
    "path": "spec/dotenv/rails_spec.rb",
    "content": "require \"spec_helper\"\nrequire \"rails\"\nrequire \"dotenv/rails\"\n\ndescribe Dotenv::Rails do\n  let(:log_output) { StringIO.new }\n  let(:application) do\n    log_output = self.log_output\n    Class.new(Rails::Application) do\n      config.load_defaults Rails::VERSION::STRING.to_f\n      config.eager_load = false\n      config.logger = ActiveSupport::Logger.new(log_output)\n      config.root = fixture_path\n\n      # Remove method fails since app is reloaded for each test\n      config.active_support.remove_deprecated_time_with_zone_name = false\n    end.instance\n  end\n\n  around do |example|\n    # These get frozen after the app initializes\n    autoload_paths = ActiveSupport::Dependencies.autoload_paths.dup\n    autoload_once_paths = ActiveSupport::Dependencies.autoload_once_paths.dup\n\n    # Run in fixtures directory\n    Dir.chdir(fixture_path) { example.run }\n  ensure\n    # Restore autoload paths to unfrozen state\n    ActiveSupport::Dependencies.autoload_paths = autoload_paths\n    ActiveSupport::Dependencies.autoload_once_paths = autoload_once_paths\n  end\n\n  before do\n    Rails.env = \"test\"\n    Rails.application = nil\n    Rails.logger = nil\n\n    begin\n      # Remove the singleton instance if it exists\n      Dotenv::Rails.remove_instance_variable(:@instance)\n    rescue\n      nil\n    end\n  end\n\n  describe \"files\" do\n    it \"loads files for development environment\" do\n      Rails.env = \"development\"\n\n      expect(Dotenv::Rails.files).to eql(\n        [\n          \".env.development.local\",\n          \".env.local\",\n          \".env.development\",\n          \".env\"\n        ]\n      )\n    end\n\n    it \"does not load .env.local in test rails environment\" do\n      Rails.env = \"test\"\n      expect(Dotenv::Rails.files).to eql(\n        [\n          \".env.test.local\",\n          \".env.test\",\n          \".env\"\n        ]\n      )\n    end\n\n    it \"can be modified in place\" do\n      Dotenv::Rails.files << \".env.shared\"\n      expect(Dotenv::Rails.files.last).to eq(\".env.shared\")\n    end\n  end\n\n  it \"watches other loaded files with Spring\" do\n    stub_spring(load_watcher: true)\n    application.initialize!\n    path = fixture_path(\"plain.env\")\n    Dotenv.load(path)\n    expect(Spring.watcher).to include(path.to_s)\n  end\n\n  it \"doesn't raise an error if Spring.watch is not defined\" do\n    stub_spring(load_watcher: false)\n\n    expect {\n      application.initialize!\n    }.to_not raise_error\n  end\n\n  context \"before_configuration\" do\n    it \"calls #load\" do\n      expect(Dotenv::Rails.instance).to receive(:load)\n      ActiveSupport.run_load_hooks(:before_configuration)\n    end\n  end\n\n  context \"load\" do\n    subject { application.initialize! }\n\n    it \"watches .env with Spring\" do\n      stub_spring(load_watcher: true)\n      subject\n      expect(Spring.watcher).to include(fixture_path(\".env\").to_s)\n    end\n\n    it \"loads .env.test before .env\" do\n      subject\n      expect(ENV[\"DOTENV\"]).to eql(\"test\")\n    end\n\n    it \"loads configured files\" do\n      Dotenv::Rails.files = [fixture_path(\"plain.env\")]\n      expect { subject }.to change { ENV[\"PLAIN\"] }.from(nil).to(\"true\")\n    end\n\n    it \"loads file relative to Rails.root\" do\n      allow(Rails).to receive(:root).and_return(Pathname.new(\"/tmp\"))\n      Dotenv::Rails.files = [\".env\"]\n      expect(Dotenv).to receive(:load).with(\"/tmp/.env\", {overwrite: false})\n      subject\n    end\n\n    it \"returns absolute paths unchanged\" do\n      Dotenv::Rails.files = [\"/tmp/.env\"]\n      expect(Dotenv).to receive(:load).with(\"/tmp/.env\", {overwrite: false})\n      subject\n    end\n\n    context \"with overwrite = true\" do\n      before { Dotenv::Rails.overwrite = true }\n\n      it \"overwrites .env with .env.test\" do\n        subject\n        expect(ENV[\"DOTENV\"]).to eql(\"test\")\n      end\n\n      it \"overwrites any existing ENV variables\" do\n        ENV[\"DOTENV\"] = \"predefined\"\n        expect { subject }.to(change { ENV[\"DOTENV\"] }.from(\"predefined\").to(\"test\"))\n      end\n    end\n  end\n\n  describe \"root\" do\n    it \"returns Rails.root\" do\n      expect(Dotenv::Rails.root).to eql(Rails.root)\n    end\n\n    context \"when Rails.root is nil\" do\n      before do\n        allow(Rails).to receive(:root).and_return(nil)\n      end\n\n      it \"falls back to RAILS_ROOT\" do\n        ENV[\"RAILS_ROOT\"] = \"/tmp\"\n        expect(Dotenv::Rails.root.to_s).to eql(\"/tmp\")\n      end\n    end\n  end\n\n  describe \"autorestore\" do\n    it \"is loaded if RAILS_ENV=test\" do\n      expect(Dotenv::Rails.autorestore).to eq(true)\n      expect(Dotenv::Rails.instance).to receive(:require).with(\"dotenv/autorestore\")\n      application.initialize!\n    end\n\n    it \"is not loaded if RAILS_ENV=development\" do\n      Rails.env = \"development\"\n      expect(Dotenv::Rails.autorestore).to eq(false)\n      expect(Dotenv::Rails.instance).not_to receive(:require).with(\"dotenv/autorestore\")\n      application.initialize!\n    end\n\n    it \"is not loaded if autorestore set to false\" do\n      Dotenv::Rails.autorestore = false\n      expect(Dotenv::Rails.instance).not_to receive(:require).with(\"dotenv/autorestore\")\n      application.initialize!\n    end\n\n    it \"is not loaded if ClimateControl is defined\" do\n      stub_const(\"ClimateControl\", Module.new)\n      expect(Dotenv::Rails.instance).not_to receive(:require).with(\"dotenv/autorestore\")\n      application.initialize!\n    end\n\n    it \"is not loaded if IceAge is defined\" do\n      stub_const(\"IceAge\", Module.new)\n      expect(Dotenv::Rails.instance).not_to receive(:require).with(\"dotenv/autorestore\")\n      application.initialize!\n    end\n  end\n\n  describe \"logger\" do\n    it \"replays to Rails.logger\" do\n      expect(Dotenv::Rails.logger).to be_a(Dotenv::ReplayLogger)\n      Dotenv::Rails.logger.debug(\"test\")\n\n      application.initialize!\n\n      expect(Dotenv::Rails.logger).not_to be_a(Dotenv::ReplayLogger)\n      expect(log_output.string).to include(\"[dotenv] test\")\n    end\n\n    it \"does not replace custom logger\" do\n      logger = Logger.new(log_output)\n\n      Dotenv::Rails.logger = logger\n      application.initialize!\n      expect(Dotenv::Rails.logger).to be(logger)\n    end\n  end\n\n  def stub_spring(load_watcher: true)\n    spring = Module.new do\n      if load_watcher\n        def self.watcher\n          @watcher ||= Set.new\n        end\n\n        def self.watch(path)\n          watcher.add path\n        end\n      end\n    end\n\n    stub_const \"Spring\", spring\n  end\nend\n"
  },
  {
    "path": "spec/dotenv_spec.rb",
    "content": "require \"spec_helper\"\n\ndescribe Dotenv do\n  before do\n    Dir.chdir(File.expand_path(\"../fixtures\", __FILE__))\n  end\n\n  shared_examples \"load\" do\n    context \"with no args\" do\n      let(:env_files) { [] }\n\n      it \"defaults to .env\" do\n        expect(Dotenv::Environment).to receive(:new).with(expand(\".env\"), anything).and_call_original\n        subject\n      end\n    end\n\n    context \"with a tilde path\" do\n      let(:env_files) { [\"~/.env\"] }\n\n      it \"expands the path\" do\n        expected = expand(\"~/.env\")\n        allow(File).to receive(:exist?) { |arg| arg == expected }\n        expect(Dotenv::Environment).to receive(:new).with(expected, anything)\n          .and_return(Dotenv::Environment.new(\".env\"))\n        subject\n      end\n    end\n\n    context \"with multiple files\" do\n      let(:env_files) { [\".env\", fixture_path(\"plain.env\")] }\n\n      let(:expected) do\n        {\"OPTION_A\" => \"1\",\n         \"OPTION_B\" => \"2\",\n         \"OPTION_C\" => \"3\",\n         \"OPTION_D\" => \"4\",\n         \"OPTION_E\" => \"5\",\n         \"PLAIN\" => \"true\",\n         \"DOTENV\" => \"true\"}\n      end\n\n      it \"loads all files\" do\n        subject\n        expected.each do |key, value|\n          expect(ENV[key]).to eq(value)\n        end\n      end\n\n      it \"returns hash of loaded variables\" do\n        expect(subject).to eq(expected)\n      end\n\n      it \"does not return unchanged variables\" do\n        ENV[\"OPTION_A\"] = \"1\"\n        expect(subject).not_to have_key(\"OPTION_A\")\n      end\n    end\n  end\n\n  shared_examples \"overwrite\" do\n    it_behaves_like \"load\"\n\n    context \"with multiple files\" do\n      let(:env_files) { [fixture_path(\"important.env\"), fixture_path(\"plain.env\")] }\n\n      let(:expected) do\n        {\n          \"OPTION_A\" => \"abc\",\n          \"OPTION_B\" => \"2\",\n          \"OPTION_C\" => \"3\",\n          \"OPTION_D\" => \"4\",\n          \"OPTION_E\" => \"5\",\n          \"PLAIN\" => \"false\"\n        }\n      end\n\n      it \"respects the file importance order\" do\n        subject\n        expected.each do |key, value|\n          expect(ENV[key]).to eq(value)\n        end\n      end\n    end\n  end\n\n  describe \"load\" do\n    let(:env_files) { [] }\n    let(:options) { {} }\n    subject { Dotenv.load(*env_files, **options) }\n\n    it_behaves_like \"load\"\n\n    it \"initializes the Environment with overwrite: false\" do\n      expect(Dotenv::Environment).to receive(:new).with(anything, overwrite: false)\n        .and_call_original\n      subject\n    end\n\n    it \"warns about not overwriting when requested\" do\n      options[:overwrite] = :warn\n      ENV[\"DOTENV\"] = \"false\"\n\n      expect(capture_output { subject }).to eq(\"Warning: dotenv not overwriting ENV[\\\"DOTENV\\\"]\\n\")\n\n      expect(ENV[\"DOTENV\"]).to eq(\"false\")\n    end\n\n    context \"when the file does not exist\" do\n      let(:env_files) { [\".env_does_not_exist\"] }\n\n      it \"fails silently\" do\n        expect { subject }.not_to raise_error\n      end\n\n      it \"does not change ENV\" do\n        expect { subject }.not_to change { ENV.inspect }\n      end\n    end\n\n    context \"when the file is a directory\" do\n      let(:env_files) { [] }\n\n      around do |example|\n        Dir.mktmpdir do |dir|\n          env_files.push dir\n          example.run\n        end\n      end\n\n      it \"fails silently with ignore: true (default)\" do\n        expect { subject }.not_to raise_error\n      end\n\n      it \"raises error with ignore: false\" do\n        options[:ignore] = false\n        expect { subject }.to raise_error(/Is a directory/)\n      end\n    end\n  end\n\n  describe \"load!\" do\n    let(:env_files) { [] }\n    subject { Dotenv.load!(*env_files) }\n\n    it_behaves_like \"load\"\n\n    it \"initializes Environment with overwrite: false\" do\n      expect(Dotenv::Environment).to receive(:new).with(anything, overwrite: false)\n        .and_call_original\n      subject\n    end\n\n    context \"when one file exists and one does not\" do\n      let(:env_files) { [\".env\", \".env_does_not_exist\"] }\n\n      it \"raises an Errno::ENOENT error\" do\n        expect { subject }.to raise_error(Errno::ENOENT)\n      end\n    end\n  end\n\n  describe \"overwrite\" do\n    let(:env_files) { [fixture_path(\"plain.env\")] }\n    subject { Dotenv.overwrite(*env_files) }\n    it_behaves_like \"load\"\n    it_behaves_like \"overwrite\"\n\n    it \"initializes the Environment overwrite: true\" do\n      expect(Dotenv::Environment).to receive(:new).with(anything, overwrite: true)\n        .and_call_original\n      subject\n    end\n\n    context \"when loading a file containing already set variables\" do\n      let(:env_files) { [fixture_path(\"plain.env\")] }\n\n      it \"overwrites any existing ENV variables\" do\n        ENV[\"OPTION_A\"] = \"predefined\"\n\n        subject\n\n        expect(ENV[\"OPTION_A\"]).to eq(\"1\")\n      end\n    end\n\n    context \"when the file does not exist\" do\n      let(:env_files) { [\".env_does_not_exist\"] }\n\n      it \"fails silently\" do\n        expect { subject }.not_to raise_error\n      end\n\n      it \"does not change ENV\" do\n        expect { subject }.not_to change { ENV.inspect }\n      end\n    end\n  end\n\n  describe \"overwrite!\" do\n    let(:env_files) { [fixture_path(\"plain.env\")] }\n    subject { Dotenv.overwrite!(*env_files) }\n    it_behaves_like \"load\"\n    it_behaves_like \"overwrite\"\n\n    it \"initializes the Environment with overwrite: true\" do\n      expect(Dotenv::Environment).to receive(:new).with(anything, overwrite: true)\n        .and_call_original\n      subject\n    end\n\n    context \"when loading a file containing already set variables\" do\n      let(:env_files) { [fixture_path(\"plain.env\")] }\n\n      it \"overwrites any existing ENV variables\" do\n        ENV[\"OPTION_A\"] = \"predefined\"\n        subject\n        expect(ENV[\"OPTION_A\"]).to eq(\"1\")\n      end\n    end\n\n    context \"when one file exists and one does not\" do\n      let(:env_files) { [\".env\", \".env_does_not_exist\"] }\n\n      it \"raises an Errno::ENOENT error\" do\n        expect { subject }.to raise_error(Errno::ENOENT)\n      end\n    end\n  end\n\n  describe \"with an instrumenter\" do\n    let(:instrumenter) { double(\"instrumenter\", instrument: {}) }\n    before { Dotenv.instrumenter = instrumenter }\n    after { Dotenv.instrumenter = nil }\n\n    describe \"load\" do\n      it \"instruments if the file exists\" do\n        expect(instrumenter).to receive(:instrument) do |name, payload|\n          expect(name).to eq(\"load.dotenv\")\n          expect(payload[:env]).to be_instance_of(Dotenv::Environment)\n          {}\n        end\n        Dotenv.load\n      end\n\n      it \"does not instrument if file does not exist\" do\n        expect(instrumenter).to receive(:instrument).never\n        Dotenv.load \".doesnotexist\"\n      end\n    end\n  end\n\n  describe \"require keys\" do\n    let(:env_files) { [\".env\", fixture_path(\"bom.env\")] }\n\n    before { Dotenv.load(*env_files) }\n\n    it \"raises exception with not defined mandatory ENV keys\" do\n      expect { Dotenv.require_keys(\"BOM\", \"TEST\") }.to raise_error(\n        Dotenv::MissingKeys,\n        'Missing required configuration key: [\"TEST\"]'\n      )\n    end\n\n    it \"raises exception when missing multiple mandator keys\" do\n      expect { Dotenv.require_keys(\"TEST1\", \"TEST2\") }.to raise_error(\n        Dotenv::MissingKeys,\n        'Missing required configuration keys: [\"TEST1\", \"TEST2\"]'\n      )\n    end\n  end\n\n  describe \"parse\" do\n    let(:env_files) { [] }\n    subject { Dotenv.parse(*env_files) }\n\n    context \"with no args\" do\n      let(:env_files) { [] }\n\n      it \"defaults to .env\" do\n        expect(Dotenv::Environment).to receive(:new).with(expand(\".env\"),\n          anything)\n        subject\n      end\n    end\n\n    context \"with a tilde path\" do\n      let(:env_files) { [\"~/.env\"] }\n\n      it \"expands the path\" do\n        expected = expand(\"~/.env\")\n        allow(File).to receive(:exist?) { |arg| arg == expected }\n        expect(Dotenv::Environment).to receive(:new).with(expected, anything)\n        subject\n      end\n    end\n\n    context \"with multiple files\" do\n      let(:env_files) { [\".env\", fixture_path(\"plain.env\")] }\n\n      let(:expected) do\n        {\"OPTION_A\" => \"1\",\n         \"OPTION_B\" => \"2\",\n         \"OPTION_C\" => \"3\",\n         \"OPTION_D\" => \"4\",\n         \"OPTION_E\" => \"5\",\n         \"PLAIN\" => \"true\",\n         \"DOTENV\" => \"true\"}\n      end\n\n      it \"does not modify ENV\" do\n        subject\n        expected.each do |key, _value|\n          expect(ENV[key]).to be_nil\n        end\n      end\n\n      it \"returns hash of parsed key/value pairs\" do\n        expect(subject).to eq(expected)\n      end\n    end\n\n    it \"initializes the Environment with overwrite: false\" do\n      expect(Dotenv::Environment).to receive(:new).with(anything, overwrite: false)\n      subject\n    end\n\n    context \"when the file does not exist\" do\n      let(:env_files) { [\".env_does_not_exist\"] }\n\n      it \"fails silently\" do\n        expect { subject }.not_to raise_error\n        expect(subject).to eq({})\n      end\n    end\n  end\n\n  describe \"Unicode\" do\n    subject { fixture_path(\"bom.env\") }\n\n    it \"loads a file with a Unicode BOM\" do\n      expect(Dotenv.load(subject)).to eql(\"BOM\" => \"UTF-8\")\n    end\n\n    it \"fixture file has UTF-8 BOM\" do\n      contents = File.binread(subject).force_encoding(\"UTF-8\")\n      expect(contents).to start_with(\"\\xEF\\xBB\\xBF\".force_encoding(\"UTF-8\"))\n    end\n  end\n\n  describe \"restore\" do\n    it \"restores previously saved snapshot\" do\n      ENV[\"MODIFIED\"] = \"true\"\n      Dotenv.restore # save was already called in setup\n      expect(ENV[\"MODIFIED\"]).to be_nil\n    end\n\n    it \"raises an error in threads\" do\n      ENV[\"MODIFIED\"] = \"true\"\n      Thread.new do\n        expect { Dotenv.restore }.to raise_error(ThreadError, /not thread safe/)\n      end.join\n      expect(ENV[\"MODIFIED\"]).to eq(\"true\")\n    end\n\n    it \"is a noop if nil state provided\" do\n      expect { Dotenv.restore(nil) }.not_to raise_error\n    end\n\n    it \"is a noop if no previously saved state\" do\n      # Clear state saved in setup\n      expect(Dotenv.instance_variable_get(:@diff)).to be_instance_of(Dotenv::Diff)\n      Dotenv.instance_variable_set(:@diff, nil)\n      expect { Dotenv.restore }.not_to raise_error\n    end\n\n    it \"can save and restore stubbed ENV\" do\n      stub_const(\"ENV\", ENV.to_h.merge(\"STUBBED\" => \"1\"))\n      Dotenv.save\n      ENV[\"MODIFIED\"] = \"1\"\n      Dotenv.restore\n      expect(ENV[\"STUBBED\"]).to eq(\"1\")\n      expect(ENV[\"MODIFED\"]).to be(nil)\n    end\n  end\n\n  describe \"modify\" do\n    it \"sets values for the block\" do\n      ENV[\"FOO\"] = \"initial\"\n\n      Dotenv.modify(FOO: \"during\", BAR: \"baz\") do\n        expect(ENV[\"FOO\"]).to eq(\"during\")\n        expect(ENV[\"BAR\"]).to eq(\"baz\")\n      end\n\n      expect(ENV[\"FOO\"]).to eq(\"initial\")\n      expect(ENV).not_to have_key(\"BAR\")\n    end\n  end\n\n  describe \"update\" do\n    it \"sets new variables\" do\n      Dotenv.update({\"OPTION_A\" => \"1\"})\n      expect(ENV[\"OPTION_A\"]).to eq(\"1\")\n    end\n\n    it \"does not overwrite defined variables\" do\n      ENV[\"OPTION_A\"] = \"original\"\n      Dotenv.update({\"OPTION_A\" => \"updated\"})\n      expect(ENV[\"OPTION_A\"]).to eq(\"original\")\n    end\n\n    context \"with overwrite: true\" do\n      it \"sets new variables\" do\n        Dotenv.update({\"OPTION_A\" => \"1\"}, overwrite: true)\n        expect(ENV[\"OPTION_A\"]).to eq(\"1\")\n      end\n\n      it \"overwrites defined variables\" do\n        ENV[\"OPTION_A\"] = \"original\"\n        Dotenv.update({\"OPTION_A\" => \"updated\"}, overwrite: true)\n        expect(ENV[\"OPTION_A\"]).to eq(\"updated\")\n      end\n    end\n  end\n\n  def expand(path)\n    File.expand_path path\n  end\nend\n"
  },
  {
    "path": "spec/fixtures/bom.env",
    "content": "﻿BOM=UTF-8"
  },
  {
    "path": "spec/fixtures/exported.env",
    "content": "export OPTION_A=2\nexport OPTION_B='\\n'\n"
  },
  {
    "path": "spec/fixtures/important.env",
    "content": "PLAIN=false\nOPTION_A=abc\nOPTION_B=2"
  },
  {
    "path": "spec/fixtures/plain.env",
    "content": "PLAIN=true\nOPTION_A=1\nOPTION_B=2\nOPTION_C= 3\nOPTION_D =4\nOPTION_E = 5\n"
  },
  {
    "path": "spec/fixtures/quoted.env",
    "content": "QUOTED=true\nOPTION_A='1'\nOPTION_B='2'\nOPTION_C=''\nOPTION_D='\\n'\nOPTION_E=\"1\"\nOPTION_F=\"2\"\nOPTION_G=\"\"\nOPTION_H=\"\\n\"\n"
  },
  {
    "path": "spec/fixtures/yaml.env",
    "content": "OPTION_A: 1\nOPTION_B: '2'\nOPTION_C: ''\nOPTION_D: '\\n'\n"
  },
  {
    "path": "spec/spec_helper.rb",
    "content": "require \"dotenv\"\nrequire \"dotenv/autorestore\"\nrequire \"tmpdir\"\n\ndef fixture_path(*parts)\n  Pathname.new(__dir__).join(\"./fixtures\", *parts)\nend\n\n# Capture output to $stdout and $stderr\ndef capture_output(&_block)\n  original_stderr = $stderr\n  original_stdout = $stdout\n  output = $stderr = $stdout = StringIO.new\n  yield\n  output.string\nensure\n  $stderr = original_stderr\n  $stdout = original_stdout\nend\n"
  },
  {
    "path": "test/autorestore_test.rb",
    "content": "require \"active_support\" # Rails 6.1 fails if this is not loaded\nrequire \"active_support/test_case\"\nrequire \"minitest/autorun\"\n\nrequire \"dotenv\"\nrequire \"dotenv/autorestore\"\n\nclass AutorestoreTest < ActiveSupport::TestCase\n  test \"restores ENV between tests, part 1\" do\n    assert_nil ENV[\"DOTENV\"], \"ENV was not restored between tests\"\n    ENV[\"DOTENV\"] = \"1\"\n  end\n\n  test \"restores ENV between tests, part 2\" do\n    assert_nil ENV[\"DOTENV\"], \"ENV was not restored between tests\"\n    ENV[\"DOTENV\"] = \"2\"\n  end\nend\n"
  }
]