overpass-api-ruby 0.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +10 -0
- data/CHANGELOG.md +5 -1
- data/Gemfile +2 -2
- data/Gemfile.lock +5 -5
- data/Rakefile +2 -3
- data/lib/base.rb +12 -11
- data/lib/overpass_api_ruby.rb +3 -3
- data/lib/ql.rb +7 -7
- data/lib/version.rb +1 -1
- data/lib/xml.rb +9 -7
- data/overpass-api-ruby.gemspec +16 -16
- data/spec/integration/ql_spec.rb +5 -5
- data/spec/integration/xml_spec.rb +8 -8
- data/spec/spec_helper.rb +18 -18
- data/spec/unit/base_spec.rb +40 -27
- data/spec/unit/ql_spec.rb +10 -9
- data/spec/unit/xml_spec.rb +12 -10
- metadata +20 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7910a44e761b01b5428eb92a87e3ca58b8f4d4c0
|
4
|
+
data.tar.gz: 6862082f918ae6d6d72e2b156cc533bca315f7cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56837255ad68022940a7c8a05758525bd8e33368775ca3c16702ff05cd788180eb2371ca5bf2ea12f730d9a952ef7a88c746346116b3f5b88cbb730f6484ba01
|
7
|
+
data.tar.gz: cda0d9a6453673694b7e8a203cd658e2f512680b8b5964e0babeb1278c7c8f7fccb1c4180a92c4f8527617e024cca242215608af3f46928440a4dcd6aeb9ca07
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
=========
|
3
|
+
v 0.3.1
|
4
|
+
-------
|
5
|
+
- Clean up / refactor per rubocop suggestions
|
6
|
+
|
3
7
|
v 0.3
|
4
8
|
-----
|
5
9
|
- Use POST instead of GET.
|
6
|
-
- Update
|
10
|
+
- Update rack to version 2.0.6 because of a GitHub vulnerability alert.
|
7
11
|
|
8
12
|
v 0.2.3
|
9
13
|
--------
|
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org/'
|
2
2
|
|
3
|
-
gemspec
|
3
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
overpass-api-ruby (0.
|
4
|
+
overpass-api-ruby (0.3)
|
5
5
|
httpi (~> 2.4.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -41,9 +41,9 @@ PLATFORMS
|
|
41
41
|
DEPENDENCIES
|
42
42
|
bundler (~> 1.3)
|
43
43
|
overpass-api-ruby!
|
44
|
-
pry
|
45
|
-
rake
|
46
|
-
rspec (
|
44
|
+
pry (~> 0.10)
|
45
|
+
rake (~> 12.0)
|
46
|
+
rspec (~> 3.6)
|
47
47
|
|
48
48
|
BUNDLED WITH
|
49
|
-
1.
|
49
|
+
1.17.2
|
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
1
|
require 'bundler/gem_tasks'
|
3
2
|
|
4
3
|
require 'rake'
|
@@ -6,8 +5,8 @@ require 'rspec/core/rake_task'
|
|
6
5
|
|
7
6
|
desc 'Run all tests'
|
8
7
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
9
|
-
t.pattern =
|
10
|
-
t.rspec_opts = %w
|
8
|
+
t.pattern = 'spec/**/*_spec.rb'
|
9
|
+
t.rspec_opts = %w[--color --warnings]
|
11
10
|
end
|
12
11
|
|
13
12
|
task default: [:spec]
|
data/lib/base.rb
CHANGED
@@ -2,33 +2,34 @@ require 'httpi'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
module OverpassAPI
|
5
|
+
# base class, ql and xml extend this
|
5
6
|
class Base
|
6
|
-
DEFAULT_ENDPOINT='http://overpass-api.de/api/interpreter'
|
7
|
+
DEFAULT_ENDPOINT = 'http://overpass-api.de/api/interpreter'.freeze
|
7
8
|
|
8
|
-
def initialize(args={})
|
9
|
+
def initialize(args = {})
|
9
10
|
bbox = args[:bbox]
|
10
|
-
bounding_box(bbox[:s],bbox[:n],bbox[:w],bbox[:e]) if bbox
|
11
|
+
bounding_box(bbox[:s], bbox[:n], bbox[:w], bbox[:e]) if bbox
|
11
12
|
|
12
13
|
@endpoint = args[:endpoint] || DEFAULT_ENDPOINT
|
13
14
|
@timeout = args[:timeout]
|
14
15
|
end
|
15
16
|
|
16
|
-
def bounding_box(
|
17
|
-
@bbox = "#{
|
17
|
+
def bounding_box(south, north, west, east)
|
18
|
+
@bbox = "#{south},#{west},#{north},#{east}"
|
18
19
|
end
|
19
20
|
|
20
|
-
def query(
|
21
|
-
perform build_query(
|
21
|
+
def query(query)
|
22
|
+
perform build_query(query)
|
22
23
|
end
|
23
24
|
|
24
|
-
def raw_query(
|
25
|
-
perform
|
25
|
+
def raw_query(query)
|
26
|
+
perform query
|
26
27
|
end
|
27
28
|
|
28
29
|
private
|
29
30
|
|
30
|
-
def perform(
|
31
|
-
r = HTTPI::Request.new(url: @endpoint, body:
|
31
|
+
def perform(query)
|
32
|
+
r = HTTPI::Request.new(url: @endpoint, body: query)
|
32
33
|
JSON.parse(HTTPI.post(r).body, symbolize_names: true)
|
33
34
|
end
|
34
35
|
end
|
data/lib/overpass_api_ruby.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
require_relative
|
1
|
+
require_relative 'version'
|
2
|
+
require_relative 'xml'
|
3
|
+
require_relative 'ql'
|
data/lib/ql.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative 'base'
|
2
2
|
|
3
3
|
module OverpassAPI
|
4
|
+
# builds queries in overpass ql format
|
4
5
|
class QL < Base
|
5
|
-
def initialize(args={})
|
6
|
+
def initialize(args = {})
|
6
7
|
super
|
7
|
-
|
8
8
|
@maxsize = args[:maxsize]
|
9
9
|
end
|
10
10
|
|
11
|
-
def build_query(
|
12
|
-
header =
|
11
|
+
def build_query(query)
|
12
|
+
header = ''
|
13
13
|
header << "[bbox:#{@bbox}]" if @bbox
|
14
14
|
header << "[timeout:#{@timeout}]" if @timeout
|
15
15
|
header << "[maxsize:#{@maxsize}]" if @maxsize
|
16
16
|
|
17
|
-
header <<
|
17
|
+
header << '[out:json]'
|
18
18
|
|
19
|
-
"#{header};#{
|
19
|
+
"#{header};#{query}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/version.rb
CHANGED
data/lib/xml.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
require_relative 'base'
|
2
2
|
|
3
3
|
module OverpassAPI
|
4
|
+
# builds queries in xml format
|
4
5
|
class XML < Base
|
5
|
-
def initialize(args={})
|
6
|
+
def initialize(args = {})
|
6
7
|
super
|
7
|
-
|
8
8
|
@element_limit = args[:element_limit]
|
9
9
|
end
|
10
10
|
|
11
|
-
def build_query(
|
12
|
-
bbox = @bbox ? "bbox='#{@bbox}'" : ''
|
13
|
-
timeout = @timeout ? "timeout='#{@timeout}'" : ''
|
14
|
-
element_limit = @element_limit ? "element-limit='#{@element_limit}'" : ''
|
15
|
-
|
11
|
+
def build_query(query)
|
12
|
+
bbox = @bbox ? " bbox='#{@bbox}'" : ''
|
13
|
+
timeout = @timeout ? " timeout='#{@timeout}'" : ''
|
14
|
+
element_limit = @element_limit ? " element-limit='#{@element_limit}'" : ''
|
15
|
+
|
16
|
+
"<osm-script#{bbox}#{timeout}#{element_limit} output='json'>" \
|
17
|
+
"#{query}<print/></osm-script>"
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/overpass-api-ruby.gemspec
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'overpass-api-ruby'
|
8
7
|
spec.version = OverpassAPI::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.description =
|
12
|
-
spec.summary =
|
13
|
-
|
14
|
-
spec.
|
8
|
+
spec.authors = ['Bruno Salerno']
|
9
|
+
spec.email = ['br.salerno@gmail.com']
|
10
|
+
spec.description = 'A Ruby wrapper for OpenStreetMap Overpass API'
|
11
|
+
spec.summary = 'This gem will allow you to perform queries to'\
|
12
|
+
'OSM Overpass API using QL or XML'
|
13
|
+
spec.homepage = 'https://github.com/BrunoSalerno/overpass-api-ruby'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
16
|
+
spec.files = `git ls-files`.split($RS)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_runtime_dependency
|
21
|
+
spec.add_runtime_dependency 'httpi', '~> 2.4'
|
22
22
|
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
25
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.6'
|
27
27
|
end
|
data/spec/integration/ql_spec.rb
CHANGED
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
require 'overpass_api_ruby'
|
3
3
|
|
4
4
|
describe OverpassAPI::QL do
|
5
|
-
it
|
6
|
-
options={:
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
it 'should return the right elements' do
|
6
|
+
options = { bbox: { s: -34.705448, n: -34.526562,
|
7
|
+
w: -58.531471, e: -58.335159 },
|
8
|
+
timeout: 900,
|
9
|
+
maxsize: 10_000 }
|
10
10
|
|
11
11
|
overpass = OverpassAPI::QL.new(options)
|
12
12
|
|
@@ -2,17 +2,17 @@ require 'spec_helper'
|
|
2
2
|
require 'overpass_api_ruby'
|
3
3
|
|
4
4
|
describe OverpassAPI::XML do
|
5
|
-
it
|
6
|
-
options={:
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
it 'should return the requested elements' do
|
6
|
+
options = { bbox: { s: -34.705448, n: -34.526562,
|
7
|
+
w: -58.531471, e: -58.335159 },
|
8
|
+
timeout: 900,
|
9
|
+
element_limit: 100_000 }
|
10
10
|
|
11
11
|
overpass = OverpassAPI::XML.new(options)
|
12
12
|
|
13
|
-
ba_query = "<union><query type='relation'
|
14
|
-
|
15
|
-
|
13
|
+
ba_query = "<union><query type='relation'>" \
|
14
|
+
"<has-kv k='route' v='subway'/></query>" \
|
15
|
+
"</union><union><item/><recurse type='down'/></union>"
|
16
16
|
|
17
17
|
expect(overpass.query(ba_query)[:elements]).to be_a(Array)
|
18
18
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
# users commonly want.
|
17
17
|
#
|
18
18
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
|
19
20
|
RSpec.configure do |config|
|
20
21
|
# rspec-expectations config goes here. You can use an alternate
|
21
22
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
@@ -40,57 +41,56 @@ RSpec.configure do |config|
|
|
40
41
|
mocks.verify_partial_doubles = false
|
41
42
|
end
|
42
43
|
|
43
|
-
# The settings below are suggested to provide a good initial experience
|
44
|
-
# with RSpec, but feel free to customize to your heart's content.
|
45
|
-
|
44
|
+
# The settings below are suggested to provide a good initial experience
|
45
|
+
# with RSpec, but feel free to customize to your heart's content.
|
46
|
+
|
46
47
|
# These two settings work together to allow you to limit a spec run
|
47
48
|
# to individual examples or groups you care about by tagging them with
|
48
49
|
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
49
50
|
# get run.
|
50
|
-
config.filter_run :focus
|
51
|
-
config.run_all_when_everything_filtered = true
|
51
|
+
# config.filter_run :focus
|
52
|
+
# config.run_all_when_everything_filtered = true
|
52
53
|
|
53
54
|
# Allows RSpec to persist some state between runs in order to support
|
54
55
|
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
55
56
|
# you configure your source control system to ignore this file.
|
56
|
-
config.example_status_persistence_file_path = "spec/examples.txt"
|
57
|
+
# config.example_status_persistence_file_path = "spec/examples.txt"
|
57
58
|
|
58
59
|
# Limits the available syntax to the non-monkey patched syntax that is
|
59
60
|
# recommended. For more details, see:
|
60
61
|
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
61
62
|
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
62
63
|
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
63
|
-
config.disable_monkey_patching!
|
64
|
+
# config.disable_monkey_patching!
|
64
65
|
|
65
66
|
# This setting enables warnings. It's recommended, but in some cases may
|
66
67
|
# be too noisy due to issues in dependencies.
|
67
|
-
config.warnings = true
|
68
|
+
# config.warnings = true
|
68
69
|
|
69
70
|
# Many RSpec users commonly either run the entire suite or an individual
|
70
71
|
# file, and it's useful to allow more verbose output when running an
|
71
72
|
# individual spec file.
|
72
|
-
if config.files_to_run.one?
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
73
|
+
# if config.files_to_run.one?
|
74
|
+
# Use the documentation formatter for detailed output,
|
75
|
+
# unless a formatter has already been configured
|
76
|
+
# (e.g. via a command-line flag).
|
77
|
+
# config.default_formatter = 'doc'
|
78
|
+
# end
|
78
79
|
|
79
80
|
# Print the 10 slowest examples and example groups at the
|
80
81
|
# end of the spec run, to help surface which specs are running
|
81
82
|
# particularly slow.
|
82
|
-
config.profile_examples = 10
|
83
|
+
# config.profile_examples = 10
|
83
84
|
|
84
85
|
# Run specs in random order to surface order dependencies. If you find an
|
85
86
|
# order dependency and want to debug it, you can fix the order by providing
|
86
87
|
# the seed, which is printed after each run.
|
87
88
|
# --seed 1234
|
88
|
-
config.order = :random
|
89
|
+
# config.order = :random
|
89
90
|
|
90
91
|
# Seed global randomization in this process using the `--seed` CLI option.
|
91
92
|
# Setting this allows you to use `--seed` to deterministically reproduce
|
92
93
|
# test failures related to randomization by passing the same `--seed` value
|
93
94
|
# as the one that triggered the failure.
|
94
|
-
Kernel.srand config.seed
|
95
|
-
=end
|
95
|
+
# Kernel.srand config.seed
|
96
96
|
end
|
data/spec/unit/base_spec.rb
CHANGED
@@ -2,38 +2,41 @@ require 'spec_helper'
|
|
2
2
|
require 'overpass_api_ruby'
|
3
3
|
require 'httpi'
|
4
4
|
|
5
|
+
# rubocop:disable Metrics/BlockLength
|
5
6
|
describe OverpassAPI::Base do
|
6
|
-
it
|
7
|
-
expect(OverpassAPI::Base::DEFAULT_ENDPOINT).to eq
|
7
|
+
it 'should return the default endpoint' do
|
8
|
+
expect(OverpassAPI::Base::DEFAULT_ENDPOINT).to eq 'http://overpass-api.de/api/interpreter'
|
8
9
|
base = OverpassAPI::Base.new
|
9
|
-
expect(
|
10
|
+
expect(
|
11
|
+
base.instance_variable_get('@endpoint')
|
12
|
+
).to eq OverpassAPI::Base::DEFAULT_ENDPOINT
|
10
13
|
end
|
11
14
|
|
12
|
-
it
|
13
|
-
opts = {bbox: {s: 1, n: 2, w: 3, e: 4},
|
14
|
-
|
15
|
-
|
15
|
+
it 'should set the right args' do
|
16
|
+
opts = { bbox: { s: 1, n: 2, w: 3, e: 4 },
|
17
|
+
endpoint: 'a.endpoint.com',
|
18
|
+
timeout: 1000 }
|
16
19
|
|
17
20
|
base = OverpassAPI::Base.new(opts)
|
18
21
|
|
19
|
-
expect(base.instance_variable_get(
|
20
|
-
expect(base.instance_variable_get(
|
21
|
-
expect(base.instance_variable_get(
|
22
|
+
expect(base.instance_variable_get('@bbox')).to eq '1,3,2,4'
|
23
|
+
expect(base.instance_variable_get('@endpoint')).to eq 'a.endpoint.com'
|
24
|
+
expect(base.instance_variable_get('@timeout')).to eq 1000
|
22
25
|
end
|
23
26
|
|
24
|
-
it
|
27
|
+
it 'should set the bounding box' do
|
25
28
|
base = OverpassAPI::Base.new
|
26
|
-
base.bounding_box(10,20,30,40)
|
29
|
+
base.bounding_box(10, 20, 30, 40)
|
27
30
|
|
28
|
-
expect(base.instance_variable_get(
|
31
|
+
expect(base.instance_variable_get('@bbox')).to eq '10,30,20,40'
|
29
32
|
end
|
30
33
|
|
31
|
-
it
|
34
|
+
it 'should try to perform the query' do
|
32
35
|
base = OverpassAPI::Base.new
|
33
36
|
|
34
|
-
query =
|
35
|
-
built_query =
|
36
|
-
expected_response =
|
37
|
+
query = 'a query'
|
38
|
+
built_query = 'built_query'
|
39
|
+
expected_response = 'a response'
|
37
40
|
|
38
41
|
allow(base).to receive(:perform).and_return(expected_response)
|
39
42
|
allow(base).to receive(:build_query).and_return(built_query)
|
@@ -46,11 +49,11 @@ describe OverpassAPI::Base do
|
|
46
49
|
expect(response).to eq expected_response
|
47
50
|
end
|
48
51
|
|
49
|
-
it
|
52
|
+
it 'should try to perform a raw query' do
|
50
53
|
base = OverpassAPI::Base.new
|
51
54
|
|
52
|
-
query =
|
53
|
-
expected_response =
|
55
|
+
query = 'as query'
|
56
|
+
expected_response = 'a response'
|
54
57
|
|
55
58
|
allow(base).to receive(:perform).and_return(expected_response)
|
56
59
|
expect(base).to receive(:perform).with(query)
|
@@ -60,20 +63,30 @@ describe OverpassAPI::Base do
|
|
60
63
|
expect(response).to eq expected_response
|
61
64
|
end
|
62
65
|
|
63
|
-
it
|
66
|
+
it 'should try to perform an http request' do
|
64
67
|
base = OverpassAPI::Base.new
|
65
68
|
|
66
|
-
query =
|
67
|
-
request =
|
68
|
-
body = { key:
|
69
|
+
query = 'a query'
|
70
|
+
request = 'a request'
|
71
|
+
body = { key: 'value' }
|
69
72
|
|
70
73
|
allow(HTTPI::Request).to receive(:new).and_return(request)
|
71
|
-
expect(
|
72
|
-
|
73
|
-
|
74
|
+
expect(
|
75
|
+
HTTPI::Request
|
76
|
+
).to receive(:new).with(
|
77
|
+
url: OverpassAPI::Base::DEFAULT_ENDPOINT,
|
78
|
+
body: query
|
79
|
+
)
|
80
|
+
|
81
|
+
allow(
|
82
|
+
HTTPI
|
83
|
+
).to receive(:post).and_return(
|
84
|
+
OpenStruct.new(body: body.to_json)
|
85
|
+
)
|
74
86
|
expect(HTTPI).to receive(:post).with(request)
|
75
87
|
|
76
88
|
response = base.raw_query(query)
|
77
89
|
expect(response).to eq body
|
78
90
|
end
|
79
91
|
end
|
92
|
+
# rubocop:enable Metrics/BlockLength
|
data/spec/unit/ql_spec.rb
CHANGED
@@ -2,22 +2,23 @@ require 'spec_helper'
|
|
2
2
|
require 'overpass_api_ruby'
|
3
3
|
|
4
4
|
describe OverpassAPI::QL do
|
5
|
-
it
|
5
|
+
it 'should return the right built query when no opts are passed' do
|
6
6
|
overpass = OverpassAPI::QL.new
|
7
|
-
built_query = overpass.build_query(
|
7
|
+
built_query = overpass.build_query('a query')
|
8
8
|
|
9
|
-
expect(built_query).to eq
|
9
|
+
expect(built_query).to eq '[out:json];a query'
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
13
|
-
opts = {bbox: {s: 1, n: 2, w: 3, e: 4},
|
14
|
-
|
15
|
-
|
12
|
+
it 'should set the right opts' do
|
13
|
+
opts = { bbox: { s: 1, n: 2, w: 3, e: 4 },
|
14
|
+
timeout: 1000,
|
15
|
+
maxsize: 333 }
|
16
16
|
|
17
17
|
overpass = OverpassAPI::QL.new(opts)
|
18
|
-
built_query = overpass.build_query(
|
18
|
+
built_query = overpass.build_query('a query')
|
19
19
|
|
20
|
-
expected_built_query =
|
20
|
+
expected_built_query = '[bbox:1,3,2,4][timeout:1000]' \
|
21
|
+
'[maxsize:333][out:json];a query'
|
21
22
|
expect(built_query).to eq expected_built_query
|
22
23
|
end
|
23
24
|
end
|
data/spec/unit/xml_spec.rb
CHANGED
@@ -2,23 +2,25 @@ require 'spec_helper'
|
|
2
2
|
require 'overpass_api_ruby'
|
3
3
|
|
4
4
|
describe OverpassAPI::XML do
|
5
|
-
it
|
5
|
+
it 'should return the right built query when no opts are passed' do
|
6
6
|
overpass = OverpassAPI::XML.new
|
7
|
-
built_query = overpass.build_query(
|
7
|
+
built_query = overpass.build_query('a query')
|
8
8
|
|
9
|
-
expect(built_query).to eq "<osm-script
|
9
|
+
expect(built_query).to eq "<osm-script output='json'>a query" \
|
10
|
+
'<print/></osm-script>'
|
10
11
|
end
|
11
12
|
|
12
|
-
it
|
13
|
-
opts = {bbox: {s: 1, n: 2, w: 3, e: 4},
|
14
|
-
|
15
|
-
|
13
|
+
it 'should set the right opts' do
|
14
|
+
opts = { bbox: { s: 1, n: 2, w: 3, e: 4 },
|
15
|
+
timeout: 1000,
|
16
|
+
element_limit: 333 }
|
16
17
|
|
17
18
|
overpass = OverpassAPI::XML.new(opts)
|
18
|
-
built_query = overpass.build_query(
|
19
|
+
built_query = overpass.build_query('a query')
|
19
20
|
|
20
|
-
expected_built_query = "<osm-script bbox='1,3,2,4' timeout='1000'
|
21
|
-
"
|
21
|
+
expected_built_query = "<osm-script bbox='1,3,2,4' timeout='1000' " \
|
22
|
+
"element-limit='333' output='json'>" \
|
23
|
+
'a query<print/></osm-script>'
|
22
24
|
expect(built_query).to eq expected_built_query
|
23
25
|
end
|
24
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: overpass-api-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Salerno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpi
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.4
|
19
|
+
version: '2.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.4
|
26
|
+
version: '2.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,47 +39,47 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '0.10'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '0.10'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '12.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '12.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3'
|
75
|
+
version: '3.6'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3'
|
82
|
+
version: '3.6'
|
83
83
|
description: A Ruby wrapper for OpenStreetMap Overpass API
|
84
84
|
email:
|
85
85
|
- br.salerno@gmail.com
|
@@ -87,6 +87,7 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
+
- ".circleci/config.yml"
|
90
91
|
- ".gitignore"
|
91
92
|
- ".rspec"
|
92
93
|
- CHANGELOG.md
|
@@ -130,7 +131,7 @@ rubyforge_project:
|
|
130
131
|
rubygems_version: 2.5.1
|
131
132
|
signing_key:
|
132
133
|
specification_version: 4
|
133
|
-
summary: This gem will allow you to perform queries
|
134
|
+
summary: This gem will allow you to perform queries toOSM Overpass API using QL or
|
134
135
|
XML
|
135
136
|
test_files:
|
136
137
|
- spec/integration/ql_spec.rb
|