cartocss_helper 5.0.0 → 5.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abeb68cede68758d9f0c8ef8ef4b85c192190d20
4
- data.tar.gz: 9c6d087f808d57a21aa8330babedf98cbfce032a
3
+ metadata.gz: 687e90505435113721d6c181afce5feb18be9813
4
+ data.tar.gz: 127cf1604bb20100d21dde261ca687cad19a8300
5
5
  SHA512:
6
- metadata.gz: ba4dcae451a8fa7d2ceff112a7c309a1cff302fc31bf38aa3323d79d62e13696d86be19a8f52f24af13ecc312a7fbf9d6bc908bd6af48e43bcb957439ebf5c30
7
- data.tar.gz: 74a622f7cb5c73a6a95ff89f1c12ec02f86acbb14e83b057217e665cf020768ef4e266d5155a708f7786ba37ab64de228b3ab4f32ae2dfc93996cfb25a7c87a6
6
+ metadata.gz: b6d068d926cf96ac6047044bd34631edc40d259980f10c08bf1fc111b3336bdf94e278ac69731d1878ef637effae7131ab48408d23a48b696b6b63c3293dd5f9
7
+ data.tar.gz: c35e933f2ab3484797d2a7ce1f4617af3cb71134c984cb1189b1a5950afc56019c2bdd46373915feee974d08058fa6a12f800acefaca0ab64a4720ddbbf63508
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'open3'
3
4
 
4
5
  module CartoCSSHelper
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'fileutils'
3
4
  require 'find'
4
5
 
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require_relative 'configuration'
3
4
  require_relative 'util/systemhelper.rb'
4
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'configuration.rb'
2
4
  require_relative 'util/systemhelper.rb'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CartoCSSHelper
2
4
  module Heuristic
3
5
  require 'set'
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require_relative 'configuration.rb'
3
4
  require_relative 'heuristic.rb'
4
5
  require_relative 'data_file_handling.rb'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'util/generic_cached_downloader.rb'
2
4
 
3
5
  module CartoCSSHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'util/generic_downloader.rb'
2
4
  require_relative 'util/generic_cached_downloader.rb'
3
5
  require 'uri' # for URI.escape
@@ -41,6 +43,8 @@ module CartoCSSHelper
41
43
  puts url
42
44
  puts
43
45
  puts e
46
+ elsif e.http_code == 414
47
+ puts 'see https://github.com/matkoniecz/CartoCSSHelper/issues/35'
44
48
  end
45
49
  raise e
46
50
  end
@@ -54,8 +58,13 @@ module CartoCSSHelper
54
58
  query = query.gsub('\\', '\\\\')
55
59
  query = query.delete("\n")
56
60
  query = query.delete("\t")
61
+ query = URI.escape(query)
62
+ query = query.gsub("&", "%26")
63
+ if query.length > 8174 #8175 is too much and allows crashes
64
+ raise 'see https://github.com/matkoniecz/CartoCSSHelper/issues/35'
65
+ end
57
66
  base_overpass_url = OverpassDownloader.get_overpass_instance_url
58
- return base_overpass_url + '/interpreter?data=' + URI.escape(query)
67
+ return base_overpass_url + '/interpreter?data=' + query
59
68
  end
60
69
 
61
70
  def self.get_overpass_instance_url
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'digest/sha1'
3
4
  require 'sys/filesystem'
4
5
  require_relative 'overpass_downloader.rb'
@@ -134,7 +135,11 @@ module CartoCSSHelper
134
135
  return get_query_to_get_location_set_format(tags, type, latitude, longitude, range, "[out:csv(::lat,::lon;false)]")
135
136
  end
136
137
 
138
+ # TODO: better, more generic function name
139
+ # get_query_to_get_objects_matching?
140
+ # put latitude, longitude, range together to avoid passing dummy variables
137
141
  def self.get_query_to_get_location_set_format(tags, type, latitude, longitude, range, format)
142
+ # special support for range == :infinity
138
143
  # special support for some tag values - see CartoCSSHelper::OverpassQueryGenerator.turn_list_of_tags_in_overpass_filter for details
139
144
  locator = "[timeout:#{OverpassDownloader.get_allowed_timeout_in_seconds}]#{format};"
140
145
  locator += "\n"
@@ -167,21 +172,21 @@ module CartoCSSHelper
167
172
  end
168
173
 
169
174
  def self.translate_tag_object_into_filter_data(tag)
