Project

General

Profile

Feature #10177 ยป Replace_Hash#has_something.PATCH

gogotanaka (Kazuki Tanaka), 08/27/2014 10:55 PM

View differences:

lib/cgi/cookie.rb
end
options = name
unless options.has_key?("name")
unless options.key?("name")
raise ArgumentError, "`name' required"
end
......
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)
lib/cgi/core.rb
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
......
# 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?
lib/cgi/html.rb
{ "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
......
pretty = " " if true == pretty
buf = ""
if attributes.has_key?("DOCTYPE")
if attributes.key?("DOCTYPE")
if attributes["DOCTYPE"]
buf << attributes.delete("DOCTYPE")
else
......
{ "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
lib/drb/drb.rb
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
lib/mkmf.rb
['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)'],
......
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
lib/net/imap.rb
# 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
......
end
def record_response(name, data)
unless @responses.has_key?(name)
unless @responses.key?(name)
@responses[name] = []
end
@responses[name].push(data)
......
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
lib/net/telnet.rb
#
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"])
......
end
end
unless @options.has_key?("Telnetmode")
unless @options.key?("Telnetmode")
@options["Telnetmode"] = true
else
unless (true == @options["Telnetmode"] or false == @options["Telnetmode"])
......
@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
......
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)
......
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
......
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
......
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
......
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
......
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) <
......
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
......
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
......
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
lib/rake/task_arguments.rb
# 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)
lib/rexml/functions.rb
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]
......
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
lib/rexml/parsers/baseparser.rb
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
lib/rexml/parsers/sax2parser.rb
copy = event[1].clone
esub = proc { |match|
if @entities.has_key?($1)
if @entities.key?($1)
@entities[$1].gsub(Text::REFERENCE, &esub)
else
match
lib/rss/atom.rb
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
lib/rss/parser.rb
# 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
......
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
lib/rss/rss.rb
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
......
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
......
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
......
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
lib/rubygems/commands/push_command.rb
# 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
lib/webrick/cgi.rb
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
lib/webrick/httpauth/digestauth.rb
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
......
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'])
lib/webrick/httpservlet/cgihandler.rb
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)
}
lib/webrick/httputils.rb
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
......
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
......
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
lib/xmlrpc/parser.rb
# * <code>'faultString'</code> 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"])
    (1-1/1)