Class: Pipedawg::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/pipedawg/util.rb

Overview

util class

Class Method Summary collapse

Class Method Details

.echo_proxy_varsObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/pipedawg/util.rb', line 33

def self.echo_proxy_vars
  script = ['echo Proxy settings:']
  script << 'echo   http_proxy: "${http_proxy}"'
  script << 'echo   https_proxy: "${https_proxy}"'
  script << 'echo   no_proxy: "${no_proxy}"'
  script << 'echo   HTTP_PROXY: "${HTTP_PROXY}"'
  script << 'echo   HTTPS_PROXY: "${HTTPS_PROXY}"'
  script << 'echo   NO_PROXY: "${NO_PROXY}"'
  script
end

.expand_env_vars(item) ⇒ Object

rubocop:disable Metrics/MethodLength



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pipedawg/util.rb', line 6

def self.expand_env_vars(item) # rubocop:disable Metrics/MethodLength
  case item
  when Array
    item.map { |i| expand_env_vars(i) }
  when Hash
    item.each { |k, v| item[k] = expand_env_vars(v) }
    item.transform_keys! { |k| expand_env_vars(k) }
    item
  when String
    item.gsub(/\${([^} ]+)}/) do |e|
      ENV[e.gsub('${', '').gsub('}', '')]
    end
  else
    item
  end
end

.puts_proxy_varsObject



23
24
25
26
27
28
29
30
31
# File 'lib/pipedawg/util.rb', line 23

def self.puts_proxy_vars
  puts 'Proxy settings:'
  puts "http_proxy: #{ENV['http_proxy']}"
  puts "https_proxy: #{ENV['https_proxy']}"
  puts "no_proxy: #{ENV['no_proxy']}"
  puts "HTTP_PROXY: #{ENV['HTTP_PROXY']}"
  puts "HTTPS_PROXY: #{ENV['HTTPS_PROXY']}"
  puts "NO_PROXY: #{ENV['NO_PROXY']}"
end