Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added Symbol.to_proc core extension to ensure compatibility with Ruby…

… 1.8.6.
  • Loading branch information...
commit f014839e919d275de970368b31290c0714056307 1 parent abc762d
@weppos authored
View
2  CHANGELOG.rdoc
@@ -5,6 +5,8 @@
* FIXED: Normalize 'nameservers' property return value. Always return an Array even if there's no nameserver.
+* ADDED: Added Symbol.to_proc core extension to ensure compatibility with Ruby 1.8.6.
+
* CHANGED: Suppress Japanese output for the .js TLD [axic]
View
14 lib/core_ext.rb
@@ -0,0 +1,14 @@
+unless :to_proc.respond_to?(:to_proc)
+ class Symbol
+ # Turns the symbol into a simple proc, which is especially useful for enumerations. Examples:
+ #
+ # # The same as people.collect { |p| p.name }
+ # people.collect(&:name)
+ #
+ # # The same as people.select { |p| p.manager? }.collect { |p| p.salary }
+ # people.select(&:manager?).collect(&:salary)
+ def to_proc
+ Proc.new { |*args| args.shift.__send__(self, *args) }
+ end
+ end
+end
View
1  lib/whois.rb
@@ -14,6 +14,7 @@
#++
+require 'core_ext'
require 'whois/version'
require 'whois/errors'
require 'whois/client'
View
2  lib/whois/answer.rb
@@ -79,7 +79,7 @@ def eql?(other)
# # => "First answer.\nSecond answer."
#
def content
- @content ||= parts.map { |part| part.response }.join("\n")
+ @content ||= parts.map(&:response).join("\n")
end
# Returns whether this answer changed compared to <tt>other</tt>.
View
2  lib/whois/answer/parser/whois.nic.nu.rb
@@ -71,7 +71,7 @@ class WhoisNicNu < Base
property_supported :nameservers do
@nameservers ||= if content =~ /Domain servers in listed order:(.*)Owner and Administrative Contact information for domains/m
- $1.split.map { |s| s.strip }
+ $1.split.map(&:strip)
else
[]
end
View
2  lib/whois/answer/parser/whois.nic.tv.rb
@@ -86,7 +86,7 @@ class WhoisNicTv < Base
property_supported :nameservers do
- @nameservers ||= node("Name Server") { |raw| raw.map { |value| value.downcase }}
+ @nameservers ||= node("Name Server") { |raw| raw.map(&:downcase) }
@nameservers ||= []
end
View
2  lib/whois/answer/parser/whois.publicinterestregistry.net.rb
@@ -97,7 +97,7 @@ class WhoisPublicinterestregistryNet < Base
property_supported :nameservers do
- @nameservers ||= node("Name Server") { |server| server.reject { |value| value.empty? }.map { |value| value.downcase }}
+ @nameservers ||= node("Name Server") { |server| server.reject(&:empty?).map(&:downcase) }
@nameservers ||= []
end
View
2  lib/whois/answer/parser/whois.registrypro.pro.rb
@@ -67,7 +67,7 @@ class WhoisRegistryproPro < Base
property_supported :nameservers do
- @nameservers ||= content_for_scanner.scan(/Name Server:(.*?)\n/).flatten.map { |value| value.downcase }
+ @nameservers ||= content_for_scanner.scan(/Name Server:(.*?)\n/).flatten.map(&:downcase)
end
end
View
2  lib/whois/answer/parser/whois.ripn.net.rb
@@ -36,7 +36,7 @@ class WhoisRipnNet < Base
property_supported :status do
@status ||= if content_for_scanner =~ /state:\s+(.*?)\n/
- $1.split(",").map { |status| status.strip }
+ $1.split(",").map(&:strip)
else
[]
end
Please sign in to comment.
Something went wrong with that request. Please try again.