diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb index 3ec884d..852e3ee 100644 --- a/lib/cgi/cookie.rb +++ b/lib/cgi/cookie.rb @@ -74,7 +74,7 @@ class CGI end options = name - unless options.has_key?("name") + unless options.key?("name") raise ArgumentError, "`name' required" end @@ -150,7 +150,7 @@ class CGI name = CGI.unescape(name) values ||= "" values = values.split('&').collect{|v| CGI.unescape(v,@@accept_charset) } - if cookies.has_key?(name) + if cookies.key?(name) values = cookies[name].value + values end cookies[name] = Cookie.new(name, *values) diff --git a/lib/cgi/core.rb b/lib/cgi/core.rb index 08c2f77..731b08e 100644 --- a/lib/cgi/core.rb +++ b/lib/cgi/core.rb @@ -154,7 +154,7 @@ class CGI content_type = options buf = _header_for_string(content_type) elsif options.is_a?(Hash) - if options.size == 1 && options.has_key?('type') + if options.size == 1 && options.key?('type') content_type = options['type'] buf = _header_for_string(content_type) else @@ -717,7 +717,7 @@ class CGI # Returns true if a given query string parameter exists. def has_key?(*args) - @params.has_key?(*args) + @params.key?(*args) end alias key? has_key? alias include? has_key? diff --git a/lib/cgi/html.rb b/lib/cgi/html.rb index ed0c07b..7cbf3a0 100644 --- a/lib/cgi/html.rb +++ b/lib/cgi/html.rb @@ -311,10 +311,10 @@ class CGI { "METHOD" => method, "ACTION" => action, "ENCTYPE" => enctype } else - unless method.has_key?("METHOD") + unless method.key?("METHOD") method["METHOD"] = "post" end - unless method.has_key?("ENCTYPE") + unless method.key?("ENCTYPE") method["ENCTYPE"] = enctype end method @@ -409,7 +409,7 @@ class CGI pretty = " " if true == pretty buf = "" - if attributes.has_key?("DOCTYPE") + if attributes.key?("DOCTYPE") if attributes["DOCTYPE"] buf << attributes.delete("DOCTYPE") else @@ -503,10 +503,10 @@ class CGI { "METHOD" => "post", "ACTION" => action, "ENCTYPE" => enctype } else - unless action.has_key?("METHOD") + unless action.key?("METHOD") action["METHOD"] = "post" end - unless action.has_key?("ENCTYPE") + unless action.key?("ENCTYPE") action["ENCTYPE"] = enctype end action diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb index 26f39b7..91962b8 100644 --- a/lib/drb/drb.rb +++ b/lib/drb/drb.rb @@ -863,8 +863,8 @@ module DRb 0, Socket::AI_PASSIVE) families = Hash[*infos.collect { |af, *_| af }.uniq.zip([]).flatten] - return TCPServer.open('0.0.0.0', port) if families.has_key?('AF_INET') - return TCPServer.open('::', port) if families.has_key?('AF_INET6') + return TCPServer.open('0.0.0.0', port) if families.key?('AF_INET') + return TCPServer.open('::', port) if families.key?('AF_INET6') return TCPServer.open(port) # :stopdoc: end diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 6177e04..edb44a2 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -197,7 +197,7 @@ module MakeMakefile ['HDRDIR', '$(rubyhdrdir)/ruby$(target_prefix)'], ['ARCHHDRDIR', '$(rubyhdrdir)/$(arch)/ruby$(target_prefix)'], ] - elsif $configure_args.has_key?('--vendor') + elsif $configure_args.key?('--vendor') dirs = [ ['BINDIR', '$(bindir)'], ['RUBYCOMMONDIR', '$(vendordir)$(target_prefix)'], @@ -1876,7 +1876,7 @@ VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])} next unless /dir$/ =~ key mk << "#{key} = #{with_destdir(var)}\n" end - if !$extmk and !$configure_args.has_key?('--ruby') and + if !$extmk and !$configure_args.key?('--ruby') and sep = config_string('BUILD_FILE_SEPARATOR') sep = ":/=#{sep}" else diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 85644f3..cbaa2e5 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -410,7 +410,7 @@ module Net # A Net::IMAP::NoResponseError is raised if authentication fails. def authenticate(auth_type, *args) auth_type = auth_type.upcase - unless @@authenticators.has_key?(auth_type) + unless @@authenticators.key?(auth_type) raise ArgumentError, format('unknown auth type - "%s"', auth_type) end @@ -1195,7 +1195,7 @@ module Net end def record_response(name, data) - unless @responses.has_key?(name) + unless @responses.key?(name) @responses[name] = [] end @responses[name].push(data) @@ -3506,7 +3506,7 @@ module Net STAGE_TWO = :stage_two def nc(nonce) - if @nc.has_key? nonce + if @nc.key? nonce @nc[nonce] = @nc[nonce] + 1 else @nc[nonce] = 1 diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb index f178a7b..c7130a5 100644 --- a/lib/net/telnet.rb +++ b/lib/net/telnet.rb @@ -272,12 +272,12 @@ module Net # def initialize(options) # :yield: mesg @options = options - @options["Host"] = "localhost" unless @options.has_key?("Host") - @options["Port"] = 23 unless @options.has_key?("Port") - @options["Prompt"] = /[$%#>] \z/n unless @options.has_key?("Prompt") - @options["Timeout"] = 10 unless @options.has_key?("Timeout") - @options["Waittime"] = 0 unless @options.has_key?("Waittime") - unless @options.has_key?("Binmode") + @options["Host"] = "localhost" unless @options.key?("Host") + @options["Port"] = 23 unless @options.key?("Port") + @options["Prompt"] = /[$%#>] \z/n unless @options.key?("Prompt") + @options["Timeout"] = 10 unless @options.key?("Timeout") + @options["Waittime"] = 0 unless @options.key?("Waittime") + unless @options.key?("Binmode") @options["Binmode"] = false else unless (true == @options["Binmode"] or false == @options["Binmode"]) @@ -285,7 +285,7 @@ module Net end end - unless @options.has_key?("Telnetmode") + unless @options.key?("Telnetmode") @options["Telnetmode"] = true else unless (true == @options["Telnetmode"] or false == @options["Telnetmode"]) @@ -295,13 +295,13 @@ module Net @telnet_option = { "SGA" => false, "BINARY" => false } - if @options.has_key?("Output_log") + if @options.key?("Output_log") @log = File.open(@options["Output_log"], 'a+') @log.sync = true @log.binmode end - if @options.has_key?("Dump_log") + if @options.key?("Dump_log") @dumplog = File.open(@options["Dump_log"], 'a+') @dumplog.sync = true @dumplog.binmode @@ -328,7 +328,7 @@ module Net end end - if @options.has_key?("Proxy") + if @options.key?("Proxy") if @options["Proxy"].kind_of?(Net::Telnet) @sock = @options["Proxy"].sock elsif @options["Proxy"].kind_of?(IO) @@ -339,8 +339,8 @@ module Net else message = "Trying " + @options["Host"] + "...\n" yield(message) if block_given? - @log.write(message) if @options.has_key?("Output_log") - @dumplog.log_dump('#', message) if @options.has_key?("Dump_log") + @log.write(message) if @options.key?("Output_log") + @dumplog.log_dump('#', message) if @options.key?("Dump_log") begin if @options["Timeout"] == false @@ -353,8 +353,8 @@ module Net rescue Net::OpenTimeout raise Net::OpenTimeout, "timed out while opening a connection to the host" rescue - @log.write($ERROR_INFO.to_s + "\n") if @options.has_key?("Output_log") - @dumplog.log_dump('#', $ERROR_INFO.to_s + "\n") if @options.has_key?("Dump_log") + @log.write($ERROR_INFO.to_s + "\n") if @options.key?("Output_log") + @dumplog.log_dump('#', $ERROR_INFO.to_s + "\n") if @options.key?("Dump_log") raise end @sock.sync = true @@ -362,8 +362,8 @@ module Net message = "Connected to " + @options["Host"] + ".\n" yield(message) if block_given? - @log.write(message) if @options.has_key?("Output_log") - @dumplog.log_dump('#', message) if @options.has_key?("Dump_log") + @log.write(message) if @options.key?("Output_log") + @dumplog.log_dump('#', message) if @options.key?("Dump_log") end end # initialize @@ -531,16 +531,16 @@ module Net fail_eof = @options["FailEOF"] if options.kind_of?(Hash) - prompt = if options.has_key?("Match") + prompt = if options.key?("Match") options["Match"] - elsif options.has_key?("Prompt") + elsif options.key?("Prompt") options["Prompt"] - elsif options.has_key?("String") + elsif options.key?("String") Regexp.new( Regexp.quote(options["String"]) ) end - time_out = options["Timeout"] if options.has_key?("Timeout") - waittime = options["Waittime"] if options.has_key?("Waittime") - fail_eof = options["FailEOF"] if options.has_key?("FailEOF") + time_out = options["Timeout"] if options.key?("Timeout") + waittime = options["Waittime"] if options.key?("Waittime") + fail_eof = options["FailEOF"] if options.key?("FailEOF") else prompt = options end @@ -558,7 +558,7 @@ module Net end begin c = @sock.readpartial(1024 * 1024) - @dumplog.log_dump('<', c) if @options.has_key?("Dump_log") + @dumplog.log_dump('<', c) if @options.key?("Dump_log") if @options["Telnetmode"] c = rest + c if Integer(c.rindex(/#{IAC}#{SE}/no) || 0) < @@ -588,7 +588,7 @@ module Net buf.gsub!(/#{EOL}/no, "\n") end end - @log.print(buf) if @options.has_key?("Output_log") + @log.print(buf) if @options.key?("Output_log") line += buf yield buf if block_given? rescue EOFError # End of file reached @@ -611,7 +611,7 @@ module Net length = string.length while 0 < length IO::select(nil, [@sock]) - @dumplog.log_dump('>', string[-length..-1]) if @options.has_key?("Dump_log") + @dumplog.log_dump('>', string[-length..-1]) if @options.key?("Dump_log") length -= @sock.syswrite(string[-length..-1]) end end @@ -682,9 +682,9 @@ module Net if options.kind_of?(Hash) string = options["String"] - match = options["Match"] if options.has_key?("Match") - time_out = options["Timeout"] if options.has_key?("Timeout") - fail_eof = options["FailEOF"] if options.has_key?("FailEOF") + match = options["Match"] if options.key?("Match") + time_out = options["Timeout"] if options.key?("Timeout") + fail_eof = options["FailEOF"] if options.key?("FailEOF") else string = options end diff --git a/lib/rake/task_arguments.rb b/lib/rake/task_arguments.rb index fc0d657..530278f 100644 --- a/lib/rake/task_arguments.rb +++ b/lib/rake/task_arguments.rb @@ -80,13 +80,13 @@ module Rake # Returns true if +key+ is one of the arguments def has_key?(key) - @hash.has_key?(key) + @hash.key?(key) end protected def lookup(name) # :nodoc: - if @hash.has_key?(name) + if @hash.key?(name) @hash[name] elsif @parent @parent.lookup(name) diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb index 7809cc3..bd5bb70 100644 --- a/lib/rexml/functions.rb +++ b/lib/rexml/functions.rb @@ -252,7 +252,7 @@ module REXML map = {} 0.upto(from.length - 1) { |pos| from_char = from[pos] - unless map.has_key? from_char + unless map.key? from_char map[from_char] = if pos < to.length to[pos] @@ -264,11 +264,11 @@ module REXML if ''.respond_to? :chars string(string).chars.collect { |c| - if map.has_key? c then map[c] else c end + if map.key? c then map[c] else c end }.compact.join else string(string).unpack('U*').collect { |c| - if map.has_key? c then map[c] else c end + if map.key? c then map[c] else c end }.compact.pack('U*') end end diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb index 4f0926f..01c04ce 100644 --- a/lib/rexml/parsers/baseparser.rb +++ b/lib/rexml/parsers/baseparser.rb @@ -398,7 +398,7 @@ module REXML prefixes << prefix unless prefix == "xml" end - if attributes.has_key?(attr_name) + if attributes.key?(attr_name) msg = "Duplicate attribute #{attr_name.inspect}" raise REXML::ParseException.new(msg, @source, self) end diff --git a/lib/rexml/parsers/sax2parser.rb b/lib/rexml/parsers/sax2parser.rb index 40877ff..f8d2b56 100644 --- a/lib/rexml/parsers/sax2parser.rb +++ b/lib/rexml/parsers/sax2parser.rb @@ -161,7 +161,7 @@ module REXML copy = event[1].clone esub = proc { |match| - if @entities.has_key?($1) + if @entities.key?($1) @entities[$1].gsub(Text::REFERENCE, &esub) else match diff --git a/lib/rss/atom.rb b/lib/rss/atom.rb index 8133f72..cb1c73f 100644 --- a/lib/rss/atom.rb +++ b/lib/rss/atom.rb @@ -236,7 +236,7 @@ module RSS rel = link.rel || "alternate" next unless rel == "alternate" key = [link.hreflang, link.type] - if link_infos.has_key?(key) + if link_infos.key?(key) raise TooMuchTagError.new("link", tag_name) end link_infos[key] = true diff --git a/lib/rss/parser.rb b/lib/rss/parser.rb index 86e383c..38fbcf8 100644 --- a/lib/rss/parser.rb +++ b/lib/rss/parser.rb @@ -205,7 +205,7 @@ module RSS # test if this uri is registered against this name def uri_registered?(uri, name) - @@registered_uris[name].has_key?(uri) + @@registered_uris[name].key?(uri) end # record class_name for the supplied uri and tag_name @@ -288,7 +288,7 @@ module RSS def instruction(name, content) if name == "xml-stylesheet" params = parse_pi_content(content) - if params.has_key?("href") + if params.key?("href") @xml_stylesheets << XMLStyleSheet.new(params) end end diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb index 6c9b290..bac9852 100644 --- a/lib/rss/rss.rb +++ b/lib/rss/rss.rb @@ -846,7 +846,7 @@ EOC end def install_ns(prefix, uri) - if self::NSPOOL.has_key?(prefix) + if self::NSPOOL.key?(prefix) raise OverlappedPrefixError.new(prefix) end self::NSPOOL[prefix] = uri @@ -951,7 +951,7 @@ EOC prefix = "" prefix << "#{klass.required_prefix}_" if klass.required_prefix key = "#{prefix}#{tag_name.gsub(/-/, '_')}" - if self.class.plural_forms.has_key?(key) + if self.class.plural_forms.key?(key) ary = __send__("#{self.class.plural_forms[key]}") ary << next_element else @@ -1051,7 +1051,7 @@ EOC value = __send__(alias_name || name) return nil if required and value.nil? next if value.nil? - return nil if attrs.has_key?(name) + return nil if attrs.key?(name) attrs[name] = value end attrs @@ -1223,7 +1223,7 @@ EOC def tag_filter(tags) rv = {} tags.each do |tag| - rv[tag[0]] = [] unless rv.has_key?(tag[0]) + rv[tag[0]] = [] unless rv.key?(tag[0]) rv[tag[0]].push(tag[1]) end rv diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb index 6899b48..b574324 100644 --- a/lib/rubygems/commands/push_command.rb +++ b/lib/rubygems/commands/push_command.rb @@ -78,7 +78,7 @@ You can upgrade or downgrade to the latest release version with: # Always include this, even if it's nil args << @host - if gem_data.spec.metadata.has_key?('allowed_push_host') + if gem_data.spec.metadata.key?('allowed_push_host') args << gem_data.spec.metadata['allowed_push_host'] end diff --git a/lib/webrick/cgi.rb b/lib/webrick/cgi.rb index 80f636e..2181fe0 100644 --- a/lib/webrick/cgi.rb +++ b/lib/webrick/cgi.rb @@ -54,7 +54,7 @@ module WEBrick def initialize(*args) if defined?(MOD_RUBY) - unless ENV.has_key?("GATEWAY_INTERFACE") + unless ENV.key?("GATEWAY_INTERFACE") Apache.request.setup_cgi_env end end diff --git a/lib/webrick/httpauth/digestauth.rb b/lib/webrick/httpauth/digestauth.rb index 2a5e71e..b5b4094 100644 --- a/lib/webrick/httpauth/digestauth.rb +++ b/lib/webrick/httpauth/digestauth.rb @@ -172,7 +172,7 @@ module WEBrick req_params = MustParams end req_params.each{|key| - unless auth_req.has_key?(key) + unless auth_req.key?(key) error('%s: parameter missing. "%s"', auth_req['username'], key) raise HTTPStatus::BadRequest end @@ -195,7 +195,7 @@ module WEBrick return false end - if (@qop.nil? && auth_req.has_key?('qop')) || + if (@qop.nil? && auth_req.key?('qop')) || (@qop && (! @qop.member?(auth_req['qop']))) error('%s: the qop is not allowed. "%s"', auth_req['username'], auth_req['qop']) diff --git a/lib/webrick/httpservlet/cgihandler.rb b/lib/webrick/httpservlet/cgihandler.rb index 3210041..057d245 100644 --- a/lib/webrick/httpservlet/cgihandler.rb +++ b/lib/webrick/httpservlet/cgihandler.rb @@ -95,11 +95,11 @@ module WEBrick res.status = $1.to_i header.delete('status') end - if header.has_key?('location') + if header.key?('location') # RFC 3875 6.2.3, 6.2.4 res.status = 302 unless (300...400) === res.status end - if header.has_key?('set-cookie') + if header.key?('set-cookie') header['set-cookie'].each{|k| res.cookies << Cookie.parse_set_cookie(k) } diff --git a/lib/webrick/httputils.rb b/lib/webrick/httputils.rb index 82f69f3..e7bf816 100644 --- a/lib/webrick/httputils.rb +++ b/lib/webrick/httputils.rb @@ -144,7 +144,7 @@ module WEBrick when /^([A-Za-z0-9!\#$%&'*+\-.^_`|~]+):\s*(.*?)\s*\z/om field, value = $1, $2 field.downcase! - header[field] = [] unless header.has_key?(field) + header[field] = [] unless header.key?(field) header[field] << value when /^\s+(.*?)\s*\z/om value = $1 @@ -375,7 +375,7 @@ module WEBrick val = unescape_form(val.to_s) val = FormData.new(val) val.name = key - if query.has_key?(key) + if query.key?(key) query[key].append_data(val) next end @@ -399,7 +399,7 @@ module WEBrick if data data.chop! key = data.name - if form_data.has_key?(key) + if form_data.key?(key) form_data[key].append_data(data) else form_data[key] = data diff --git a/lib/xmlrpc/parser.rb b/lib/xmlrpc/parser.rb index 791eb05..44b2f0f 100644 --- a/lib/xmlrpc/parser.rb +++ b/lib/xmlrpc/parser.rb @@ -177,7 +177,7 @@ module XMLRPC # :nodoc: # * 'faultString' key is a String def self.fault(hash) if hash.kind_of? Hash and hash.size == 2 and - hash.has_key? "faultCode" and hash.has_key? "faultString" and + hash.key? "faultCode" and hash.key? "faultString" and hash["faultCode"].kind_of? Integer and hash["faultString"].kind_of? String XMLRPC::FaultException.new(hash["faultCode"], hash["faultString"])