Module: Specjour::SocketHelper
- Included in:
- Dispatcher, Manager, RsyncDaemon, Worker
- Defined in:
- lib/specjour/socket_helper.rb
Instance Method Summary collapse
- #current_uri ⇒ Object
- #hostname ⇒ Object
- #ip_from_hostname(hostname) ⇒ Object
- #local_ip ⇒ Object
- #new_uri ⇒ Object
Instance Method Details
#current_uri ⇒ Object
19 20 21 |
# File 'lib/specjour/socket_helper.rb', line 19 def current_uri @current_uri ||= new_uri end |
#hostname ⇒ Object
11 12 13 |
# File 'lib/specjour/socket_helper.rb', line 11 def hostname @hostname ||= Socket.gethostname end |
#ip_from_hostname(hostname) ⇒ Object
5 6 7 8 9 |
# File 'lib/specjour/socket_helper.rb', line 5 def ip_from_hostname(hostname) Socket.getaddrinfo(hostname, nil, Socket::AF_INET, Socket::SOCK_STREAM).first.fetch(3) rescue SocketError hostname end |
#local_ip ⇒ Object
15 16 17 |
# File 'lib/specjour/socket_helper.rb', line 15 def local_ip @local_ip ||= UDPSocket.open {|s| s.connect('74.125.224.103', 1); s.addr.last } end |
#new_uri ⇒ Object
23 24 25 |
# File 'lib/specjour/socket_helper.rb', line 23 def new_uri URI::Generic.build :host => faux_server[2], :port => faux_server[1] end |