Sha256: 6f981184d87985ccf4c20fbcc2129ebcd6b8ca04761e8eb7f1885d6f9f86a669
Contents?: true
Size: 898 Bytes
Versions: 10
Compression:
Stored size: 898 Bytes
Contents
require 'hako/env_provider' module Hako module EnvProviders class File < EnvProvider def initialize(root_path, options) unless options['path'] validation_error!('path must be set') end @path = root_path.join(options['path']) end def ask(variables) env = {} read_from_file do |key, val| if variables.include?(key) env[key] = val end end env end private def read_from_file(&block) ::File.open(@path) do |f| f.each_line do |line| line.chomp! line.lstrip! if line[0] == '#' # line comment next end key, val = line.split('=', 2) if val block.call(key, val) end end end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems