- 'script/locale/reload-languages'
- 'script/update-spam-blocks'
+Naming/UncommunicativeMethodParamName:
+ Enabled: false
+
Rails/ApplicationRecord:
Enabled: false
def amf_handle_error(call, rootobj, rootid)
yield
rescue OSM::APIAlreadyDeletedError => ex
- return [-4, ex.object, ex.object_id]
+ [-4, ex.object, ex.object_id]
rescue OSM::APIVersionMismatchError => ex
- return [-3, [rootobj, rootid], [ex.type.downcase, ex.id, ex.latest]]
+ [-3, [rootobj, rootid], [ex.type.downcase, ex.id, ex.latest]]
rescue OSM::APIUserChangesetMismatchError => ex
- return [-2, ex.to_s]
+ [-2, ex.to_s]
rescue OSM::APIBadBoundingBox => ex
- return [-2, "Sorry - I can't get the map for that area. The server said: #{ex}"]
+ [-2, "Sorry - I can't get the map for that area. The server said: #{ex}"]
rescue OSM::APIError => ex
- return [-1, ex.to_s]
+ [-1, ex.to_s]
rescue StandardError => ex
- return [-2, "An unusual error happened (in #{call}). The server said: #{ex}"]
+ [-2, "An unusual error happened (in #{call}). The server said: #{ex}"]
end
def amf_handle_error_with_timeout(call, rootobj, rootid)
revdates.collect! { |d| [(d + 1).strftime("%d %b %Y, %H:%M:%S")] + revusers[d.to_i] }
revdates.uniq!
- return ["way", wayid, revdates]
+ ["way", wayid, revdates]
rescue ActiveRecord::RecordNotFound
- return ["way", wayid, []]
+ ["way", wayid, []]
end
# Find history of a node. Returns 'node', id, and an array of previous versions as above.
history = Node.find(nodeid).old_nodes.unredacted.reverse.collect do |old_node|
[(old_node.timestamp + 1).strftime("%d %b %Y, %H:%M:%S")] + change_user(old_node)
end
- return ["node", nodeid, history]
+ ["node", nodeid, history]
rescue ActiveRecord::RecordNotFound
- return ["node", nodeid, []]
+ ["node", nodeid, []]
end
def change_user(obj)
end
def getlocales
- @locales ||= Locale.list(Dir.glob(Rails.root.join("config", "potlatch", "locales", "*")).collect { |f| File.basename(f, ".yml") })
+ @getlocales ||= Locale.list(Dir.glob(Rails.root.join("config", "potlatch", "locales", "*")).collect { |f| File.basename(f, ".yml") })
end
##
end
def preferred_languages
- @languages ||= if params[:locale]
- Locale.list(params[:locale])
- elsif current_user
- current_user.preferred_languages
- else
- Locale.list(http_accept_language.user_preferred_languages)
- end
+ @preferred_languages ||= if params[:locale]
+ Locale.list(params[:locale])
+ elsif current_user
+ current_user.preferred_languages
+ else
+ Locale.list(http_accept_language.user_preferred_languages)
+ end
end
helper_method :preferred_languages
# restrict changes to those closed during a particular time period
def conditions_time(changesets, time)
if time.nil?
- return changesets
+ changesets
elsif time.count(",") == 1
# if there is a range, i.e: comma separated, then the first is
# low, second is high - same as with bounding boxes.
raise OSM::APIBadUserInput, "bad time range" if times.size != 2
from, to = times.collect { |t| Time.parse(t) }
- return changesets.where("closed_at >= ? and created_at <= ?", from, to)
+ changesets.where("closed_at >= ? and created_at <= ?", from, to)
else
# if there is no comma, assume its a lower limit on time
- return changesets.where("closed_at >= ?", Time.parse(time))
+ changesets.where("closed_at >= ?", Time.parse(time))
end
# stupid Time seems to throw both of these for bad parsing, so
# we have to catch both and ensure the correct code path is taken.
if current_user != @diary_entry.user
redirect_to :action => "view", :id => params[:id]
- elsif params[:diary_entry] && @diary_entry.update_attributes(entry_params)
+ elsif params[:diary_entry] && @diary_entry.update(entry_params)
redirect_to :action => "view", :id => params[:id]
end
def hide
entry = DiaryEntry.find(params[:id])
- entry.update_attributes(:visible => false)
+ entry.update(:visible => false)
redirect_to :action => "list", :display_name => entry.user.display_name
end
def hidecomment
comment = DiaryComment.find(params[:comment])
- comment.update_attributes(:visible => false)
+ comment.update(:visible => false)
redirect_to :action => "view", :display_name => comment.diary_entry.user.display_name, :id => comment.diary_entry.id
end
def update
@client_application = current_user.client_applications.find(params[:id])
- if @client_application.update_attributes(application_params)
+ if @client_application.update(application_params)
flash[:notice] = t "oauth_clients.update.flash"
redirect_to :action => "show", :id => @client_application.id
else
# ====================================================================
# Public methods
- # ---- trackpoints compile SWF of trackpoints
+ # ---- trackpoints compile SWF of trackpoints
def trackpoints
- # - Initialise
+ # - Initialise
baselong = params["baselong"].to_f
basey = params["basey"].to_f
params["xmax"], params["ymax"])
start = params["start"].to_i
- # - Begin movie
+ # - Begin movie
bounds_left = 0
bounds_right = 320 * 20
bounds_top = 240 * 20
m = ""
- m += swf_record(9, 255.chr + 155.chr + 155.chr) # Background
+ m += swf_record(9, 255.chr + 155.chr + 155.chr) # Background
absx = 0
absy = 0
xl = yb = 9999999
xr = yt = -9999999
- # - Send SQL for GPS tracks
+ # - Send SQL for GPS tracks
b = ""
lasttime = 0
m += swf_record(2, pack_u16(1) + pack_rect(xl, xr, yb, yt) + r)
m += swf_record(4, pack_u16(1) + pack_u16(1))
- # - Create Flash header and write to browser
+ # - Create Flash header and write to browser
m += swf_record(1, "") # Show frame
m += swf_record(0, "") # End
s += 2.chr # Two line styles
s += pack_u16(0) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF
s += pack_u16(0) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF
- s += 34.chr # 2 fill, 2 line index bits
+ s += 34.chr # 2 fill, 2 line index bits
s
end
d = "001001" # Line style change, moveTo
l = [length_sb(x), length_sb(y)].max
d += format("%05b%0*b%0*b", l, l, x, l, y)
- d += col # Select line style
+ d += col # Select line style
d
end
if @user_block.creator != current_user
flash[:error] = t("user_block.update.only_creator_can_edit")
redirect_to :action => "edit"
- elsif @user_block.update_attributes(
+ elsif @user_block.update(
:ends_at => Time.now.getutc + @block_period.hours,
:reason => params[:user_block][:reason],
:needs_view => params[:user_block][:needs_view]
end
def credentials
- @oauth_client ||= OAuth::Consumer.new(key, secret)
+ @credentials ||= OAuth::Consumer.new(key, secret)
end
def create_request_token(_params = {})
end
def invalidate!
- update_attributes(:invalidated_at => Time.now)
+ update(:invalidated_at => Time.now)
end
def authorized?
end
def preferred_languages
- @locales ||= Locale.list(languages)
+ @preferred_languages ||= Locale.list(languages)
end
def nearby(radius = NEARBY_RADIUS, num = NEARBY_USERS)
# revokes the block, allowing the user to use the API again. the argument
# is the user object who is revoking the ban.
def revoke!(revoker)
- update_attributes(
+ update(
:ends_at => Time.now.getutc,
:revoker_id => revoker.id,
:needs_view => false
require "yaml"
-if File.exist?(piwik_file = File.expand_path("../../piwik.yml", __FILE__))
+if File.exist?(piwik_file = File.expand_path("../piwik.yml", __dir__))
PIWIK = YAML.load_file(piwik_file)
end
create_table :node_tags, :id => false do |t|
t.column :id, :bigint, :null => false
t.column :version, :bigint, :null => false
- t.column :k, :string, :default => "", :null => false
- t.column :v, :string, :default => "", :null => false
+ t.column :k, :string, :default => "", :null => false
+ t.column :v, :string, :default => "", :null => false
end
# now get the data back
country = "GB" if country == "UK"
end
- return country
+ country
rescue StandardError
- return nil
+ nil
end
def self.ip_location(ip_address)
break if key == ""
arr[key] = getvalue(s)
end
- s.getbyte # skip the 9 'end of object' value
+ s.getbyte # skip the 9 'end of object' value
arr
end
# The Potlatch class is a helper for Potlatch
class Potlatch
# ----- getpresets
- # in: none
- # does: reads tag preset menus, colours, and autocomplete config files
- # out: [0] presets, [1] presetmenus, [2] presetnames,
- # [3] colours, [4] casing, [5] areas, [6] autotags
- # (all hashes)
+ # in: none
+ # does: reads tag preset menus, colours, and autocomplete config files
+ # out: [0] presets, [1] presetmenus, [2] presetnames,
+ # [3] colours, [4] casing, [5] areas, [6] autotags
+ # (all hashes)
def self.get_presets
Rails.logger.info(" Message: getpresets")
presetnames = { "point" => {}, "way" => {}, "POI" => {} }
presettype = ""
presetcategory = ""
- # StringIO.open(txt) do |file|
+ # StringIO.open(txt) do |file|
File.open(Rails.root.join("config", "potlatch", "presets.txt")) do |file|
file.each_line do |line|
t = line.chomp
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
-APP_PATH = File.expand_path("../../config/application", __FILE__)
-require File.expand_path("../../config/boot", __FILE__)
+APP_PATH = File.expand_path("../config/application", __dir__)
+require File.expand_path("../config/boot", __dir__)
require "rails/commands"
Coveralls.wear!("rails")
ENV["RAILS_ENV"] = "test"
-require File.expand_path("../../config/environment", __FILE__)
+require File.expand_path("../config/environment", __dir__)
require "rails/test_help"
require "webmock/minitest"