Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Utilize more idiomatic naming conventions for Socket class methods #320

Closed
wants to merge 7 commits into from

3 participants

@adkron

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
@zph 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
@zph 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
@zph 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
@zph 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
@zph 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
@zph 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
@zph 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
@zzak
Collaborator

These methods are named after POSIX standard

@zzak zzak closed this
@adkron

@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.

@zzak
Collaborator

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

@adkron

@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
Commits on May 28, 2013
  1. @zph

    Alias Socket.gethostname to Socket.hostname

    zph authored
    This alias uses a more idiomatic naming convention.
    
    Amos King (@adkron) <amos.l.king@gmail.com>
    Zander Hill (@_ZPH) <zander@civet.ws>
Commits on May 29, 2013
  1. @zph

    Alias Socket.gethostbyname to Socket.get_host_by_name

    zph authored
    This alias uses a more idiomatic naming convention.
    
    Amos King (@adkron) <amos.l.king@gmail.com>
    Zander Hill (@_ZPH) <zander@civet.ws>
  2. @zph

    Alias Socket.gethostbyaddr to Socket.get_host_by_address

    zph authored
    This alias uses a more idiomatic naming convention.
    
    Amos King (@adkron) <amos.l.king@gmail.com>
    Zander Hill (@_zph) <zander@civet.ws>
  3. @zph

    Alias Socket.getservbyname to Socket.get_service_by_name

    zph authored
    This alias uses a more idiomatic naming convention.
    
    Amos King (@adkron) <amos.l.king@gmail.com>
    Zander Hill (@_zph) <zander@civet.ws>
  4. @zph

    Alias Socket.getservbyport to Socket.get_service_by_port

    zph authored
    This alias uses a more idiomatic naming convention.
    
    Amos King (@adkron) <amos.l.king@gmail.com>
    Zander Hill (@_ZPH) <zander@civet.ws>
  5. @zph

    Alias Socket.getaddrinfo to Socket.get_address_info

    zph authored
    This alias uses a more idiomatic naming convention
    
    Amos King (@adkron) <amos.l.king@gmail.com>
    Zander Hill (@_zph) <zander@civet.ws>
  6. @zph

    Alias Socket.getnameinfo to Socket.get_name_info

    zph authored
    This alias uses a more idiomatic naming convention.
    
    Amos King (@adkron) <amos.l.king@gmail.com>
    Zander Hill (@_ZPH) <zander@civet.ws>
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 0 deletions.
  1. +10 −0 ext/socket/lib/socket.rb
View
10 ext/socket/lib/socket.rb
@@ -264,6 +264,16 @@ def connect_address
class Socket < BasicSocket
# enable the socket option IPV6_V6ONLY if IPV6_V6ONLY is available.
+ class << self
+ alias :hostname :gethostname
+ alias :get_host_by_name :gethostbyname
+ alias :get_host_by_address :gethostbyaddr
+ alias :get_service_by_name :getservbyname
+ alias :get_service_by_port :getservbyport
+ alias :get_address_info :getaddrinfo
+ alias :get_name_info :getnameinfo
+ end
+
def ipv6only!
if defined? Socket::IPV6_V6ONLY
self.setsockopt(:IPV6, :V6ONLY, 1)
Something went wrong with that request. Please try again.