class Dotenvious::ValueReplacer
Attributes
base_env[R]
filename[R]
Public Class Methods
new(filename)
click to toggle source
# File lib/dotenvious/value_replacer.rb, line 3 def initialize(filename) @filename = filename end
Public Instance Methods
replace(key)
click to toggle source
# File lib/dotenvious/value_replacer.rb, line 7 def replace(key) line_number = base_env.find_index do |line| line.match(/^#{key}=/) end updated_env = base_env.dup updated_env[line_number] = "#{key}=#{ENV_EXAMPLE[key]}" env_writer.write(updated_env.join("\n") + "\n") env_writer.close end
Private Instance Methods
env_writer()
click to toggle source
# File lib/dotenvious/value_replacer.rb, line 25 def env_writer @env_writer ||= File.open(filename, 'w') end