cartocss_helper 5.0.3 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/cartocss_helper.rb +1 -0
- data/lib/cartocss_helper/configuration.rb +6 -0
- data/lib/cartocss_helper/history_downloader.rb +35 -0
- data/lib/cartocss_helper/notes_downloader.rb +0 -4
- data/lib/cartocss_helper/overpass_downloader.rb +27 -4
- data/lib/cartocss_helper/util/rest-client_wrapper.rb +2 -0
- metadata +10 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c4b353be50dfd2f899e2b2917a5f221f6046dcb451ca3a98257b10fb776862fe
|
4
|
+
data.tar.gz: f612f883bdbe64b93b2da32ba76cc2301744d6c5d222f024eb8c78b68c2850c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b4ae1b202698be4c2ad64ca22bf7976f68d7f4cf4d0621a1904978388163ea28e6b1418ca91ccddbd4433160078386a94641bd2d5c8c5c50d76acff78b2d115
|
7
|
+
data.tar.gz: 1338085a9c2ffe1aa86aef7b977bb84bb71865e59095fb581801cdddce44c4f4e016ee0d410004ffc60008c8599c282062d983f35f8c51273c0860ef57025e21
|
data/lib/cartocss_helper.rb
CHANGED
@@ -12,6 +12,7 @@ require_relative 'cartocss_helper/validator.rb'
|
|
12
12
|
require_relative 'cartocss_helper/git.rb'
|
13
13
|
require_relative 'cartocss_helper/util/generic_downloader.rb'
|
14
14
|
require_relative 'cartocss_helper/notes_downloader.rb'
|
15
|
+
require_relative 'cartocss_helper/history_downloader.rb'
|
15
16
|
require_relative 'cartocss_helper/style_specific/default_osm_style.rb'
|
16
17
|
require_relative 'data/testing_locations'
|
17
18
|
|
@@ -103,6 +103,12 @@ module CartoCSSHelper::Configuration
|
|
103
103
|
return location
|
104
104
|
end
|
105
105
|
|
106
|
+
def get_path_to_folder_for_history_api_cache
|
107
|
+
location = File.join(get_path_to_folder_for_cache, 'history-api', '')
|
108
|
+
FileUtils.mkdir_p location
|
109
|
+
return location
|
110
|
+
end
|
111
|
+
|
106
112
|
def get_data_filename
|
107
113
|
return get_path_to_folder_for_branch_specific_cache + 'data.osm'
|
108
114
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'util/generic_cached_downloader.rb'
|
4
|
+
|
5
|
+
module CartoCSSHelper
|
6
|
+
class HistoryDownloader
|
7
|
+
def self.cache_filename(type, id)
|
8
|
+
url = HistoryDownloader.format_query_into_url(type, id)
|
9
|
+
return CartoCSSHelper::Configuration.get_path_to_folder_for_history_api_cache + url.delete("/") + ".cache"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.run_history_query(type, id, invalidate_cache: false)
|
13
|
+
timeout = HistoryDownloader.get_allowed_timeout_in_seconds
|
14
|
+
downloader = GenericCachedDownloader.new(timeout: timeout, stop_on_timeout: false)
|
15
|
+
file = cache_filename(type, id)
|
16
|
+
url = HistoryDownloader.format_query_into_url(type, id)
|
17
|
+
return downloader.get_specified_resource(url, file, invalidate_cache: invalidate_cache)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.cache_timestamp(type, id)
|
21
|
+
downloader = GenericCachedDownloader.new
|
22
|
+
file = cache_filename(type, id)
|
23
|
+
return downloader.get_cache_timestamp(file)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.get_allowed_timeout_in_seconds
|
27
|
+
return 10 * 60
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.format_query_into_url(type, id)
|
31
|
+
# documentated at https://wiki.openstreetmap.org/wiki/API_v0.6
|
32
|
+
return "http://api.openstreetmap.org/api/0.6/#{type}/#{id}/history"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -42,9 +42,5 @@ module CartoCSSHelper
|
|
42
42
|
max_longitude = longitude + size / 2
|
43
43
|
return "#{min_longitude},#{min_latitude},#{max_longitude},#{max_latitude}"
|
44
44
|
end
|
45
|
-
|
46
|
-
def self.get_overpass_instance_url
|
47
|
-
return CartoCSSHelper::Configuration.get_overpass_instance_url
|
48
|
-
end
|
49
45
|
end
|
50
46
|
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
require_relative 'util/generic_downloader.rb'
|
4
4
|
require_relative 'util/generic_cached_downloader.rb'
|
5
|
-
require 'uri' # for URI.escape
|
6
5
|
require 'digest/sha1'
|
6
|
+
require 'addressable/uri'
|
7
7
|
|
8
8
|
module CartoCSSHelper
|
9
9
|
class OverpassDownloader
|
@@ -42,6 +42,9 @@ module CartoCSSHelper
|
|
42
42
|
puts
|
43
43
|
puts url
|
44
44
|
puts
|
45
|
+
puts "url with %20 replaced back by spaces, %22 by \""
|
46
|
+
puts url.replace("%20", " ").replace("%22", '"')
|
47
|
+
puts
|
45
48
|
puts e
|
46
49
|
elsif e.http_code == 414
|
47
50
|
puts 'see https://github.com/matkoniecz/CartoCSSHelper/issues/35'
|
@@ -53,13 +56,33 @@ module CartoCSSHelper
|
|
53
56
|
return 10 * 60
|
54
57
|
end
|
55
58
|
|
56
|
-
def self.
|
57
|
-
|
59
|
+
def self.escape_query(query)
|
60
|
+
# code causing bug - (// inside quotes, as predicted) - why it was even added?
|
61
|
+
#query = query.gsub(/\/\/.*\n/, '') # add proper parsing - it will mutilate // inside quotes etc
|
62
|
+
# TODO: replace complaint above by a test
|
63
|
+
# maybe URI.escape(query, "/") is sufficient?
|
64
|
+
|
65
|
+
# escape backslash - turns \ into \\
|
58
66
|
query = query.gsub('\\', '\\\\')
|
67
|
+
|
68
|
+
# newlines, tabs added in query for readability may be safely deleted
|
59
69
|
query = query.delete("\n")
|
60
70
|
query = query.delete("\t")
|
61
|
-
|
71
|
+
|
72
|
+
#query = URI.escape(query) # no escaping for / [add require 'uri' to use it]
|
73
|
+
#query = URI.escape(query, "/") # escapes only / [add require 'uri' to use it]
|
74
|
+
#query = CGI.escape(query) # escapes spaces to + sign
|
75
|
+
query = Addressable::URI.encode_component(query, Addressable::URI::CharacterClasses::QUERY)
|
76
|
+
query = query.gsub("/", "%2F") # escape slashes manually
|
77
|
+
|
78
|
+
# inside query also & and + must be escaped (entire query is an url parameter)
|
62
79
|
query = query.gsub("&", "%26")
|
80
|
+
query = query.gsub('+', '%2B')
|
81
|
+
return query
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.format_query_into_url(query)
|
85
|
+
query = escape_query(query)
|
63
86
|
if query.length > 8174 #8175 is too much and allows crashes
|
64
87
|
raise 'see https://github.com/matkoniecz/CartoCSSHelper/issues/35'
|
65
88
|
end
|
@@ -19,6 +19,8 @@ class RestClientWrapper
|
|
19
19
|
rescue RestClient::SSLCertificateNotVerified, RestClient::ServerBrokeConnection, SocketError, URI::InvalidURIError
|
20
20
|
raise ExceptionWithoutResponse.new(e), e.to_s
|
21
21
|
rescue ArgumentError => e
|
22
|
+
puts "url:"
|
23
|
+
puts url
|
22
24
|
raise_issue_359_exception(e)
|
23
25
|
rescue => e
|
24
26
|
puts 'unhandled exception! It is a clear bug!'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cartocss_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateusz Konieczny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -93,25 +93,19 @@ dependencies:
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: 3.4.0
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
96
|
+
name: matkoniecz-ruby-style
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- - "
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0.52'
|
102
|
-
- - ">"
|
99
|
+
- - ">="
|
103
100
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0
|
101
|
+
version: '0'
|
105
102
|
type: :development
|
106
103
|
prerelease: false
|
107
104
|
version_requirements: !ruby/object:Gem::Requirement
|
108
105
|
requirements:
|
109
|
-
- - "
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: '0.52'
|
112
|
-
- - ">"
|
106
|
+
- - ">="
|
113
107
|
- !ruby/object:Gem::Version
|
114
|
-
version: 0
|
108
|
+
version: '0'
|
115
109
|
- !ruby/object:Gem::Dependency
|
116
110
|
name: simplecov
|
117
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,20 +134,6 @@ dependencies:
|
|
140
134
|
- - "~>"
|
141
135
|
- !ruby/object:Gem::Version
|
142
136
|
version: '1.8'
|
143
|
-
- !ruby/object:Gem::Dependency
|
144
|
-
name: codeclimate-test-reporter
|
145
|
-
requirement: !ruby/object:Gem::Requirement
|
146
|
-
requirements:
|
147
|
-
- - "~>"
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0.5'
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
requirements:
|
154
|
-
- - "~>"
|
155
|
-
- !ruby/object:Gem::Version
|
156
|
-
version: '0.5'
|
157
137
|
description: Tool to make development of CartoCSS styles more efficient. Automates
|
158
138
|
actions necessary to produce test images and validates style. Loading data using
|
159
139
|
osm2pgsql, rendering with TileMill, obtaining test data from overpass turbo.
|
@@ -168,6 +148,7 @@ files:
|
|
168
148
|
- lib/cartocss_helper/data_file_handling.rb
|
169
149
|
- lib/cartocss_helper/git.rb
|
170
150
|
- lib/cartocss_helper/heuristic.rb
|
151
|
+
- lib/cartocss_helper/history_downloader.rb
|
171
152
|
- lib/cartocss_helper/image_generator.rb
|
172
153
|
- lib/cartocss_helper/notes_downloader.rb
|
173
154
|
- lib/cartocss_helper/overpass_downloader.rb
|
@@ -200,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
181
|
requirements:
|
201
182
|
- - ">="
|
202
183
|
- !ruby/object:Gem::Version
|
203
|
-
version: 2.
|
184
|
+
version: 2.4.0
|
204
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
186
|
requirements:
|
206
187
|
- - ">="
|
@@ -208,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
189
|
version: 1.8.23
|
209
190
|
requirements: []
|
210
191
|
rubyforge_project:
|
211
|
-
rubygems_version: 2.6.
|
192
|
+
rubygems_version: 2.7.6.2
|
212
193
|
signing_key:
|
213
194
|
specification_version: 4
|
214
195
|
summary: Tool to make development of CartoCSS styles more efficient.
|