lib/dotenv/rails.rb in dotenv-rails-2.0.0.beta vs lib/dotenv/rails.rb in dotenv-rails-2.0.0
- old
+ new
@@ -1,21 +1,23 @@
-require 'dotenv'
+require "dotenv"
Dotenv.instrumenter = ActiveSupport::Notifications
# Watch all loaded env files with Spring
begin
- require 'spring/watcher'
+ 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
+ # Dotenv Railtie for using Dotenv to load environment from a file into
+ # Rails applications
class Railtie < Rails::Railtie
config.before_configuration { load }
# Public: Load dotenv
#
@@ -23,16 +25,16 @@
# 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')
+ 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.
+ # or the current working directory.
def root
Rails.root || Pathname.new(ENV["RAILS_ROOT"] || Dir.pwd)
end
# Rails uses `#method_missing` to delegate all class methods to the