class TorManager::CreateEyeConfig

Public Class Methods

new(params={}) click to toggle source
# File lib/tormanager/create_eye_config.rb, line 3
def initialize params={}
  @settings = params
end

Public Instance Methods

create() click to toggle source
# File lib/tormanager/create_eye_config.rb, line 7
def create
  File.open(@settings[:eye_tor_config_path], "w") do |file|
    file.puts read_eye_tor_config_template_and_substitute_keywords
  end
end

Private Instance Methods

eye_tor_config_template_substitution_keywords() click to toggle source
# File lib/tormanager/create_eye_config.rb, line 23
def eye_tor_config_template_substitution_keywords
  @settings.keys.map(&:to_s)
end
read_eye_tor_config_template_and_substitute_keywords() click to toggle source
# File lib/tormanager/create_eye_config.rb, line 15
def read_eye_tor_config_template_and_substitute_keywords
  text = File.read(@settings[:eye_tor_config_template])
  eye_tor_config_template_substitution_keywords.each do |keyword|
    text = text.gsub(/\[\[\[#{keyword}\]\]\]/, @settings[keyword.to_sym].to_s)
  end
  text
end