regio 0.2.0 → 0.3.0

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
  SHA256:
3
- metadata.gz: 58f1f77fb4ff83302a5591e138bface9f60913e2649727bee81b7460067d8d44
4
- data.tar.gz: 7e10c3b4eb3826aaf0865888c98507f3cdf5a97e550f3100e8f91beb89bffe41
3
+ metadata.gz: 86ff1a4469844d4dac8bb93c443ea9fe502f6ccc9c797527b084632b07ea1782
4
+ data.tar.gz: 927ccf0892657b996638c674626891d52e3fb7150e2c3958745eefcab2fccc41
5
5
  SHA512:
6
- metadata.gz: 6702d492cb1b10ee6f6795ef16be9c1d7f8e36009d2e3667e513974b642ceed446c41a83e106b832176aa90f7eadc05d7185fb5c5f24b23f1a0e8676bb68975f
7
- data.tar.gz: a9e6cf6a456cdcda8d5abb1adb718199df81295aca6bc1fe7d488276b5f6a7ba1aa6eb94f35435fb34e551b5c6bc3da9eabab1e26534918dd68bea080914f5e8
6
+ metadata.gz: 4e303ab24fb83061ab0356d4aae680513c60ffd61e5160132865b562d75918b2835b506c1d63adf2ce0db914cfab84ea4160065650c22d477b747881bb949ee1
7
+ data.tar.gz: '048f9e3a8a809f4faed5e312900231f4d94ecf343eac3be83188db7ce0f76b48a38ce6a8d2b39b806fed7d7c3d993baf65b22afe1d8f5d8c6c4feb13acd006bf'
@@ -7,13 +7,17 @@ concurrency:
7
7
  cancel-in-progress: true
8
8
  jobs:
9
9
  rspec:
10
- name: RSpec
10
+ name: RSpec with ruby ${{matrix.ruby}}
11
11
  runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: ['2.6', '2.7', '3.0', '3.1', head]
12
16
  steps:
13
17
  - uses: actions/checkout@v3
14
18
  - uses: ruby/setup-ruby@v1
15
19
  with:
16
- ruby-version: 3.1.2
20
+ ruby-version: ${{matrix.ruby}}
17
21
  bundler-cache: true
18
22
  - name: Test with RSpec
19
23
  run: COVERAGE=true bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change log
2
2
 
3
+ ## v0.3.0 (02.01.2023)
4
+
5
+ * 2 major enhancements:
6
+ * Regio [routing](https://api.regio.ee/documentation/#docs/routing_and_directions)
7
+ * Regio [gazetteer](https://api.regio.ee/documentation/#docs/gazetteer)
8
+ * Minor refactoring
9
+
3
10
  ## v0.2.0 (15.10.2022)
4
11
 
5
12
  * 1 major enhancement:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- regio (0.2.0)
4
+ regio (0.3.0)
5
5
  httparty (~> 0.20.0)
6
6
 
7
7
  GEM
@@ -18,51 +18,51 @@ GEM
18
18
  httparty (0.20.0)
19
19
  mime-types (~> 3.0)
20
20
  multi_xml (>= 0.5.2)
21
- json (2.6.2)
21
+ json (2.6.3)
22
22
  mime-types (3.4.1)
23
23
  mime-types-data (~> 3.2015)
24
24
  mime-types-data (3.2022.0105)
25
25
  multi_xml (0.6.0)
26
26
  parallel (1.22.1)
27
- parser (3.1.2.1)
27
+ parser (3.1.3.0)
28
28
  ast (~> 2.4.1)
29
29
  public_suffix (5.0.0)
30
30
  rainbow (3.1.1)
31
31
  rake (13.0.6)
32
- regexp_parser (2.6.0)
32
+ regexp_parser (2.6.1)
33
33
  rexml (3.2.5)
34
- rspec (3.11.0)
35
- rspec-core (~> 3.11.0)
36
- rspec-expectations (~> 3.11.0)
37
- rspec-mocks (~> 3.11.0)
38
- rspec-core (3.11.0)
39
- rspec-support (~> 3.11.0)
40
- rspec-expectations (3.11.1)
34
+ rspec (3.12.0)
35
+ rspec-core (~> 3.12.0)
36
+ rspec-expectations (~> 3.12.0)
37
+ rspec-mocks (~> 3.12.0)
38
+ rspec-core (3.12.0)
39
+ rspec-support (~> 3.12.0)
40
+ rspec-expectations (3.12.0)
41
41
  diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.11.0)
43
- rspec-mocks (3.11.1)
42
+ rspec-support (~> 3.12.0)
43
+ rspec-mocks (3.12.0)
44
44
  diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.11.0)
46
- rspec-support (3.11.1)
47
- rubocop (1.36.0)
45
+ rspec-support (~> 3.12.0)
46
+ rspec-support (3.12.0)
47
+ rubocop (1.41.1)
48
48
  json (~> 2.3)
49
49
  parallel (~> 1.10)
50
50
  parser (>= 3.1.2.1)
51
51
  rainbow (>= 2.2.2, < 4.0)
52
52
  regexp_parser (>= 1.8, < 3.0)
53
53
  rexml (>= 3.2.5, < 4.0)
54
- rubocop-ast (>= 1.20.1, < 2.0)
54
+ rubocop-ast (>= 1.23.0, < 2.0)
55
55
  ruby-progressbar (~> 1.7)
56
56
  unicode-display_width (>= 1.4.0, < 3.0)
57
- rubocop-ast (1.21.0)
57
+ rubocop-ast (1.24.0)
58
58
  parser (>= 3.1.1.0)
59
- rubocop-performance (1.15.0)
59
+ rubocop-performance (1.15.2)
60
60
  rubocop (>= 1.7.0, < 2.0)
61
61
  rubocop-ast (>= 0.4.0)
62
- rubocop-rspec (2.13.2)
62
+ rubocop-rspec (2.16.0)
63
63
  rubocop (~> 1.33)
64
64
  ruby-progressbar (1.11.0)
65
- simplecov (0.21.2)
65
+ simplecov (0.22.0)
66
66
  docile (~> 1.1)
67
67
  simplecov-html (~> 0.11)
68
68
  simplecov_json_formatter (~> 0.1)
@@ -84,11 +84,11 @@ DEPENDENCIES
84
84
  bundler (~> 2.3.0)
85
85
  rake (~> 13.0.6)
86
86
  regio!
87
- rspec (~> 3.11.0)
87
+ rspec (~> 3.12.0)
88
88
  rubocop (~> 1.36)
89
89
  rubocop-performance (~> 1.15)
90
- rubocop-rspec (~> 2.13.2)
91
- simplecov (~> 0.21.2)
90
+ rubocop-rspec (~> 2.16.0)
91
+ simplecov (~> 0.22.0)
92
92
  webmock (~> 3.18.1)
93
93
 
94
94
  BUNDLED WITH
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  Add this line to your application's Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'regio', '~> 0.2.0'
14
+ gem 'regio', '~> 0.3.0'
15
15
  ```
16
16
 
17
17
  And then execute:
@@ -30,6 +30,15 @@ Get your own API key
30
30
  REGIO_API_KEY=SECRET
31
31
  ```
32
32
 
33
+ ```
34
+ export REGIO_API_KEY=SECRET && irb -I lib
35
+
36
+ irb(main):001:0> require 'regio'
37
+ => true
38
+
39
+ ...
40
+ ```
41
+
33
42
  ### Geocoding
34
43
 
35
44
  Use `Geocode` class in your code
@@ -56,7 +65,6 @@ end
56
65
 
