123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- require "dotenv"
- Dotenv.instrumenter = ActiveSupport::Notifications
- 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
-
- end
- module Dotenv
-
-
- class Railtie < Rails::Railtie
- config.before_configuration { load }
-
-
-
-
- def load
- Dotenv.load(
- root.join(".env.local"),
- root.join(".env.#{Rails.env}"),
- root.join(".env")
- )
- end
-
-
-
- def root
- Rails.root || Pathname.new(ENV["RAILS_ROOT"] || Dir.pwd)
- end
-
-
- def self.load
- instance.load
- end
- end
- end
|