Class: Dotenvious::Loaders::DotenvFile
- Inherits:
-
Object
- Object
- Dotenvious::Loaders::DotenvFile
- Defined in:
- lib/dotenvious/loaders/dotenv_file.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename) ⇒ DotenvFile
constructor
A new instance of DotenvFile.
- #load ⇒ Object
Constructor Details
#initialize(filename) ⇒ DotenvFile
Returns a new instance of DotenvFile.
8 9 10 |
# File 'lib/dotenvious/loaders/dotenv_file.rb', line 8 def initialize(filename) @filename = filename end |
Class Method Details
.load_from(filename) ⇒ Object
4 5 6 |
# File 'lib/dotenvious/loaders/dotenv_file.rb', line 4 def self.load_from(filename) new(filename).load end |
Instance Method Details
#load ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dotenvious/loaders/dotenv_file.rb', line 12 def load #took from Dotenv source code whoops if file_missing? puts "This repo does not have an #{filename} file" return {} end Hash.new.tap do |environment| file.each do |line| environment[$1] = $2 if line =~ /\A([\w_]+)=(.*)\z/ end end end |