SystemTimer was only needed on ruby 1.8, and we dropped support for
that a long time ago.
# Offense count: 25
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
# Offense count: 25
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
# Offense count: 68
# Configuration parameters: IgnoredMethods.
# Offense count: 68
# Configuration parameters: IgnoredMethods.
gem "htmlentities"
gem "sanitize"
gem "htmlentities"
gem "sanitize"
-# Load SystemTimer for implementing request timeouts
-gem "SystemTimer", ">= 1.1.3", :require => "system_timer", :platforms => :ruby_18
-
# Load faraday for mockable HTTP client
gem "faraday"
# Load faraday for mockable HTTP client
gem "faraday"
GEM
remote: https://rubygems.org/
specs:
GEM
remote: https://rubygems.org/
specs:
aasm (5.1.1)
concurrent-ruby (~> 1.0)
actioncable (6.0.3.4)
aasm (5.1.1)
concurrent-ruby (~> 1.0)
actioncable (6.0.3.4)
aasm
actionpack-page_caching (>= 1.2.0)
active_record_union
aasm
actionpack-page_caching (>= 1.2.0)
active_record_union
module Api
class AmfController < ApiController
module Api
class AmfController < ApiController
include Potlatch
before_action :check_api_writable
include Potlatch
before_action :check_api_writable
def amf_handle_error_with_timeout(call, rootobj, rootid, &block)
amf_handle_error(call, rootobj, rootid) do
def amf_handle_error_with_timeout(call, rootobj, rootid, &block)
amf_handle_error(call, rootobj, rootid) do
- OSM::Timer.timeout(Settings.api_timeout, OSM::APITimeoutError, &block)
+ Timeout.timeout(Settings.api_timeout, OSM::APITimeoutError, &block)
class ApplicationController < ActionController::Base
class ApplicationController < ActionController::Base
include SessionPersistence
protect_from_forgery :with => :exception
include SessionPersistence
protect_from_forgery :with => :exception
##
# wrap an api call in a timeout
def api_call_timeout(&block)
##
# wrap an api call in a timeout
def api_call_timeout(&block)
- OSM::Timer.timeout(Settings.api_timeout, Timeout::Error, &block)
+ Timeout.timeout(Settings.api_timeout, Timeout::Error, &block)
rescue Timeout::Error
raise OSM::APITimeoutError
end
rescue Timeout::Error
raise OSM::APITimeoutError
end
##
# wrap a web page in a timeout
def web_timeout(&block)
##
# wrap a web page in a timeout
def web_timeout(&block)
- OSM::Timer.timeout(Settings.web_timeout, Timeout::Error, &block)
+ Timeout.timeout(Settings.web_timeout, Timeout::Error, &block)
rescue ActionView::Template::Error => e
e = e.cause
rescue ActionView::Template::Error => e
e = e.cause
extend ActionView::Helpers::NumberHelper
def self.describe_location(lat, lon, zoom = nil, language = nil)
extend ActionView::Helpers::NumberHelper
def self.describe_location(lat, lon, zoom = nil, language = nil)
url = "https://nominatim.openstreetmap.org/reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{language}"
begin
url = "https://nominatim.openstreetmap.org/reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{language}"
begin
- response = OSM::Timer.timeout(4) do
+ response = Timeout.timeout(4) do
REXML::Document.new(Net::HTTP.get(URI.parse(url)))
end
rescue StandardError
REXML::Document.new(Net::HTTP.get(URI.parse(url)))
end
rescue StandardError
require "rexml/text"
require "xml/libxml"
require "rexml/text"
require "xml/libxml"
- if defined?(SystemTimer)
- Timer = SystemTimer
- else
- require "timeout"
- Timer = Timeout
- end
-
# The base class for API Errors.
class APIError < RuntimeError
def initialize(message = "Generic API Error")
# The base class for API Errors.
class APIError < RuntimeError
def initialize(message = "Generic API Error")