Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Utilize more idiomatic naming conventions for Socket class methods #320

Closed
wants to merge 7 commits into from

3 participants

Amos King Zachary Scott Zander Hill
Amos King
adkron commented

The current names of methods like Socket.gethostname are not very idiomatic of Ruby. In order to maintain backwards compatibility we decided to alias to the more idiomatic names.

@adkron
@zph

zph added some commits
Zander Hill zph Alias Socket.gethostname to Socket.hostname
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_ZPH) <zander@civet.ws>
7c06a46
Zander Hill zph Alias Socket.gethostbyname to Socket.get_host_by_name
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_ZPH) <zander@civet.ws>
43f935e
Zander Hill zph Alias Socket.gethostbyaddr to Socket.get_host_by_address
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_zph) <zander@civet.ws>
c1abf35
Zander Hill zph Alias Socket.getservbyname to Socket.get_service_by_name
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_zph) <zander@civet.ws>
61fc8fa
Zander Hill zph Alias Socket.getservbyport to Socket.get_service_by_port
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_ZPH) <zander@civet.ws>
af0254a
Zander Hill zph Alias Socket.getaddrinfo to Socket.get_address_info
This alias uses a more idiomatic naming convention

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_zph) <zander@civet.ws>
f4c6e3a
Zander Hill zph Alias Socket.getnameinfo to Socket.get_name_info
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_ZPH) <zander@civet.ws>
9f5aedb
Zachary Scott
Collaborator
zzak commented

These methods are named after POSIX standard

Zachary Scott zzak closed this
Amos King
adkron commented

@zzak I understand that they are named after the POSIX standards. That is why we only aliased the methods. I think this should be reopened for discussion.

Zachary Scott
Collaborator
zzak commented

Please open a feature request on http://bugs.ruby-lang.org/ for discussion.

Amos King
adkron commented

@zzak thanks for pointing me in the right direction.

@zph created a ticket at https://bugs.ruby-lang.org/issues/8459

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 7 unique commits by 1 author.

May 28, 2013
Zander Hill zph Alias Socket.gethostname to Socket.hostname
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_ZPH) <zander@civet.ws>
7c06a46
May 29, 2013
Zander Hill zph Alias Socket.gethostbyname to Socket.get_host_by_name
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_ZPH) <zander@civet.ws>
43f935e
Zander Hill zph Alias Socket.gethostbyaddr to Socket.get_host_by_address
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_zph) <zander@civet.ws>
c1abf35
Zander Hill zph Alias Socket.getservbyname to Socket.get_service_by_name
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_zph) <zander@civet.ws>
61fc8fa
Zander Hill zph Alias Socket.getservbyport to Socket.get_service_by_port
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_ZPH) <zander@civet.ws>
af0254a
Zander Hill zph Alias Socket.getaddrinfo to Socket.get_address_info
This alias uses a more idiomatic naming convention

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_zph) <zander@civet.ws>
f4c6e3a
Zander Hill zph Alias Socket.getnameinfo to Socket.get_name_info
This alias uses a more idiomatic naming convention.

Amos King (@adkron) <amos.l.king@gmail.com>
Zander Hill (@_ZPH) <zander@civet.ws>
9f5aedb
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 10 additions and 0 deletions. Show diff stats Hide diff stats

  1. +10 0 ext/socket/lib/socket.rb
10 ext/socket/lib/socket.rb
@@ -264,6 +264,16 @@ def connect_address
264 264
265 265 class Socket < BasicSocket
266 266 # enable the socket option IPV6_V6ONLY if IPV6_V6ONLY is available.
  267 + class << self
  268 + alias :hostname :gethostname
  269 + alias :get_host_by_name :gethostbyname
  270 + alias :get_host_by_address :gethostbyaddr
  271 + alias :get_service_by_name :getservbyname
  272 + alias :get_service_by_port :getservbyport
  273 + alias :get_address_info :getaddrinfo
  274 + alias :get_name_info :getnameinfo
  275 + end
  276 +
267 277 def ipv6only!
268 278 if defined? Socket::IPV6_V6ONLY
269 279 self.setsockopt(:IPV6, :V6ONLY, 1)

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.