Sha256: 7590e4e60ef8cdd80e3911b9a3538dbccffae2bc514cd182f414e7f9ad22b6b6
Contents?: true
Size: 928 Bytes
Versions: 24
Compression:
Stored size: 928 Bytes
Contents
# frozen_string_literal: true 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
24 entries across 24 versions & 1 rubygems