Class: ProxyConf::Mac

Inherits:
Object
  • Object
show all
Defined in:
lib/proxyconf/mac.rb

Instance Method Summary collapse

Instance Method Details

#active_networkObject



38
39
40
41
# File 'lib/proxyconf/mac.rb', line 38

def active_network
  guid = get_primary_service_guid
  get_service_name(guid)
end

#exportObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/proxyconf/mac.rb', line 49

def export
  info = proxy_info
  proxy = ""
  if info['Enabled']
    proxy = "#{info['Server']}:#{info['Port']}"
  end
  puts "export http_proxy=#{proxy}"
  puts "export ftp_proxy=#{proxy}"
  puts "export https_proxy=#{proxy}"
end

#proxy_infoObject



43
44
45
46
47
# File 'lib/proxyconf/mac.rb', line 43

def proxy_info
  active_service_name = active_network
  src = `networksetup -getwebproxy "#{active_service_name}"`
  info = YAML.load(src)
end