Class: DataAnon::Utils::TemplateHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/template_helper.rb

Class Method Summary collapse

Class Method Details

.destination_connection_specs_mongoObject


29
30
31
# File 'lib/utils/template_helper.rb', line 29

def self.destination_connection_specs_mongo
  ":mongodb_uri => '<enter value>', :database => '<enter value>'"
end

.destination_connection_specs_rdbms(config_hash) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/utils/template_helper.rb', line 17

def self.destination_connection_specs_rdbms config_hash

  config_hash.keys.collect { |key|
    ":#{key} => '<enter_value>'"
  }.join ', '

end

.mongo_uri(config_hash) ⇒ Object


33
34
35
36
37
38
39
40
41
# File 'lib/utils/template_helper.rb', line 33

def self.mongo_uri config_hash
  if config_hash[:user].nil?
    mongo_uri = "mongodb://#{config_hash[:host]}#{config_hash[:port].nil? ? "" : ":#{config_hash[:port]}"}/#{config_hash[:database]}"
  else
    credentials = "#{config_hash[:username]}:#{config_hash[:password]}"
    mongo_uri = "mongodb://#{config_hash[:host]}#{config_hash[:port].nil? ? "" : ":#{config_hash[:port]}"}@#{credentials}/#{config_hash[:database]}"
  end
  mongo_uri
end

.source_connection_specs_mongo(config_hash) ⇒ Object


25
26
27
# File 'lib/utils/template_helper.rb', line 25

def self.source_connection_specs_mongo config_hash
  ":mongodb_uri => '#{self.mongo_uri config_hash}', :database => '#{config_hash[:database]}'"
end

.source_connection_specs_rdbms(config_hash) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/utils/template_helper.rb', line 5

def self.source_connection_specs_rdbms config_hash

  config_hash.keys.reject{|key| config_hash[key].nil? }.collect { |key|
    if ((config_hash[key].class.to_s.downcase == "string"))
      ":#{key} => '#{config_hash[key]}'"
    elsif ((config_hash[key].class.to_s.downcase == "fixnum"))
      ":#{key} => #{config_hash[key]}"
    end
  }.join ', '

end