Module: Util

Defined in:
lib/util.rb

Class Method Summary collapse

Class Method Details

.discover_my_public_ip_cidrObject



22
23
24
25
# File 'lib/util.rb', line 22

def self.discover_my_public_ip_cidr
  my_ip = `dig @resolver1.opendns.com myip.opendns.com +short`
  "#{my_ip.chomp}/32"
end

.merge_secrets(yml_path) ⇒ Object



8
9
10
11
12
13
# File 'lib/util.rb', line 8

def self.merge_secrets(yml_path)
  jenkins_settings = YAML.load_file(yml_path)
  secret_properties = YAML.load_file(secrets_file_path(yml_path))
  jenkins_settings.merge! secret_properties
  jenkins_settings
end

.secrets_file_path(yml_path) ⇒ Object



2
3
4
5
6
# File 'lib/util.rb', line 2

def self.secrets_file_path(yml_path)
  yml_split_path = File.split(yml_path)
  secret_name_base = File.basename yml_split_path[1], '.yml'
  File.join yml_split_path[0], "#{secret_name_base}_secret.yml"
end

.transform_keys_to_symbols(hash) ⇒ Object



15
16
17
18
19
20
# File 'lib/util.rb', line 15

def self.transform_keys_to_symbols(hash)
  hash.keys.each do |k|
    hash[k.to_sym] = hash[k]
    hash.delete k
  end
end