regio 0.1.0 → 0.1.1

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: d23fef1e0c19ace88fc09034262df4f09ab9503ffad0d5052b34901e11012356
4
- data.tar.gz: 11ca77e05f124d409f53c987ea9bb47951661d48f2bd6a9a52ed9464019f85b6
3
+ metadata.gz: 503356adbc6069f1dfd5cc6c965aef1dcd3a85bc4cf2600551bf050d45af3900
4
+ data.tar.gz: 198f74020d181bbb107a00f25d933e99e54daceaa73726300f1fa76a8efb9df2
5
5
  SHA512:
6
- metadata.gz: f6987b0f7e02429e1bc4d035000dce128c1492f068a97f46e12594fbc90b8a89ceb1bd87d26d66ecf54222cf195cd63e8cdf051b9733afe93cd21b86068f51c0
7
- data.tar.gz: 58bad3e737e130eeba54d5e9fa14f99590e9eb0eef9f8d2b44cfe95e306830e5faeb8b0833db805904aa4ccf2f038b16ed54f3f8ada7ec49a796644bd5cecfc0
6
+ metadata.gz: f844a02af39777cf32a749b4b5df59a50a95a584359711535fcbf38b222b1e0a8a2f41530e2f1ee5718b5ca0868130c2da4c9bee718a1c84a1b5dab7c226c5c2
7
+ data.tar.gz: 709352194bbb875a6e2394fdb85c22fd6bf42c74c50cd06516cac6faa39c4ab99ae4a3c3f7d78572ca97405c6d5a0857c872949381bbd31ee256e2b9de8f4e6e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change log
2
2
 
3
+ ## v0.1.1 (9.10.2022)
4
+
5
+ * 1 major enhancement:
6
+ * Regio [geocode](https://api.regio.ee/documentation/#docs/geocode)
7
+ * Minor improvements
8
+
3
9
  ## v0.1.0 (8.10.2022)
4
10
 
5
11
  * 1 major enhancement:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- regio (0.1.0)
4
+ regio (0.1.1)
5
5
  httparty (~> 0.20.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Regio
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/regio.svg)](https://badge.fury.io/rb/regio)
4
+
3
5
  [Regio geocoding API](https://api.regio.ee/documentation/#docs/geocode) lets you search for addresses from complete Estonian address database.
4
6
 
5
7
  [Regio](https://www.regio.ee/en/)
@@ -9,7 +11,7 @@
9
11
  Add this line to your application's Gemfile:
10
12
 
11
13
  ```ruby
12
- gem 'regio'
14
+ gem 'regio', '~> 0.1.1'
13
15
  ```
14
16
 
15
17
  And then execute:
@@ -22,7 +24,33 @@ Or install it yourself as:
22
24
 
23
25
  ## Usage
24
26
 
25
- TODO: Write usage instructions here
27
+ Get your own API key
28
+
29
+ ```shell
30
+ REGIO_API_KEY=SECRET
31
+ ```
32
+
33
+ Use geocode class in your code
34
+
35
+ ```ruby
36
+ require 'regio'
37
+
38
+ class Geocoding
39
+
40
+ private
41
+
42
+ def results
43
+ @results ||= Regio::Geocode.new(options).results
44
+ end
45
+
46
+ def options
47
+ {
48
+ address: 'Tartu maantee 83',
49
+ country: 'ee'
50
+ }
51
+ end
52
+ end
53
+ ```
26
54
 
27
55
  ## Development
28
56
 
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Regio
4
+ class Failed < StandardError
5
+ def initialize(msg = 'Failed')
6
+ super
7
+ end
8
+
9
+ def http_status_code
10
+ 400
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Regio
4
+ class Forbidden < StandardError
5
+ def initialize(msg = 'Forbidden')
6
+ super
7
+ end
8
+
9
+ def http_status_code
10
+ 403
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Regio
4
+ class NotFound < StandardError
5
+ def initialize(msg = 'Not found')
6
+ super
7
+ end
8
+
9
+ def http_status_code
10
+ 403
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Regio
4
+ class Unprocessable < StandardError
5
+ def initialize(msg = 'Unprocessable')
6
+ super
7
+ end
8
+
9
+ def http_status_code
10
+ 422
11
+ end
12
+ end
13
+ end
data/lib/regio/geocode.rb CHANGED
@@ -27,6 +27,8 @@ module Regio
27
27
  end
28
28
 
29
29
  def results
30
+ raise Unprocessable, response[:message] if response[:message]
31
+
30
32
  response.merge(
31
33
  collection: response[:data]&.map { |result| transform(result) } || []
32
34
  )
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.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
data/lib/regio.rb CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  require 'regio/configuration'
4
4
  require 'regio/geocode'
5
+ require 'regio/errors/failed'
6
+ require 'regio/errors/forbidden'
7
+ require 'regio/errors/not_found'
8
+ require 'regio/errors/unprocessable'
5
9
  require 'regio/version'
6
10
 
7
11
  module Regio
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tab
@@ -162,6 +162,10 @@ files:
162
162
  - bin/setup
163
163
  - lib/regio.rb
164
164
  - lib/regio/configuration.rb
165
+ - lib/regio/errors/failed.rb
166
+ - lib/regio/errors/forbidden.rb
167
+ - lib/regio/errors/not_found.rb
168
+ - lib/regio/errors/unprocessable.rb
165
169
  - lib/regio/geocode.rb
166
170
  - lib/regio/version.rb
167
171
  - regio.gemspec