Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable frozen_string_literal feature. #1076

Merged
merged 1 commit into from
Feb 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/sinatra/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# external dependencies
require 'rack'
require 'tilt'
Expand Down Expand Up @@ -268,7 +270,7 @@ def redirect(uri, *args)
# Takes Rack routers and reverse proxies into account.
def uri(addr = nil, absolute = true, add_script_name = true)
return addr if addr =~ /\A[A-z][A-z0-9\+\.\-]*:/
uri = [host = ""]
uri = [host = String.new]
if absolute
host << "http#{'s' if request.secure?}://"
if request.forwarded? or request.port != (request.secure? ? 443 : 80)
Expand Down Expand Up @@ -342,7 +344,7 @@ def content_type(type = nil, params = {})

# Set the Content-Disposition to "attachment" with the specified filename,
# instructing the user agents to prompt to save.
def attachment(filename = nil, disposition = 'attachment')
def attachment(filename = nil, disposition = :attachment)
response['Content-Disposition'] = disposition.to_s
if filename
params = '; filename="%s"' % File.basename(filename)
Expand All @@ -360,8 +362,8 @@ def send_file(path, opts = {})

disposition = opts[:disposition]
filename = opts[:filename]
disposition = 'attachment' if disposition.nil? and filename
filename = path if filename.nil?
disposition = :attachment if disposition.nil? and filename
filename = path if filename.nil?
attachment(filename, disposition) if disposition

last_modified opts[:last_modified] if opts[:last_modified]
Expand Down Expand Up @@ -1299,7 +1301,7 @@ def inline_templates=(file = nil)
data.each_line do |line|
lines += 1
if line =~ /^@@\s*(.*\S)\s*$/
template = force_encoding('', encoding)
template = force_encoding(String.new, encoding)
templates[$1.to_sym] = [template, file, lines]
elsif template
template << line
Expand Down
2 changes: 2 additions & 0 deletions lib/sinatra/show_exceptions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rack/show_exceptions'

module Sinatra
Expand Down