170
- operator = :equal
171
- key = tag[0]
172
- value = :any_value
173
- if tag[1].class == Hash
174
- # complex operation
175
- if tag[1][:operation] == :not_equal_to
176
- operator = :not_equal
177
- else
178
- raise "unexpected operation in #{tag[1]}"
179
- end
180
- value = tag[1][:value]
181
- else
182
- value = tag[1]
183
- end
184
- return {operator: operator, key: key, value: value}
175
+ operator = :equal
176
+ key = tag[0]
177
+ value = :any_value
178
+ if tag[1].class == Hash
179
+ # complex operation
180
+ if tag[1][:operation] == :not_equal_to
181
+ operator = :not_equal
182
+ else
183
+ raise "unexpected operation in #{tag[1]}"
184
+ end
185
+ value = tag[1][:value]
186
+ else
187
+ value = tag[1]
188
+ end
189
+ return { operator: operator, key: key, value: value }
185
190
  end
186
191
 
187
192
  def self.overpass_escape(text)
@@ -190,17 +195,21 @@ module CartoCSSHelper
190
195
 
191
196
  def self.turn_tag_into_overpass_filter(tag)
192
197
  filter_data = translate_tag_object_into_filter_data(tag)
193
- value = overpass_escape(filter_data[:value])
194
- key = overpass_escape(filter_data[:key])
198
+ value = filter_data[:value]
199
+ key = filter_data[:key]
195
200
  operator = filter_data[:operator]
201
+
202
+ value = overpass_escape(value) if value != :any_value
203
+ key = overpass_escape(key)
204
+
196
205
  if value == :any_value && operator == :equal
197
- return "\t['#{key}']"
206
+ return "\t['#{key}']"
198
207
  elsif value == :any_value && operator == :not_equal
199
- return "\t['#{key}'!~'.*']"
208
+ return "\t['#{key}'!~'.*']"
200
209
  elsif value != :any_value && operator == :equal
201
- return "\t['#{key}'='#{value}']"
210
+ return "\t['#{key}'='#{value}']"
202
211
  elsif value != :any_value && operator == :not_equal
203
- return "\t['#{key}'!='#{value}']"
212
+ return "\t['#{key}'!='#{value}']"
204
213
  else
205
214
  raise "unexpected situation in <#{tag}>"
206
215
  end
@@ -210,14 +219,12 @@ module CartoCSSHelper
210
219
  # special support for some tag values - see CartoCSSHelper::OverpassQueryGenerator.turn_list_of_tags_in_overpass_filter for details
211
220
  # TODO - escape value with quotation signs in them
212
221
  element = "(#{type}"
213
- element += OverpassQueryGenerator.turn_list_of_tags_in_overpass_filter(tags)
214
- element += "\n"
222
+ element += OverpassQueryGenerator.turn_list_of_tags_in_overpass_filter(tags).strip
215
223
  if range != :infinity
216
- element += "\t(around:#{range},#{latitude},#{longitude});"
217
- element += "\n"
224
+ element += "(around:#{range},#{latitude},#{longitude})"
218
225
  end
219
- element += ');'
220
- element += "\n"
226
+ element += ';);'
227
+ element += "\n\n"
221
228
  return element
222
229
  end
223
230
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'util/systemhelper.rb'
2
4
 
3
5
  include SystemHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative('style_specific')
2
4
 
3
5
  module CartoCSSHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CartoCSSHelper
2
4
  class StyleSpecificData
3
5
  attr_reader :min_z, :max_z, :list_of_documented_tags, :list_of_documented_compositions, :name_label_is_not_required
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'configuration.rb'
2
4
  require_relative 'image_generator.rb'
3
5
  include CartoCSSHelper::Configuration
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  module FileHelper
3
4
  def self.make_string_usable_as_filename(string)
4
5
  return string.gsub(/[\x00\/\\:\*\?\"<>\|]/, '_')
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'generic_downloader.rb'
2
4
 
3
5
  class GenericCachedDownloader
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ruby-progressbar'
2
4
  require_relative 'rest-client_wrapper.rb'
3
5
  require_relative 'logger.rb'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
 
3
5
  module Log
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rest-client'
2
4
  require_relative 'generic_downloader.rb'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class FailedCommandException < StandardError
2
4
  end
3
5
 
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require_relative 'heuristic.rb'
3
4
  require_relative 'image_generator.rb'
4
5
  require_relative 'configuration.rb'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rmagick'
2
4
 
3
5
  module CartoCSSHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'visualise_changes_diff_from_images'
2
4
  require_relative 'git'
3
5
  require_relative 'renderer_handler'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CartoCSSHelper
2
4
  def self.get_list_of_testing_locations
3
5
  return [
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.0
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Konieczny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-07 00:00:00.000000000 Z
11
+ date: 2018-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -200,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
200
  requirements:
201
201
  - - ">="
202
202
  - !ruby/object:Gem::Version
203
- version: 2.1.0
203
+ version: 2.3.0
204
204
  required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - ">="
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  version: 1.8.23
209
209
  requirements: []
210
210
  rubyforge_project:
211
- rubygems_version: 2.5.1
211
+ rubygems_version: 2.6.14.1
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: Tool to make development of CartoCSS styles more efficient.