Class: ProxyConf::Mac

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

Instance Method Summary collapse

Methods inherited from Engine

#add, #info, #list, #remove

Instance Method Details

#active_networkObject



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

def active_network
  guid = get_primary_service_guid
  get_service_name(guid)
end

#exportObject



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

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



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

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