Browse Source

Don't load dotenv or unused/broken gems.

tags/0.3.1^2
Bèr Kessels 5 months ago
parent
commit
aefecf6184
40 changed files with 17 additions and 1643 deletions
  1. 0
    1
      Gemfile
  2. 0
    12
      Gemfile.lock
  3. 8
    2
      Rakefile
  4. 5
    3
      config/environment.rb
  5. 4
    0
      lib/hours.rb
  6. BIN
      vendor/cache/faraday-0.15.4.gem
  7. BIN
      vendor/cache/multipart-post-2.0.0.gem
  8. 0
    0
      vendor/cache/nominatim-dec16d522405/.bundlecache
  9. 0
    21
      vendor/cache/nominatim-dec16d522405/.gitignore
  10. 0
    2
      vendor/cache/nominatim-dec16d522405/.rspec
  11. 0
    7
      vendor/cache/nominatim-dec16d522405/.travis.yml
  12. 0
    15
      vendor/cache/nominatim-dec16d522405/CHANGELOG.md
  13. 0
    8
      vendor/cache/nominatim-dec16d522405/Gemfile
  14. 0
    13
      vendor/cache/nominatim-dec16d522405/Guardfile
  15. 0
    22
      vendor/cache/nominatim-dec16d522405/LICENSE
  16. 0
    113
      vendor/cache/nominatim-dec16d522405/README.md
  17. 0
    11
      vendor/cache/nominatim-dec16d522405/Rakefile
  18. 0
    36
      vendor/cache/nominatim-dec16d522405/lib/nominatim.rb
  19. 0
    83
      vendor/cache/nominatim-dec16d522405/lib/nominatim/address.rb
  20. 0
    40
      vendor/cache/nominatim-dec16d522405/lib/nominatim/client.rb
  21. 0
    52
      vendor/cache/nominatim-dec16d522405/lib/nominatim/configuration.rb
  22. 0
    93
      vendor/cache/nominatim-dec16d522405/lib/nominatim/place.rb
  23. 0
    30
      vendor/cache/nominatim-dec16d522405/lib/nominatim/point.rb
  24. 0
    13
      vendor/cache/nominatim-dec16d522405/lib/nominatim/polygon.rb
  25. 0
    16
      vendor/cache/nominatim-dec16d522405/lib/nominatim/response/parse_json.rb
  26. 0
    44
      vendor/cache/nominatim-dec16d522405/lib/nominatim/reverse.rb
  27. 0
    117
      vendor/cache/nominatim-dec16d522405/lib/nominatim/search.rb
  28. 0
    3
      vendor/cache/nominatim-dec16d522405/lib/nominatim/version.rb
  29. 0
    51
      vendor/cache/nominatim-dec16d522405/nominatim.gemspec
  30. 0
    1
      vendor/cache/nominatim-dec16d522405/spec/fixtures/reverse.json
  31. 0
    1
      vendor/cache/nominatim-dec16d522405/spec/fixtures/search.json
  32. 0
    209
      vendor/cache/nominatim-dec16d522405/spec/nominatim/address_spec.rb
  33. 0
    23
      vendor/cache/nominatim-dec16d522405/spec/nominatim/client_spec.rb
  34. 0
    172
      vendor/cache/nominatim-dec16d522405/spec/nominatim/place_spec.rb
  35. 0
    53
      vendor/cache/nominatim-dec16d522405/spec/nominatim/point_spec.rb
  36. 0
    19
      vendor/cache/nominatim-dec16d522405/spec/nominatim/polygon_spec.rb
  37. 0
    68
      vendor/cache/nominatim-dec16d522405/spec/nominatim/reverse_spec.rb
  38. 0
    185
      vendor/cache/nominatim-dec16d522405/spec/nominatim/search_spec.rb
  39. 0
    66
      vendor/cache/nominatim-dec16d522405/spec/nominatim_spec.rb
  40. 0
    38
      vendor/cache/nominatim-dec16d522405/spec/spec_helper.rb

+ 0
- 1
Gemfile View File

@@ -12,7 +12,6 @@ gem 'event_sourcery-postgres'
gem 'hashie'
gem 'json_expressions'
gem 'jsonapi-rb'
gem 'nominatim', github: 'lukaszsliwa/nominatim'
gem 'offline_geocoder', path: '../libs/offline_geocoder'
gem 'open-location-code', require: 'plus_code'
gem 'opening_hours_converter', path: '../libs/opening_hours_converter'

+ 0
- 12
Gemfile.lock View File

@@ -1,11 +1,3 @@
GIT
remote: https://github.com/lukaszsliwa/nominatim
revision: dec16d522405cff38f886b8a12199d5b52589774
specs:
nominatim (0.0.6)
faraday
multi_json

