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



31
32
33
# File 'lib/utils/template_helper.rb', line 31

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

.destination_connection_specs_rdbms(config_hash) ⇒ Object



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

def self.destination_connection_specs_rdbms config_hash

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

end

.mongo_uri(config_hash) ⇒ Object



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

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



27
28
29
# File 'lib/utils/template_helper.rb', line 27

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
16
17
# 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 == 'integer'))
      ":#{key} => #{config_hash[key]}"
    elsif ((config_hash[key].class.to_s.downcase == 'fixnum'))
      ":#{key} => #{config_hash[key]}"
    end
  }.join ', '

end