class Dotenvious::Loaders::DotenvFile
Attributes
filename[R]
Public Class Methods
load_from(filename)
click to toggle source
# File lib/dotenvious/loaders/dotenv_file.rb, line 4 def self.load_from(filename) new(filename).load end
new(filename)
click to toggle source
# File lib/dotenvious/loaders/dotenv_file.rb, line 8 def initialize(filename) @filename = filename end
Public Instance Methods
load()
click to toggle source
# 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
Private Instance Methods
file()
click to toggle source
# File lib/dotenvious/loaders/dotenv_file.rb, line 33 def file File.read(filename).split("\n") end
file_missing?()
click to toggle source
# File lib/dotenvious/loaders/dotenv_file.rb, line 29 def file_missing? !File.exists?(filename) end