Sha256: b825a1864c4b91c0ed94a15e66db6a1892d96c8efc4d474ee1df8797a3b80abe
Contents?: true
Size: 1.42 KB
Versions: 13
Compression:
Stored size: 1.42 KB
Contents
require 'insxsync' # represents a single config file class ConfigFile < ErrorHandlingIface # reads in the contents of the specified config file and returns the object # @param [String] file The full file name of the config file 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 # Scrub the contents of the config file and return them # @return [String] The scrubbed contents of the config file def scrub @scrubbed = @contents @scrubbed.gsub!("\"", "'") @scrubbed.gsub!(/database.params.hostname(\s*)=(\s*)'[^']*'/m, "database.params.hostname\\1=\\2''") @scrubbed.gsub!(/database.params.username(\s*)=(\s*)'[^']*'/m, "database.params.username\\1=\\2''") @scrubbed.gsub!(/database.params.password(\s*)=(\s*)'[^']*'/m, "database.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 def get_usage #Usage cases for all the usage in this class if @usage.nil? init_usage @usage['new'] = ['file = String'] end super end end
Version data entries
13 entries across 13 versions & 1 rubygems