# Offense count: 25
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
- Max: 643
+ Max: 644
# Offense count: 68
# Configuration parameters: IgnoredMethods.
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"
GEM
remote: https://rubygems.org/
specs:
- SystemTimer (1.2.3)
aasm (5.1.1)
concurrent-ruby (~> 1.0)
actioncable (6.0.3.4)
ruby
DEPENDENCIES
- SystemTimer (>= 1.1.3)
aasm
actionpack-page_caching (>= 1.2.0)
active_record_union
module Api
class AmfController < ApiController
+ require "timeout"
+
include Potlatch
before_action :check_api_writable
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)
end
end
class ApplicationController < ActionController::Base
+ require "timeout"
+
include SessionPersistence
protect_from_forgery :with => :exception
##
# 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
##
# 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
module Nominatim
+ require "timeout"
+
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
- response = OSM::Timer.timeout(4) do
+ response = Timeout.timeout(4) do
REXML::Document.new(Net::HTTP.get(URI.parse(url)))
end
rescue StandardError
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")