Skip to content

Commit

Permalink
Merge 879f6e7 into 7f67e4e
Browse files Browse the repository at this point in the history
  • Loading branch information
casperisfine committed Apr 3, 2019
2 parents 7f67e4e + 879f6e7 commit 6085553
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/whois/server.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#--
# Ruby Whois
#
Expand Down Expand Up @@ -75,7 +76,9 @@ def load_json(file)
JSON.load(File.read(file)).each do |allocation, settings|
next if allocation == "_"
settings.reject! { |k, _| k.start_with?("_") }
define(type, allocation, settings.delete("host"), Hash[settings.map { |k,v| [k.to_sym, v] }])
host = settings.delete("host")
host = intern_string(host) if host
define(type, allocation, host, Hash[settings.map { |k,v| [k.to_sym, v.is_a?(String) ? intern_string(v) : v] }])
end
end

Expand Down Expand Up @@ -336,6 +339,15 @@ def _definitions(type = nil)
end
end

if String.method_defined?(:-@)
def intern_string(string)
-string
end
else
def intern_string(string)
string.freeze
end
end

def camelize(string)
string.to_s.split("_").collect(&:capitalize).join
Expand Down

0 comments on commit 6085553

Please sign in to comment.