Class: CartoCSSHelper::HistoryDownloader
- Inherits:
-
Object
- Object
- CartoCSSHelper::HistoryDownloader
- Defined in:
- lib/cartocss_helper/history_downloader.rb
Class Method Summary collapse
- .cache_filename(type, id) ⇒ Object
- .cache_timestamp(type, id) ⇒ Object
- .format_query_into_url(type, id) ⇒ Object
- .get_allowed_timeout_in_seconds ⇒ Object
- .run_history_query(type, id, invalidate_cache: false) ⇒ Object
Class Method Details
.cache_filename(type, id) ⇒ Object
7 8 9 10 |
# File 'lib/cartocss_helper/history_downloader.rb', line 7 def self.cache_filename(type, id) url = HistoryDownloader.format_query_into_url(type, id) return CartoCSSHelper::Configuration.get_path_to_folder_for_history_api_cache + url.delete("/") + ".cache" end |
.cache_timestamp(type, id) ⇒ Object
20 21 22 23 24 |
# File 'lib/cartocss_helper/history_downloader.rb', line 20 def self.(type, id) downloader = GenericCachedDownloader.new file = cache_filename(type, id) return downloader.(file) end |
.format_query_into_url(type, id) ⇒ Object
30 31 32 33 |
# File 'lib/cartocss_helper/history_downloader.rb', line 30 def self.format_query_into_url(type, id) # documentated at https://wiki.openstreetmap.org/wiki/API_v0.6 return "http://api.openstreetmap.org/api/0.6/#{type}/#{id}/history" end |
.get_allowed_timeout_in_seconds ⇒ Object
26 27 28 |
# File 'lib/cartocss_helper/history_downloader.rb', line 26 def self.get_allowed_timeout_in_seconds return 10 * 60 end |
.run_history_query(type, id, invalidate_cache: false) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/cartocss_helper/history_downloader.rb', line 12 def self.run_history_query(type, id, invalidate_cache: false) timeout = HistoryDownloader.get_allowed_timeout_in_seconds downloader = GenericCachedDownloader.new(timeout: timeout, stop_on_timeout: false) file = cache_filename(type, id) url = HistoryDownloader.format_query_into_url(type, id) return downloader.get_specified_resource(url, file, invalidate_cache: invalidate_cache) end |