PATH
remote: ../libs/offline_geocoder
specs:
@@ -79,8 +71,6 @@ GEM
pg
sequel (>= 4.38)
execjs (2.7.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
ffi (1.11.1)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
@@ -116,7 +106,6 @@ GEM
minitest
nokogiri
multi_json (1.13.1)
multipart-post (2.0.0)
mustermann (1.0.3)
nio4r (2.5.2)
nokogiri (1.8.5)
@@ -247,7 +236,6 @@ DEPENDENCIES
minitest
minitest-have_tag
nokogiri
nominatim!
offline_geocoder!
open-location-code
opening_hours_converter!

+ 8
- 2
Rakefile View File

@@ -2,13 +2,19 @@

$LOAD_PATH.unshift '.'

def production?
ENV['APP_ENV'] == 'production'
end

task :environment do
require 'lib/hours'
end

task :sequel do
require 'dotenv'
Dotenv.load(".env.#{ENV['APP_ENV']}", '.env')
unless production?
require 'dotenv'
Dotenv.load(".env.#{ENV['APP_ENV']}", '.env')
end

require 'sequel'
require 'sequel-postgis-georuby'

+ 5
- 3
config/environment.rb View File

@@ -1,8 +1,10 @@
# frozen_string_literal: true

require 'dotenv'
Dotenv.load(Hours.base_path.join(".env.#{ENV['APP_ENV']}"),
Hours.base_path.join('.env'))
unless Hours.production?
require 'dotenv'
Dotenv.load(Hours.base_path.join(".env.#{ENV['APP_ENV']}"),
Hours.base_path.join('.env'))
end

##
# Setup of database.

+ 4
- 0
lib/hours.rb View File

@@ -43,6 +43,10 @@ module Hours
ENV.fetch('RACK_ENV', ENV['APP_ENV'] || 'development')
end

def self.production?
environment == 'production'
end

def self.event_store
EventSourcery::Postgres.config.event_store
end

BIN
vendor/cache/faraday-0.15.4.gem View File


BIN
vendor/cache/multipart-post-2.0.0.gem View File


+ 0
- 0
vendor/cache/nominatim-dec16d522405/.bundlecache View File


+ 0
- 21
vendor/cache/nominatim-dec16d522405/.gitignore View File

@@ -1,21 +0,0 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
coverage
*.swp
*.swo
*.rvmrc

+ 0
- 2
vendor/cache/nominatim-dec16d522405/.rspec View File

@@ -1,2 +0,0 @@
--color
--format progress

+ 0
- 7
vendor/cache/nominatim-dec16d522405/.travis.yml View File

@@ -1,7 +0,0 @@
language: ruby
rvm:
- 2.0.0
- 1.9.3
- 1.9.2
- rbx-19mode
script: "bundle exec rake"

+ 0
- 15
vendor/cache/nominatim-dec16d522405/CHANGELOG.md View File

@@ -1,15 +0,0 @@
## v0.0.3

* Added Polygon class.

* Fixed few typos.

* Added documentation to Place class.

* Added Point class.

* Returning ids as integers instead of strings.

## v0.0.1

* Initial release.

+ 0
- 8
vendor/cache/nominatim-dec16d522405/Gemfile View File

@@ -1,8 +0,0 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in nominatim.gemspec
gemspec

gem 'guard'
gem 'guard-rspec'
gem 'guard-bundler'

+ 0
- 13
vendor/cache/nominatim-dec16d522405/Guardfile View File

@@ -1,13 +0,0 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'bundler' do
watch('Gemfile')
watch(/^.+\.gemspec/)
end

guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
end

+ 0
- 22
vendor/cache/nominatim-dec16d522405/LICENSE View File

@@ -1,22 +0,0 @@
Copyright (c) 2012 Jakub Svehla

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 0
- 113
vendor/cache/nominatim-dec16d522405/README.md View File

@@ -1,113 +0,0 @@
# Nominatim

A Ruby wrapper for the Nominatim API. [![Build Status](https://secure.travis-ci.org/jakubsvehla/nominatim.png?branch=master)](http://travis-ci.org/jakubsvehla/nominatim)

## Installation

Add this line to your application's Gemfile:

gem 'nominatim'

And then execute:

$ bundle

Or install it yourself as:

$ gem install nominatim

## Documentation

[http://rdoc.info/gems/nominatim][documentation]

[documentation]: http://rdoc.info/gems/nominatim

## Usage

```ruby
places = Nominatim.search('San Francisco').limit(10).address_details(true)

for place in places
puts "#{place.display_name} (#{place.type})"
end

puts "Found #{places.count} places."
```

### Structured requests

```ruby
places = Nominatim.search.city('San Antonio').country('Mexico').limit(10).address_details(true)

for place in places
puts "#{place.display_name} (#{place.type})"
end

puts "Found #{places.count} places."
```

Nominatim::Search has the following methods to craft structures requests:

- street: accepts house number and street name as parameters
- city
- county
- state
- country
- postalcode

See http://wiki.openstreetmap.org/wiki/Nominatim#Parameters

## Configuration

```ruby
Nominatim.configure do |config|
config.email = 'your-email-address@example.com'
config.endpoint = 'http://open.mapquestapi.com/nominatim/v1'
end
```

## Contributing

1. [Fork the repository.][fork]
2. [Create a topic branch.][branch]
3. Add specs for your unimplemented feature or bug fix.
4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
5. Implement your feature or bug fix.
6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
7. Run `open coverage/index.html`. If your changes are not completely covered
by your tests, return to step 3.
8. Add, commit, and push your changes.
9. [Submit a pull request.][pr]

[fork]: http://help.github.com/fork-a-repo/
[branch]: http://learn.github.com/p/branching.html
[pr]: http://help.github.com/send-pull-requests/

## Supported Ruby Versions

Nominatim is tested under 1.9.2 and 1.9.3.

## Copyright

Copyright (c) 2012 Jakub Svehla

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 0
- 11
vendor/cache/nominatim-dec16d522405/Rakefile View File

@@ -1,11 +0,0 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new

task :test => :spec
task :default => :spec

require 'yard'
YARD::Rake::YardocTask.new

+ 0
- 36
vendor/cache/nominatim-dec16d522405/lib/nominatim.rb View File

@@ -1,36 +0,0 @@
require "nominatim/version"
require "nominatim/configuration"
require "nominatim/point"
require "nominatim/polygon"
require "nominatim/address"
require "nominatim/place"
require "nominatim/response/parse_json"
require "nominatim/client"
require "nominatim/search"
require "nominatim/reverse"

module Nominatim

# @return [Nominatim::Search]
def self.search(q = nil)
search = Nominatim::Search.new
search.query(q) if q
search
end

# @return [Nominatim::Reverse]
def self.reverse(lat = nil, lon = nil)
search = Nominatim::Reverse.new
search.lat(lat).lon(lon) if lat && lon
search
end

# @return [Nominatim::Configuration]
def self.config
@config ||= Configuration.new
end

def self.configure(&block)
config.configure &block
end
end

+ 0
- 83
vendor/cache/nominatim-dec16d522405/lib/nominatim/address.rb View File

@@ -1,83 +0,0 @@
module Nominatim
class Address
def initialize(attrs = {})
@attrs = attrs
end

def attraction
@attraction ||= @attrs[:attraction]
end

def clothes
@clothes ||= @attrs[:clothes]
end

def house_number
@house_number ||= @attrs[:house_number]
end

def road
@road ||= @attrs[:road]
end

def commercial
@commercial ||= @attrs[:commercial]
end

def pedestrian
@pedestrian ||= @attrs[:pedestrian]
end

def suburb
@suburb ||= @attrs[:suburb]
end

def city_district
@city_district ||= @attrs[:city_district]
end

def city
@city ||= @attrs[:city]
end

def administrative
@administrative ||= @attrs[:administrative]
end

def county
@county ||= @attrs[:county]
end

def state_district
@state_district ||= @attrs[:state_district]
end

def state
@state ||= @attrs[:state]
end

def postcode
@postcode ||= @attrs[:postcode]
end

def country
@country ||= @attrs[:country]
end

def country_code
@country_code ||= @attrs[:country_code]
end

def place
@place ||= @attrs[:place]
end

def town
@town ||= @attrs[:town]
end

def village
@village ||= @attrs[:village]
end
end
end

+ 0
- 40
vendor/cache/nominatim-dec16d522405/lib/nominatim/client.rb View File

@@ -1,40 +0,0 @@
require 'faraday'

module Nominatim
class Client

# Performs an HTTP GET request
def get(path, params = {})
connection.get path, params
end

private

# Returns a Faraday::Connection object
#
# @return [Faraday::Connection]
def connection
return @connection if defined? @connection

options = {
request: {
timeout: Nominatim.config.timeout
}
}

@connection = Faraday.new Nominatim.config.endpoint, options do |builder|
builder.use Nominatim::Response::ParseJson
builder.adapter Faraday.default_adapter
end

@connection.params[:format] = 'json'
@connection.params[:email] = Nominatim.config.email if Nominatim.config.email
@connection.params[:key] = Nominatim.config.key if Nominatim.config.key

@connection.headers[:user_agent] = Nominatim.config.user_agent
@connection.headers[:"accept-language"] = Nominatim.config.accept_language

@connection
end
end
end

+ 0
- 52
vendor/cache/nominatim-dec16d522405/lib/nominatim/configuration.rb View File

@@ -1,52 +0,0 @@
module Nominatim
class Configuration

DEFAULT_ENDPOINT = 'https://nominatim.openstreetmap.org'

DEFAULT_KEY = nil

DEFAULT_USER_AGENT = "Nominatim Ruby Gem #{Nominatim::VERSION}"

DEFAULT_EMAIL = nil

DEFAULT_LANGUAGE = 'en'

DEFAULT_TIMEOUT = nil

DEFAULT_SEARCH_URL = 'search'
DEFAULT_REVERSE_URL = 'reverse'

VALID_OPTIONS_KEYS = [
:endpoint,
:key,
:user_agent,
:email,
:accept_language,
:timeout,
:search_url,
:reverse_url
]

attr_accessor *VALID_OPTIONS_KEYS

def initialize
reset!
end

def configure
yield self
self
end

def reset!
self.endpoint = DEFAULT_ENDPOINT
self.key = DEFAULT_KEY
self.user_agent = DEFAULT_USER_AGENT
self.email = DEFAULT_EMAIL
self.accept_language = DEFAULT_LANGUAGE
self.timeout = DEFAULT_TIMEOUT
self.search_url = DEFAULT_SEARCH_URL
self.reverse_url = DEFAULT_REVERSE_URL
end
end
end

+ 0
- 93
vendor/cache/nominatim-dec16d522405/lib/nominatim/place.rb View File

@@ -1,93 +0,0 @@
module Nominatim
class Place
# attr_reader :attrs
# alias to_hash attrs

def initialize(attrs = {})
@attrs = attrs
end

# Return display name
#
# @return [String]
def display_name
@display_name ||= @attrs[:display_name]
end

# Return a class
#
# @return [String]
def class
@class ||= @attrs[:class]
end

# Return a type
#
# @return [String]
def type
@type ||= @attrs[:type]
end

# Return an address
#
# @return [Nominatim::Address]
def address
@address ||= Nominatim::Address.new(@attrs[:address]) if @attrs[:address]
end

# Return a latitude
#
# @return [Float]
def lat
point.lat
end
alias latitude lat

# Return a longitude
#
# @return [Float]
def lon
point.lon
end
alias longitude lon

def boundingbox
@boundingbox ||= @attrs[:boundingbox]
end
alias bounding_box boundingbox

# Return a polygon
#
# @return [Nominatim::Polygon]
def polygonpoints
@polygonpoints ||= Nominatim::Polygon.new(@attrs[:polygonpoints]) if @attrs[:polygonpoints]
end

# Return a place id
#
# @return [Integer]
def place_id
@place_id ||= @attrs[:place_id].to_i if @attrs[:place_id]
end

# Return an OSM id
#
# @return [Integer]
def osm_id
@osm_id ||= @attrs[:osm_id].to_i if @attrs[:osm_id]
end

# Return an OSM type
#
# @return [String]
def osm_type
@osm_type ||= @attrs[:osm_type]
end

private

def point
@point ||= Nominatim::Point.new(@attrs[:lat], @attrs[:lon])
end
end
end

+ 0
- 30
vendor/cache/nominatim-dec16d522405/lib/nominatim/point.rb View File

@@ -1,30 +0,0 @@
module Nominatim
class Point
attr_reader :lat, :lon
alias latitude lat
alias longitude lon

# @param lat [Float]
# @param lon [Float]
def initialize(lat, lon)
@lat, @lon = lat.to_f, lon.to_f if lat && lon
end

# @return [Array]
def to_a
[lat, lon]
end

# Return a string representation of the point
#
# @return [String]
def to_s
to_a.to_s
end

# @return [true, false]
def ==(other)
self.to_a == other.to_a
end
end
end

+ 0
- 13
vendor/cache/nominatim-dec16d522405/lib/nominatim/polygon.rb View File

@@ -1,13 +0,0 @@
module Nominatim
class Polygon
attr_reader :coordinates

# @param coordinates [Array<Array<Float, String>>]
def initialize(coordinates)
@coordinates = []
coordinates.each do |c|
@coordinates.push(Nominatim::Point.new(c[0], c[1]))
end
end
end
end

+ 0
- 16
vendor/cache/nominatim-dec16d522405/lib/nominatim/response/parse_json.rb View File

@@ -1,16 +0,0 @@
require 'faraday'
require 'multi_json'

module Nominatim
module Response
class ParseJson < Faraday::Response::Middleware
def on_complete(env)
if env[:body].empty?
env[:body] = nil
else
env[:body] = MultiJson.load(env[:body], symbolize_keys: true)
end
end
end
end
end

+ 0
- 44
vendor/cache/nominatim-dec16d522405/lib/nominatim/reverse.rb View File

@@ -1,44 +0,0 @@
module Nominatim
class Reverse < Client
attr_reader :criteria

def initialize
@criteria = {}
end

# Returns search result or nil if no results received.
def fetch
body = get(Nominatim.config.reverse_url, @criteria).body
return nil if body.empty?
Nominatim::Place.new(body)
end

# Latitude string to search for.
#
# @param lat [String] Latitude
# @return [Nominatim::Reverse]
def lat(lat)
@criteria[:lat] = lat
self
end

# Longitude string to search for.
#
# @param lon [String] Longitude
# @return [Nominatim::Reverse]
def lon(lon)
@criteria[:lon] = lon
self
end

# Include a breakdown of the address into elements.
#
# @param bool [true, false]
# @return [Nominatim::Reverse]
def address_details(bool)
@criteria[:addressdetails] = bool ? 1 : 0
self
end

end
end

+ 0
- 117
vendor/cache/nominatim-dec16d522405/lib/nominatim/search.rb View File

@@ -1,117 +0,0 @@
module Nominatim
class Search < Client
include Enumerable
attr_reader :criteria

def initialize
@criteria = {}
end

# Iterates over the search results.
def each(&block)
@criteria.delete(:q) if (@criteria.keys & [:street, :city, :county, :state, :country, :postalcode]).count > 0
@results ||= get(Nominatim.config.search_url, @criteria).body.map! { |attrs| Nominatim::Place.new(attrs) }
@results.each(&block)
end

# Structured search requests
# @see https://wiki.openstreetmap.org/wiki/Nominatim
%w(city county state country postalcode).to_a.each do |criterion|
define_method(criterion) do |param|
@criteria[criterion.to_sym] = param
self
end
end

# Structured street search request
#
# @see https://wiki.openstreetmap.org/wiki/Nominatim
def street housenumber, streetname
@criteria[:street] = "#{housenumber} #{streetname}"
self
end

# Query string to search for.
#
# @param q [String] Query string
# @return [Nominatim::Search]
def query(q)
@criteria[:q] = q
self
end

# Limit search results to a specific country (or a list of countries).
#
# @param codes [Array<String>, String]
# @see https://wiki.openstreetmap.org/wiki/Nominatim
# @return [Nominatim::Search]
def country_codes(codes)
if codes.instance_of? Array
@criteria[:countrycodes] = codes.join(',')
else
@criteria[:countrycodes] = codes
end
self
end

# The preferred area to find search results.
#
# @param viewbox [Array<String>]
# @return [Nominatim::Search]
def viewbox(viewbox)
@criteria[:viewbox] = viewbox.join(',')
self
end

# Restrict the results to only items contained with the bounding box.
#
# @param bool [true, false]
# @see https://wiki.openstreetmap.org/wiki/Nominatim
# @return [Nominatim::Search]
def bounded(bool)
@criteria[:bounded] = bool ? 1 : 0
self
end

# Output polygon outlines for items found.
#
# @param bool [true, false]
# @return [Nominatim::Search]
def polygon(bool)
@criteria[:polygon] = bool ? 1 : 0
self
end

# Include a breakdown of the address into elements.
#
# @param bool [true, false]
# @return [Nominatim::Search]
def address_details(bool)
@criteria[:addressdetails] = bool ? 1 : 0
self
end

# Exclude given place ids from the search result.
#
# @param ids [Array<String>, String] Place ids
# @return [Nominatim::Search]
def exclude_place_ids(ids)
if ids.instance_of? Array
@criteria[:exclude_place_ids] = ids.join(',')
else
@criteria[:exclude_place_ids] = ids
end
self
end

# Limit the number of returned results.
#
# @param limit [Integer]
# @return [Nominatim::Search]
def limit(limit)
@criteria[:limit] = limit
self
end

end
end

+ 0
- 3
vendor/cache/nominatim-dec16d522405/lib/nominatim/version.rb View File

@@ -1,3 +0,0 @@
module Nominatim
VERSION = "0.0.6"
end

+ 0
- 51
vendor/cache/nominatim-dec16d522405/nominatim.gemspec View File

@@ -1,51 +0,0 @@
# -*- encoding: utf-8 -*-
# stub: nominatim 0.0.6 ruby lib

Gem::Specification.new do |s|
s.name = "nominatim".freeze
s.version = "0.0.6"

s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Jakub Svehla".freeze]
s.date = "2020-01-15"
s.description = "A Ruby wrapper for the Nominatim API.".freeze
s.email = ["jakub.svehla@gmail.com".freeze]
s.files = [".gitignore".freeze, ".rspec".freeze, ".travis.yml".freeze, "CHANGELOG.md".freeze, "Gemfile".freeze, "Guardfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "lib/nominatim.rb".freeze, "lib/nominatim/address.rb".freeze, "lib/nominatim/client.rb".freeze, "lib/nominatim/configuration.rb".freeze, "lib/nominatim/place.rb".freeze, "lib/nominatim/point.rb".freeze, "lib/nominatim/polygon.rb".freeze, "lib/nominatim/response/parse_json.rb".freeze, "lib/nominatim/reverse.rb".freeze, "lib/nominatim/search.rb".freeze, "lib/nominatim/version.rb".freeze, "nominatim.gemspec".freeze, "spec/fixtures/reverse.json".freeze, "spec/fixtures/search.json".freeze, "spec/nominatim/address_spec.rb".freeze, "spec/nominatim/client_spec.rb".freeze, "spec/nominatim/place_spec.rb".freeze, "spec/nominatim/point_spec.rb".freeze, "spec/nominatim/polygon_spec.rb".freeze, "spec/nominatim/reverse_spec.rb".freeze, "spec/nominatim/search_spec.rb".freeze, "spec/nominatim_spec.rb".freeze, "spec/spec_helper.rb".freeze]
s.homepage = "https://github.com/jakubsvehla/nominatim".freeze
s.rubygems_version = "3.0.4".freeze
s.summary = "A Ruby wrapper for the Nominatim API.".freeze
s.test_files = ["spec/fixtures/reverse.json".freeze, "spec/fixtures/search.json".freeze, "spec/nominatim/address_spec.rb".freeze, "spec/nominatim/client_spec.rb".freeze, "spec/nominatim/place_spec.rb".freeze, "spec/nominatim/point_spec.rb".freeze, "spec/nominatim/polygon_spec.rb".freeze, "spec/nominatim/reverse_spec.rb".freeze, "spec/nominatim/search_spec.rb".freeze, "spec/nominatim_spec.rb".freeze, "spec/spec_helper.rb".freeze]

s.installed_by_version = "3.0.4" if s.respond_to? :installed_by_version

if s.respond_to? :specification_version then
s.specification_version = 4

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<faraday>.freeze, [">= 0"])
s.add_runtime_dependency(%q<multi_json>.freeze, [">= 0"])
s.add_development_dependency(%q<rake>.freeze, [">= 0"])
s.add_development_dependency(%q<rspec>.freeze, ["~> 2.10"])
s.add_development_dependency(%q<webmock>.freeze, [">= 0"])
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
s.add_development_dependency(%q<yard>.freeze, [">= 0"])
else
s.add_dependency(%q<faraday>.freeze, [">= 0"])
s.add_dependency(%q<multi_json>.freeze, [">= 0"])
s.add_dependency(%q<rake>.freeze, [">= 0"])
s.add_dependency(%q<rspec>.freeze, ["~> 2.10"])
s.add_dependency(%q<webmock>.freeze, [">= 0"])
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
s.add_dependency(%q<yard>.freeze, [">= 0"])
end
else
s.add_dependency(%q<faraday>.freeze, [">= 0"])
s.add_dependency(%q<multi_json>.freeze, [">= 0"])
s.add_dependency(%q<rake>.freeze, [">= 0"])
s.add_dependency(%q<rspec>.freeze, ["~> 2.10"])
s.add_dependency(%q<webmock>.freeze, [">= 0"])
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
s.add_dependency(%q<yard>.freeze, [">= 0"])
end
end

+ 0
- 1
vendor/cache/nominatim-dec16d522405/spec/fixtures/reverse.json View File

@@ -1 +0,0 @@
{"place_id":"13686660","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"1241690521","lat":"37.733976","lon":"-122.3912081","display_name":"4900, 3rd Street, San Francisco, California, 94124, United States of America","address":{"house_number":"4900","road":"3rd Street","city":"San Francisco","county":"San Francisco","state":"California","postcode":"94124","country":"United States of America","country_code":"us"}}

+ 0
- 1
vendor/cache/nominatim-dec16d522405/spec/fixtures/search.json
File diff suppressed because it is too large
View File


+ 0
- 209
vendor/cache/nominatim-dec16d522405/spec/nominatim/address_spec.rb View File

@@ -1,209 +0,0 @@
require 'spec_helper'

describe Nominatim::Address do

describe '#attraction' do
it 'returns a attraction when set with attraction' do
address = Nominatim::Address.new(attraction: 'Eiffel Tower')
address.attraction.should eq 'Eiffel Tower'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.attraction.should be_nil
end
end

describe '#clothes' do
it 'returns clothes when set with clothes' do
address = Nominatim::Address.new(clothes: 'XXI')
address.clothes.should eq 'XXI'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.clothes.should be_nil
end
end

describe '#house_number' do
it 'returns a house number when set with house_number' do
address = Nominatim::Address.new(house_number: 1)
address.house_number.should eq 1
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.house_number.should be_nil
end
end

describe '#road' do
it 'returns a road when set with road' do
address = Nominatim::Address.new(road: 'Infinite Loop')
address.road.should eq 'Infinite Loop'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.road.should be_nil
end
end

describe '#commercial' do
it 'returns a commercial when set with commercial' do
address = Nominatim::Address.new(commercial: 'Apple, Inc.')
address.commercial.should eq 'Apple, Inc.'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.commercial.should be_nil
end
end

describe '#pedestrian' do
it 'returns a pedestrian when set with pedestrian' do
address = Nominatim::Address.new(pedestrian: 'Avenue Pierre Loti')
address.pedestrian.should eq 'Avenue Pierre Loti'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.pedestrian.should be_nil
end
end

describe '#suburb' do
it 'returns a suburb when set with suburb' do
address = Nominatim::Address.new(suburb: 'Quartier du Gros Caillou')
address.suburb.should eq 'Quartier du Gros Caillou'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.suburb.should be_nil
end
end

describe '#city_district' do
it 'returns a city district when set with city_district' do
address = Nominatim::Address.new(city_district: '7th Arrondissement')
address.city_district.should eq '7th Arrondissement'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.city_district.should be_nil
end
end

describe '#city' do
it 'returns a city when set with city' do
address = Nominatim::Address.new(city: 'Santa Clara')
address.city.should eq 'Santa Clara'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.city.should be_nil
end
end

describe '#administrative' do
it 'returns a administrative when set with administrative' do
address = Nominatim::Address.new(administrative: 'Paris')
address.administrative.should eq 'Paris'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.administrative.should be_nil
end
end

describe '#county' do
it 'returns a county when set with county' do
address = Nominatim::Address.new(county: 'Santa Clara County')
address.county.should eq 'Santa Clara County'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.county.should be_nil
end
end

describe '#state_district' do
it 'returns a state disctrict when set with state_district' do
address = Nominatim::Address.new(state_district: 'West Midlands')
address.state_district.should eq 'West Midlands'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.state_district.should be_nil
end
end

describe '#state' do
it 'returns a state when set with state' do
address = Nominatim::Address.new(state: 'California')
address.state.should eq 'California'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.state.should be_nil
end
end

describe '#postcode' do
it 'returns a postcode when set with postcode' do
address = Nominatim::Address.new(postcode: '95014')
address.postcode.should eq '95014'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.postcode.should be_nil
end
end

describe '#country' do
it 'returns a country when set with country' do
address = Nominatim::Address.new(country: 'United States of America')
address.country.should eq 'United States of America'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.country.should be_nil
end
end

describe '#country_code' do
it 'returns a country code when set with country_code' do
address = Nominatim::Address.new(country_code: 'us')
address.country_code.should eq 'us'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.country_code.should be_nil
end
end

describe '#place' do
it 'returns a place when set with place' do
address = Nominatim::Address.new(place: 'Europe')
address.place.should eq 'Europe'
end

it 'returns nil when not set' do
address = Nominatim::Address.new
address.place.should be_nil
end
end

end

+ 0
- 23
vendor/cache/nominatim-dec16d522405/spec/nominatim/client_spec.rb View File

@@ -1,23 +0,0 @@
require 'spec_helper'

describe Nominatim::Client do
after do
WebMock.reset!
end

describe '#get' do
before do
stub_get('/search').to_return(body: "[]")
end

it 'requests the correct resource' do
Nominatim::Client.new.get('/search')
a_get('/search').should have_been_requested
end

it 'parses the body' do
response = Nominatim::Client.new.get('/search')
response.body.should eq []
end
end
end

+ 0
- 172
vendor/cache/nominatim-dec16d522405/spec/nominatim/place_spec.rb View File

@@ -1,172 +0,0 @@
require 'spec_helper'

describe Nominatim::Place do
describe '#display_name' do
it 'returns a full name when set with display_name' do
place = Nominatim::Place.new(display_name: 'Los Angeles, California, United States of America')
place.display_name.should eq 'Los Angeles, California, United States of America'
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.display_name.should be_nil
end
end

describe '#class' do
it 'returns a class when set with class' do
place = Nominatim::Place.new(class: 'place')
place.class.should eq 'place'
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.class.should be_nil
end
end

describe '#type' do
it 'returns a type when set with type' do
place = Nominatim::Place.new(type: 'county')
place.type.should eq 'county'
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.type.should be_nil
end
end

describe '#address' do
it 'returns a Nominatim::Address when set' do
place = Nominatim::Place.new(address: {county: 'Los Angeles', state: 'California', country: 'United States of America'})
place.address.should be_a Nominatim::Address
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.address.should be_nil
end
end

describe '#lat' do
it 'returns a latitude when set with lat' do
place = Nominatim::Place.new(lat: '52.5487969264788', lon: '-1.81642935385411')
place.lat.should eq 52.5487969264788
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.lat.should be_nil
end
end

describe '#latitude' do
it 'returns a latitude when set with lat' do
place = Nominatim::Place.new(lat: '52.5487969264788', lon: '-1.81642935385411')
place.latitude.should eq 52.5487969264788
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.latitude.should be_nil
end
end

describe '#lon' do
it 'returns a longitude when set with lon' do
place = Nominatim::Place.new(lat: '52.5487969264788', lon: '-1.81642935385411')
place.lon.should eq -1.81642935385411
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.lon.should be_nil
end
end

describe '#longitude' do
it 'returns a longitude when set with lon' do
place = Nominatim::Place.new(lat: '52.5487969264788', lon: '-1.81642935385411')
place.longitude.should eq -1.81642935385411
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.longitude.should be_nil
end
end

describe '#boundingbox' do
it 'returns a boundingbox when set with boundingbox' do
place = Nominatim::Place.new(boundingbox: ["52.5487442016602", "52.5488510131836", "-1.81651306152344", "-1.81634628772736"])
place.boundingbox.should eq ["52.5487442016602", "52.5488510131836", "-1.81651306152344", "-1.81634628772736"]
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.boundingbox.should be_nil
end
end

describe '#bounding_box' do
it 'returns a bounding box when set with boundingbox' do
place = Nominatim::Place.new(boundingbox: ["52.5487442016602", "52.5488510131836", "-1.81651306152344", "-1.81634628772736"])
place.bounding_box.should eq ["52.5487442016602", "52.5488510131836", "-1.81651306152344", "-1.81634628772736"]
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.bounding_box.should be_nil
end
end

describe '#polygonpoints' do
it 'returns polygon points when set with polygonpoints' do
place = Nominatim::Place.new(polygonpoints: [["-1.816513", "52.5487566"], ["-1.8164913", "52.548824"], ["-1.8164685", "52.5488213"]])
place.polygonpoints.should be_a Nominatim::Polygon
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.polygonpoints.should be_nil
end
end

describe '#place_id' do
it 'returns a place id when set with place_id' do
place = Nominatim::Place.new(place_id: '84327444')
place.place_id.should eq 84327444
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.place_id.should be_nil
end
end

describe '#osm_id' do
it 'returns an osm id when set with osm_id' do
place = Nominatim::Place.new(osm_id: '90394480')
place.osm_id.should eq 90394480
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.osm_id.should be_nil
end
end

describe '#osm_type' do
it 'returns an osm type when set with osm_type' do
place = Nominatim::Place.new(osm_type: 'way')
place.osm_type.should eq 'way'
end

it 'returns nil when not set' do
place = Nominatim::Place.new
place.osm_type.should be_nil
end
end

end

+ 0
- 53
vendor/cache/nominatim-dec16d522405/spec/nominatim/point_spec.rb View File

@@ -1,53 +0,0 @@
require 'spec_helper'

describe Nominatim::Point do
let(:point) { Nominatim::Point.new(52.5487969264788, -1.81642935385411) }

describe '#lat' do
it 'returns the latitude' do
point.lat.should eq 52.5487969264788
end
end

describe '#latitude' do
it 'returns the latitude' do
point.latitude.should eq 52.5487969264788
end
end

describe '#lon' do
it 'returns the longitude' do
point.lon.should eq -1.81642935385411
end
end

describe '#longitude' do
it 'returns the longitude' do
point.longitude.should eq -1.81642935385411
end
end

describe '#to_a' do
it 'returns an array representing the point' do
point.to_a.should eq [52.5487969264788, -1.81642935385411]
end
end

describe '#to_s' do
it 'returns a string representing the point' do
point.to_s.should eq '[52.5487969264788, -1.81642935385411]'
end
end

describe '#==' do
it 'returns true when objects coordinates are the same' do
other = Nominatim::Point.new(52.5487969264788, -1.81642935385411)
(point == other).should be_true
end

it 'returns false when objects coordinates are different' do
other = Nominatim::Point.new(-1.81642935385411, 52.5487969264788)
(point == other).should be_false
end
end
end

+ 0
- 19
vendor/cache/nominatim-dec16d522405/spec/nominatim/polygon_spec.rb View File

@@ -1,19 +0,0 @@
require 'spec_helper'

describe Nominatim::Polygon do

let(:polygon) { Nominatim::Polygon.new([[-1.816513, 52.5487566], [-1.8164913, 52.548824], [-1.8164685, 52.5488213]]) }

it 'sets coordinates correctly' do
polygon.coordinates.first.lat.should eq -1.816513
polygon.coordinates.first.lon.should eq 52.5487566
end

describe '#coordinates' do
it 'retruns an array of coordinates' do
polygon.coordinates.each do |p|
p.should be_a Nominatim::Point
end
end
end
end

+ 0
- 68
vendor/cache/nominatim-dec16d522405/spec/nominatim/reverse_spec.rb View File

@@ -1,68 +0,0 @@
require 'spec_helper'

describe Nominatim::Reverse do

let(:reverse) { Nominatim::Reverse.new }

it 'has no criteria set' do
reverse.criteria.should be_empty
end

it 'allows chaining of criterions' do
reverse.lat('37.733976').lon('-122.3912081').address_details(1)
reverse.criteria[:lat].should eq '37.733976'
reverse.criteria[:lon].should eq '-122.3912081'
reverse.criteria[:addressdetails].should eq 1
end

describe '#each' do
let(:reverse) { Nominatim::Reverse.new.lat('37.733976').lon('-122.3912081').address_details(1) }

before do
stub_get('/reverse').
with(query: { lat: '37.733976', lon: '-122.3912081', addressdetails: 1 }).
to_return(body: fixture('reverse.json'))
end

it 'iterates over the matching places' do
reverse.fetch.should be_a Nominatim::Place
end

it 'returns correct places' do
reverse.fetch.display_name.should eq '4900, 3rd Street, San Francisco, California, 94124, United States of America'
reverse.fetch.address.city.should eq 'San Francisco'
reverse.fetch.address.state.should eq 'California'
end
end

describe '#lat' do
it 'adds a latitude criterion' do
reverse.lat('37.733976')
reverse.criteria[:lat].should eq '37.733976'
end
end

describe '#lon' do
it 'adds a longitude criterion' do
reverse.lon('-122.3912081')
reverse.criteria[:lon].should eq '-122.3912081'
end
end

describe '#address_details' do
it 'adds an address details criterion' do
reverse.address_details(true)
reverse.criteria[:addressdetails].should eq 1
end

it 'sets 1 when set with true' do
reverse.address_details(true)
reverse.criteria[:addressdetails].should eq 1
end

it 'sets 0 when set with false' do
reverse.address_details(false)
reverse.criteria[:addressdetails].should eq 0
end
end
end

+ 0
- 185
vendor/cache/nominatim-dec16d522405/spec/nominatim/search_spec.rb View File

@@ -1,185 +0,0 @@
require 'spec_helper'

describe Nominatim::Search do

let(:search) { Nominatim::Search.new }

it 'has no criteria set' do
search.criteria.should be_empty
end

it 'allows chaining of criterions' do
search.query('Los Angeles').limit(1)
search.criteria[:q].should eq 'Los Angeles'
search.criteria[:limit].should eq 1
end

describe '#each' do

let(:search) { Nominatim::Search.new.query('Los Angeles').limit(1) }

let(:structured_search){ Nominatim::Search.new.query('Text').city('Los Angeles').country('us').limit(1) }

before do
stub_get('/search').
with(query: { q: 'Los Angeles', limit: 1 }).
to_return(body: fixture('search.json'))
stub_get('/search').
with(query: { city: 'Los Angeles', country: 'us', limit: 1 }).
to_return(body: fixture('search.json'))
end

it 'iterates over the matching places' do
search.each do |place|
place.should be_a Nominatim::Place
end
end

it 'returns all matching places' do
search.count.should eq 1
end

it 'returns correct places' do
search.first.display_name.should eq 'Los Angeles, California, United States of America'
search.first.lat.should eq 34.0966764
search.first.lon.should eq -117.7196785
end

it 'omits q parameter from structured search' do
structured_search.first.display_name.should eq 'Los Angeles, California, United States of America'
structured_search.first.lat.should eq 34.0966764
structured_search.first.lon.should eq -117.7196785
end
end

describe '#query' do
it 'adds a query criterion' do
search.query('Los Angeles')
search.criteria[:q].should eq 'Los Angeles'
end
end

describe '#country_codes' do
it 'adds a country codes criterion' do
search.country_codes('us')
search.criteria[:countrycodes].should eq 'us'
end

it 'adds all country codes when set with an array' do
search.country_codes(['us', 'ca'])
search.criteria[:countrycodes].should eq 'us,ca'
end
end

describe '#viewbox' do
it 'adds a viewbox criterion' do
search.viewbox(["52.5487442016602", "-1.81651306152344", "52.5488510131836", "-1.81634628772736"])
search.criteria[:viewbox].should eq "52.5487442016602,-1.81651306152344,52.5488510131836,-1.81634628772736"
end
end

describe '#street' do
it 'adds a street criterion' do
search.street('1000', 'street name')
search.criteria[:street].should eq "1000 street name"
end
end
describe '#city' do
it 'adds a city criterion' do
search.city('City name')
search.criteria[:city].should eq "City name"
end
end
describe '#county' do
it 'adds a county criterion' do
search.county('County name')
search.criteria[:county].should eq "County name"
end
end

describe '#state' do
it 'adds a state criterion' do
search.state('State name')
search.criteria[:state].should eq "State name"
end
end

describe '#country' do
it 'adds a country criterion' do
search.country('Country name')
search.criteria[:country].should eq "Country name"
end
end


describe '#bounded' do
it 'adds a bounded criterion' do
search.bounded(true)
search.criteria[:bounded].should eq 1
end

it 'sets 1 when set with true' do
search.bounded(true)
search.criteria[:bounded].should eq 1
end

it 'sets 0 when set with false' do
search.bounded(false)
search.criteria[:bounded].should eq 0
end
end

describe '#polygon' do
it 'adds a polygon criterion' do
search.polygon(true)
search.criteria[:polygon].should eq 1
end

it 'sets 1 when set with true' do
search.polygon(true)
search.criteria[:polygon].should eq 1
end

it 'sets 0 when set with false' do
search.polygon(false)
search.criteria[:polygon].should eq 0
end
end

describe '#address_details' do
it 'adds an address details criterion' do
search.address_details(true)
search.criteria[:addressdetails].should eq 1
end

it 'sets 1 when set with true' do
search.address_details(true)
search.criteria[:addressdetails].should eq 1
end

it 'sets 0 when set with false' do
search.address_details(false)
search.criteria[:addressdetails].should eq 0
end
end

describe '#exclude_place_ids' do
it 'excludes given place ids' do
search.exclude_place_ids('1')
search.criteria[:exclude_place_ids].should eq '1'
end

it 'adds all place ids when set with an array' do
search.exclude_place_ids(['1', '2', '3'])
search.criteria[:exclude_place_ids].should eq '1,2,3'
end
end

describe '#limit' do
it 'adds a limit criterion' do
search.limit(1)
search.criteria[:limit].should eq 1
end
end

end

+ 0
- 66
vendor/cache/nominatim-dec16d522405/spec/nominatim_spec.rb View File

@@ -1,66 +0,0 @@
require 'spec_helper'

describe Nominatim do
describe '.search' do
it 'returns a Nominatim::Search' do
Nominatim.search.should be_a Nominatim::Search
end

it 'adds a query criterion if given as a parameter' do
search = Nominatim.search('San Francisco')
search.criteria[:q].should eq 'San Francisco'
end
end

describe '.reverse' do
it 'returns a Nominatim::Reverse' do
Nominatim.reverse.should be_a Nominatim::Reverse
end

it 'adds a reverse query criteria if given as a parameters' do
reverse = Nominatim.reverse('37.733976', '-122.3912081')
reverse.criteria[:lat].should eq '37.733976'
reverse.criteria[:lon].should eq '-122.3912081'
end
end

describe '.configure' do

before do
Nominatim.config.reset!
end

it 'has a default endpoint' do
Nominatim.config.endpoint.should eq "https://nominatim.openstreetmap.org"
end

it 'sets the endpoint' do
Nominatim.configure do |config|
config.endpoint = "http://nominatim.org/"
end
Nominatim.config.endpoint.should eq "http://nominatim.org/"
end

it 'has a default user agent' do
Nominatim.config.user_agent.should eq "Nominatim Ruby Gem #{Nominatim::VERSION}"
end

it 'sets the user agent' do
Nominatim.configure do |config|
config.user_agent = "MyApp"
end
Nominatim.config.user_agent.should eq "MyApp"
end

it 'has a default email' do
Nominatim.config.email.should be_nil
end

it 'sets the email' do
Nominatim.configure do |config|
config.email = "foo@bar.com"
end
Nominatim.config.email.should eq "foo@bar.com"
end
end
end

+ 0
- 38
vendor/cache/nominatim-dec16d522405/spec/spec_helper.rb View File

@@ -1,38 +0,0 @@
unless ENV['CI']
require 'simplecov'

SimpleCov.start do
add_filter 'spec'
end
end

require 'nominatim'
require 'webmock/rspec'

WebMock.disable_net_connect!

RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus

config.before do
Nominatim.config.reset!
end
end

def a_get(path)
a_request(:get, "#{Nominatim.config.endpoint}#{path}").with(query: { format: 'json' })
end

def stub_get(path)
stub_request(:get, "#{Nominatim.config.endpoint}#{path}").with(query: { format: 'json' })
end

def fixture_path
File.expand_path('../fixtures', __FILE__)
end

def fixture(file)
File.new(fixture_path + '/' + file)
end

Loading…
Cancel
Save