Skip to content

Commit

Permalink
Use frozen strings
Browse files Browse the repository at this point in the history
  • Loading branch information
kirs authored and jeremyevans committed Jan 6, 2021
1 parent 650289c commit 9279dd8
Show file tree
Hide file tree
Showing 34 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion lib/webrick/accesslog.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#--
# accesslog.rb -- Access log handling utilities
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/cgi.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# cgi.rb -- Yet another CGI library
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/compat.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# compat.rb -- cross platform compatibility
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/config.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# config.rb -- Default configurations.
#
Expand Down
4 changes: 2 additions & 2 deletions lib/webrick/cookie.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# cookie.rb -- Cookie class
#
Expand Down Expand Up @@ -92,7 +92,7 @@ def expires
# The cookie string suitable for use in an HTTP header

def to_s
ret = ""
ret = +""
ret << @name << "=" << @value
ret << "; " << "Version=" << @version.to_s if @version > 0
ret << "; " << "Domain=" << @domain if @domain
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/htmlutils.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#--
# htmlutils.rb -- HTMLUtils Module
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpauth.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httpauth.rb -- HTTP access authentication
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpauth/authenticator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#--
# httpauth/authenticator.rb -- Authenticator mix-in module.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpauth/basicauth.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httpauth/basicauth.rb -- HTTP basic access authentication
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpauth/digestauth.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httpauth/digestauth.rb -- HTTP digest access authentication
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpauth/htdigest.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httpauth/htdigest.rb -- Apache compatible htdigest file
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpauth/htgroup.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httpauth/htgroup.rb -- Apache compatible htgroup file
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpauth/htpasswd.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httpauth/htpasswd -- Apache compatible htpasswd file
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpauth/userdb.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#--
# httpauth/userdb.rb -- UserDB mix-in module.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpproxy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httpproxy.rb -- HTTPProxy Class
#
Expand Down
4 changes: 2 additions & 2 deletions lib/webrick/httprequest.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httprequest.rb -- HTTPRequest Class
#
Expand Down Expand Up @@ -171,7 +171,7 @@ def initialize(config)
@accept_charset = []
@accept_encoding = []
@accept_language = []
@body = ""
@body = +""

@addr = @peeraddr = nil
@attributes = {}
Expand Down
12 changes: 6 additions & 6 deletions lib/webrick/httpresponse.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httpresponse.rb -- HTTPResponse Class
#
Expand Down Expand Up @@ -332,7 +332,7 @@ def remove_body_tempfile # :nodoc:

