class ConfigFile

represents a single config file

Public Class Methods

new(file) click to toggle source

reads in the contents of the specified config file and returns the object @param [String] file The full file name of the config file

# File lib/config_file.rb, line 7
def initialize(file)
  # ensure the file is passed properly as a string and exists
  failValidation if file.nil? or not file.is_a?(String) or not File.exists?(file)

  # read in the contents
  @contents = File.open(file, 'r').read
end

Public Instance Methods

scrub() click to toggle source

Scrub the contents of the config file and return them @return [String] The scrubbed contents of the config file

# File lib/config_file.rb, line 17
def scrub
  @scrubbed = @contents
  @scrubbed.gsub!("\"", "'")
  @scrubbed.gsub!(/params.hostname(\s*)=(\s*)'[^']*'/m, "params.hostname\\1=\\2''")
  @scrubbed.gsub!(/params.username(\s*)=(\s*)'[^']*'/m, "params.username\\1=\\2''")
  @scrubbed.gsub!(/params.password(\s*)=(\s*)'[^']*'/m, "params.password\\1=\\2''")
  @scrubbed.gsub!(/BucketName(\s*)=(\s*)'[^']*'/m, "BucketName\\1=\\2''")

  @scrubbed.gsub!(/\s*useAnalytics\s*=\s*\d*/m, '')
  @scrubbed.gsub!(/\s*useTrackingCode \s*=\s*\d*/m, '')

  @scrubbed.chomp!
  @scrubbed += "\nDebug = 1"
end

Private Instance Methods

get_usage() click to toggle source
Calls superclass method ErrorHandlingIface#get_usage
# File lib/config_file.rb, line 34
def get_usage
  #Usage cases for all the usage in this class
  if @usage.nil?
    init_usage
    @usage['new'] = ['file = String']
  end

  super
end