# asserts that the request method is the +method+ given as a parameter
# or raises a suitable error. +method+ should be a symbol, e.g: :put or :get.
def assert_method(method)
- ok = request.send((method.to_s.downcase + "?").to_sym)
+ ok = request.send(:"#{method.to_s.downcase}?")
raise OSM::APIBadMethodError, method unless ok
end
gravatar_enabled = gravatar_enable(current_user)
if current_user.save
flash[:notice] = if gravatar_enabled
- t("users.confirm_email.success") + " " + gravatar_status_message(current_user)
+ "#{t('users.confirm_email.success')} #{gravatar_status_message(current_user)}"
else
t("users.confirm_email.success")
end
##
# omniauth failure callback
def auth_failure
- flash[:error] = t("users.auth_failure." + params[:message])
+ flash[:error] = t("users.auth_failure.#{params[:message]}")
redirect_to params[:origin] || login_url
end
if referer.nil?
params[:origin] = request.path
else
- params[:origin] = request.path + "?referer=" + CGI.escape(referer)
+ params[:origin] = "#{request.path}?referer=#{CGI.escape(referer)}"
params[:referer] = referer
end
if object.redacted?
""
else
- h(icon_tags(object).map { |k, v| k + "=" + v }.to_sentence)
+ h(icon_tags(object).map { |k, v| "#{k}=#{v}" }.to_sentence)
end
end
require "optparse"
LOCALE_DIR = File.dirname(__FILE__) + "/../../config/locales/"
-EN = YAML.load_file(LOCALE_DIR + "en.yml")
+EN = YAML.load_file("#{LOCALE_DIR}en.yml")
def iterate(hash, fhash = {}, path = "", outfile = $stdout)
hash.each do |key, val|
fhash[key] = {} unless fhash.key? key
if val.is_a? Hash
fhash[key] = {} unless fhash[key].is_a? Hash
- iterate(val, fhash[key], path + key + ":", outfile)
+ iterate(val, fhash[key], "#{path}#{key}:#{outfile}")
else
outfile.puts "msgctxt \"#{path}#{key}\""
outfile.puts "msgid \"#{val}\""
def lang2po(lang, outfile = $stdout)
puts lang
- infile = LOCALE_DIR + lang + ".yml"
+ infile = "#{LOCALE_DIR}#{lang}.yml"
if File.exist? infile
oth = YAML.load_file(infile)
oth = oth[lang]
opt = ARGV[0]
if opt == "--all"
# Produce .po files for all langs, and a .pot template
- PO_DIR = LOCALE_DIR + "po/"
- Dir.mkdir(PO_DIR) unless File.directory?(PO_DIR)
- Dir.glob(LOCALE_DIR + "*.yml") do |filename|
+ po_dir = "#{LOCALE_DIR}po/"
+ Dir.mkdir(po_dir) unless File.directory?(po_dir)
+ Dir.glob("#{LOCALE_DIR}/*.yml") do |filename|
lang = File.basename(filename, ".yml")
unless lang == "en"
- outfile = File.new(PO_DIR + "#{lang}.po", "w")
+ outfile = File.new("#{po_dir}#{lang}.po", "w")
lang2po(lang, outfile)
outfile.close
end
end
- outfile = File.new(PO_DIR + "rails_port.pot", "w")
+ outfile = File.new("#{po_dir}rails_port.pot", "w")
iterate(EN["en"], {}, "", outfile)
outfile.close
elsif opt
anchor = "map=#{zoom}/#{lat}/#{lon}"
# test without marker
- get "/go/" + short_link
+ get "/go/#{short_link}"
assert_redirected_to :controller => "site", :action => "index", :anchor => anchor
# test with marker
- get "/go/" + short_link + "?m"
+ get "/go/#{short_link}?m"
assert_redirected_to :controller => "site", :action => "index", :mlat => lat.to_s, :mlon => lon.to_s, :anchor => anchor
# test with layers and a marker
- get "/go/" + short_link + "?m&layers=B000FTF"
+ get "/go/#{short_link}?m&layers=B000FTF"
assert_redirected_to :controller => "site", :action => "index", :mlat => lat.to_s, :mlon => lon.to_s, :anchor => "#{anchor}&layers=B000FTF"
- get "/go/" + short_link + "?layers=B000FTF&m"
+ get "/go/#{short_link}?layers=B000FTF&m"
assert_redirected_to :controller => "site", :action => "index", :mlat => lat.to_s, :mlon => lon.to_s, :anchor => "#{anchor}&layers=B000FTF"
# test with some random query parameters we haven't even implemented yet
- get "/go/" + short_link + "?foobar=yes"
+ get "/go/#{short_link}?foobar=yes"
assert_redirected_to :controller => "site", :action => "index", :foobar => "yes", :anchor => anchor
end
end