def send_header(socket) # :nodoc:
if @http_version.major > 0
data = status_line()
data = status_line().dup
@header.each{|key, value|
tmp = key.gsub(/\bwww|^te$|\b\w/){ $&.upcase }
data << "#{tmp}: #{check_header(value)}" << CRLF
Expand Down Expand Up @@ -419,7 +419,7 @@ def check_header(header_value)
# :stopdoc:

def error_body(backtrace, ex, host, port)
@body = ''
@body = +''
@body << <<-_end_of_html_
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
Expand Down Expand Up @@ -453,11 +453,11 @@ def send_body_io(socket)
if @request_method == "HEAD"
# do nothing
elsif chunked?
buf = ''
buf = +''
begin
@body.readpartial(@buffer_size, buf)
size = buf.bytesize
data = "#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}"
data = +"#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}"
socket.write(data)
data.clear
@sent_size += size
Expand Down Expand Up @@ -539,7 +539,7 @@ def write(buf)
socket = @socket
@resp.instance_eval {
size = buf.bytesize
data = "#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}"
data = +"#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}"
socket.write(data)
data.clear
@sent_size += size
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/https.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# https.rb -- SSL/TLS enhancement for HTTPServer
#
Expand Down
4 changes: 2 additions & 2 deletions lib/webrick/httpserver.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httpserver.rb -- HTTPServer Class
#
Expand Down Expand Up @@ -285,7 +285,7 @@ def compile
end

def normalize(dir)
ret = dir ? dir.dup : ""
ret = dir ? dir.dup : +""
ret.sub!(%r|/+\z|, "")
ret
end
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpservlet.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httpservlet.rb -- HTTPServlet Utility File
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpservlet/abstract.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httpservlet.rb -- HTTPServlet Module
#
Expand Down
4 changes: 2 additions & 2 deletions lib/webrick/httpservlet/cgi_runner.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# cgi_runner.rb -- CGI launcher.
#
Expand All @@ -10,7 +10,7 @@
# $IPR: cgi_runner.rb,v 1.9 2002/09/25 11:33:15 gotoyuzo Exp $

def sysread(io, size)
buf = ""
buf = +""
while size > 0
tmp = io.sysread(size)
buf << tmp
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpservlet/cgihandler.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# cgihandler.rb -- CGIHandler Class
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpservlet/erbhandler.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# erbhandler.rb -- ERBHandler Class
#
Expand Down
10 changes: 5 additions & 5 deletions lib/webrick/httpservlet/filehandler.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# filehandler.rb -- FileHandler Module
#
Expand Down Expand Up @@ -481,9 +481,9 @@ def set_dir_list(req, res)
elsif !namewidth or (namewidth = namewidth.to_i) < 2
namewidth = 25
end
query = query.inject('') {|s, (k, v)| s << '&' << HTMLUtils::escape("#{k}=#{v}")}
query = query.inject('') {|s, (k, v)| s << '&' << HTMLUtils::escape("#{k}=#{v}")}.dup

type = "text/html"
type = +"text/html"
case enc = Encoding.find('filesystem')
when Encoding::US_ASCII, Encoding::ASCII_8BIT
else
Expand All @@ -492,7 +492,7 @@ def set_dir_list(req, res)
res['content-type'] = type

title = "Index of #{HTMLUtils::escape(req.path)}"
res.body = <<-_end_of_html_
res.body = +<<-_end_of_html_
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
Expand Down Expand Up @@ -528,7 +528,7 @@ def set_dir_list(req, res)
else
dname = name
end
s = "<TR><TD class=\"name\"><A HREF=\"#{HTTPUtils::escape(name)}#{query if name.end_with?('/')}\">#{HTMLUtils::escape(dname)}</A></TD>"
s = +"<TR><TD class=\"name\"><A HREF=\"#{HTTPUtils::escape(name)}#{query if name.end_with?('/')}\">#{HTMLUtils::escape(dname)}</A></TD>"
s << "<TD class=\"mtime\">" << (time ? time.strftime("%Y/%m/%d %H:%M") : "") << "</TD>"
s << "<TD class=\"size\">" << (size >= 0 ? size.to_s : "-") << "</TD></TR>\n"
res.body << s
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpservlet/prochandler.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# prochandler.rb -- ProcHandler Class
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpstatus.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#--
# httpstatus.rb -- HTTPStatus Class
#
Expand Down
6 changes: 3 additions & 3 deletions lib/webrick/httputils.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# httputils.rb -- HTTPUtils Module
#
Expand Down Expand Up @@ -231,7 +231,7 @@ def dequote(str)
# Quotes and escapes quotes in +str+

def quote(str)
'"' << str.gsub(/[\\\"]/o, "\\\1") << '"'
+'"' << str.gsub(/[\\\"]/o, "\\\1") << '"'
end
module_function :quote

Expand Down Expand Up @@ -495,7 +495,7 @@ def unescape_form(str)
# Escapes path +str+

def escape_path(str)
result = ""
result = +""
str.scan(%r{/([^/]*)}).each{|i|
result << "/" << _escape(i[0], UNESCAPED_PCHAR)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/httpversion.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#--
# HTTPVersion.rb -- presentation of HTTP version
#
Expand Down
14 changes: 7 additions & 7 deletions lib/webrick/log.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#--
# log.rb -- Log Class
#
Expand Down Expand Up @@ -86,15 +86,15 @@ def <<(obj)
end

# Shortcut for logging a FATAL message
def fatal(msg) log(FATAL, "FATAL " << format(msg)); end
def fatal(msg) log(FATAL, "FATAL " + format(msg)); end
# Shortcut for logging an ERROR message
def error(msg) log(ERROR, "ERROR " << format(msg)); end
def error(msg) log(ERROR, "ERROR " + format(msg)); end
# Shortcut for logging a WARN message
def warn(msg) log(WARN, "WARN " << format(msg)); end
def warn(msg) log(WARN, "WARN " + format(msg)); end
# Shortcut for logging an INFO message
def info(msg) log(INFO, "INFO " << format(msg)); end
def info(msg) log(INFO, "INFO " + format(msg)); end
# Shortcut for logging a DEBUG message
def debug(msg) log(DEBUG, "DEBUG " << format(msg)); end
def debug(msg) log(DEBUG, "DEBUG " + format(msg)); end

# Will the logger output FATAL messages?
def fatal?; @level >= FATAL; end
Expand All @@ -118,7 +118,7 @@ def debug?; @level >= DEBUG; end
# * Otherwise it will return +arg+.inspect.
def format(arg)
if arg.is_a?(Exception)
"#{arg.class}: #{AccessLog.escape(arg.message)}\n\t" <<
+"#{arg.class}: #{AccessLog.escape(arg.message)}\n\t" <<
arg.backtrace.join("\n\t") << "\n"
elsif arg.respond_to?(:to_str)
AccessLog.escape(arg.to_str)
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/server.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# server.rb -- GenericServer Class
#
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/ssl.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# ssl.rb -- SSL/TLS enhancement for GenericServer
#
Expand Down
4 changes: 2 additions & 2 deletions lib/webrick/utils.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# utils.rb -- Miscellaneous utilities
#
Expand Down Expand Up @@ -78,7 +78,7 @@ def create_listeners(address, port)
# Generates a random string of length +len+
def random_string(len)
rand_max = RAND_CHARS.bytesize
ret = ""
ret = +""
len.times{ ret << RAND_CHARS[rand(rand_max)] }
ret
end
Expand Down
2 changes: 1 addition & 1 deletion lib/webrick/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#--
# version.rb -- version and release date
#
Expand Down

0 comments on commit 9279dd8

Please sign in to comment.