Sha256: 9cabc60ee7e51afaffc8da9bb204df4187943e9a7c545f794af5d380e923729b
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
require 'dotenv' Dotenv.instrumenter = ActiveSupport::Notifications # Watch all loaded env files with Spring begin require 'spring/watcher' ActiveSupport::Notifications.subscribe(/^dotenv/) do |*args| event = ActiveSupport::Notifications::Event.new(*args) Spring.watch event.payload[:env].filename if Rails.application end rescue LoadError # Spring is not available end module Dotenv class Railtie < Rails::Railtie config.before_configuration { load } # Public: Load dotenv # # This will get called during the `before_configuration` callback, but you # can manually call `Dotenv::Railtie.load` if you needed it sooner. def load Dotenv.load( root.join(".env.local"), root.join(".env.#{Rails.env}"), root.join('.env') ) end # Internal: `Rails.root` is nil in Rails 4.1 before the application is # initialized, so this falls back to the `RAILS_ROOT` environment variable, # or the current workding directory. def root Rails.root || Pathname.new(ENV["RAILS_ROOT"] || Dir.pwd) end # Rails uses `#method_missing` to delegate all class methods to the # instance, which means `Kernel#load` gets called here. We don't want that. def self.load instance.load end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dotenv-rails-2.0.0.beta | lib/dotenv/rails.rb |