57
66
  Check Regio [geocode](https://api.regio.ee/documentation/#docs/geocode) documentation
58
67
 
59
-
60
68
  ### Reverse geocoding
61
69
 
62
70
  Use `ReverseGeocode` class in your code
@@ -83,6 +91,59 @@ end
83
91
 
84
92
  Check Regio [reverse geocode](https://api.regio.ee/documentation/#docs/reverse_geocode) documentation
85
93
 
94
+ ### Gazetteer
95
+
96
+ Use `Gazetteer` class in your code
97
+
98
+ ```ruby
99
+ require 'regio'
100
+
101
+ class Geocoding
102
+
103
+ private
104
+
105
+ def results
106
+ @results ||= Regio::Gazetteer.new(options).results
107
+ end
108
+
109
+ def options
110
+ {
111
+ id: 16004253,
112
+ query: 'address_children'
113
+ }
114
+ end
115
+ end
116
+ ```
117
+
118
+ Check Regio [Gazetteer](https://api.regio.ee/documentation/#docs/gazetteer) documentation
119
+
120
+ ### Routing and directions
121
+
122
+ Use `Routing` class in your code
123
+
124
+ ```ruby
125
+ require 'regio'
126
+
127
+ class Routing
128
+
129
+ private
130
+
131
+ def results
132
+ @results ||= Regio::Routing.new(options).results
133
+ end
134
+
135
+ def options
136
+ {
137
+ coordinates: [[24.649138022268, 59.14048887149], [25.853136227622, 59.00678681919]],
138
+ service: 'optimize',
139
+ overview: 'full'
140
+ }
141
+ end
142
+ end
143
+ ```
144
+
145
+ Check Regio [routing and directions](https://api.regio.ee/documentation/#docs/routing_and_directions) documentation
146
+
86
147
  ## Development
87
148
 
88
149
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Regio
4
+ class Gazetteer < Core
5
+ def results
6
+ raise Unprocessable, response[:message] if response[:message]
7
+
8
+ response.merge(
9
+ collection: response[:data]&.map { |result| transform(result) } || []
10
+ )
11
+ end
12
+
13
+ private
14
+
15
+ def response
16
+ @response ||= run('/gazetteer', options)
17
+ end
18
+
19
+ # NOTE: all options described in the documentation
20
+ # https://api.regio.ee/documentation/#docs/gazetteer
21
+ def default_options
22
+ {
23
+ apikey: Configuration.api_key,
24
+ address_format: 'long_address',
25
+ output_format: 'json'
26
+ }
27
+ end
28
+ end
29
+ end
data/lib/regio/geocode.rb CHANGED
@@ -13,7 +13,7 @@ module Regio
13
13
  private
14
14
 
15
15
  def response
16
- run('/geocode', options)
16
+ @response ||= run('/geocode', options)
17
17
  end
18
18
 
19
19
  # NOTE: all options described in the documentation
@@ -13,7 +13,7 @@ module Regio
13
13
  private
14
14
 
15
15
  def response
16
- run('/revgeocode', options)
16
+ @response ||= run('/revgeocode', options)
17
17
  end
18
18
 
19
19
  # NOTE: all options described in the documentation
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Regio
4
+ class Routing < Core
5
+ def results
6
+ response.tap do |response|
7
+ raise Unprocessable, response[:message] if response[:message]
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def response
14
+ options[:coordinates]&.map { |lnglat| lnglat.join(',') }&.join(';')
15
+
16
+ @response ||= run('/routing', options)
17
+ end
18
+
19
+ # NOTE: all options described in the documentation
20
+ # https://api.regio.ee/documentation/#docs/routing_and_directions
21
+ def default_options
22
+ {
23
+ apikey: Configuration.api_key,
24
+ output_format: 'json',
25
+ limit: 25
26
+ }
27
+ end
28
+ end
29
+ end
data/lib/regio/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Regio
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/regio.rb CHANGED
@@ -2,8 +2,10 @@
2
2
 
3
3
  require 'regio/configuration'
4
4
  require 'regio/core'
5
+ require 'regio/gazetteer'
5
6
  require 'regio/geocode'
6
7
  require 'regio/reverse_geocode'
8
+ require 'regio/routing'
7
9
  require 'regio/errors/failed'
8
10
  require 'regio/errors/forbidden'
9
11
  require 'regio/errors/not_found'
data/regio.gemspec CHANGED
@@ -41,11 +41,11 @@ Gem::Specification.new do |spec|
41
41
 
42
42
  spec.add_development_dependency 'bundler', '~> 2.3.0'
43
43
  spec.add_development_dependency 'rake', '~> 13.0.6'
44
- spec.add_development_dependency 'rspec', '~> 3.11.0'
44
+ spec.add_development_dependency 'rspec', '~> 3.12.0'
45
45
  spec.add_development_dependency 'rubocop', '~> 1.36'
46
46
  spec.add_development_dependency 'rubocop-performance', '~> 1.15'
47
- spec.add_development_dependency 'rubocop-rspec', '~> 2.13.2'
48
- spec.add_development_dependency 'simplecov', '~> 0.21.2'
47
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.16.0'
48
+ spec.add_development_dependency 'simplecov', '~> 0.22.0'
49
49
  spec.add_development_dependency 'webmock', '~> 3.18.1'
50
50
 
51
51
  spec.metadata['rubygems_mfa_required'] = 'true'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-15 00:00:00.000000000 Z
11
+ date: 2023-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.11.0
61
+ version: 3.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: 3.11.0
68
+ version: 3.12.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -100,28 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 2.13.2
103
+ version: 2.16.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 2.13.2
110
+ version: 2.16.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.21.2
117
+ version: 0.22.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.21.2
124
+ version: 0.22.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: webmock
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -167,8 +167,10 @@ files:
167
167
  - lib/regio/errors/forbidden.rb
168
168
  - lib/regio/errors/not_found.rb
169
169
  - lib/regio/errors/unprocessable.rb
170
+ - lib/regio/gazetteer.rb
170
171
  - lib/regio/geocode.rb
171
172
  - lib/regio/reverse_geocode.rb
173
+ - lib/regio/routing.rb
172
174
  - lib/regio/version.rb
173
175
  - regio.gemspec
174
176
  homepage: https://github.com/tab/regio