geo_names 1.0.1 → 1.0.2

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: c4fc212d53ae7ed43e5b991e84a46986d1a73e59e74118e680f6c20efa43e2e1
4
- data.tar.gz: 595a438c2f6760106fbf6c91e5480545c89351cc31c68ccc1b4b774836038238
3
+ metadata.gz: db31a6de689635c0e398b2f48e13a9aebedc742c768ee0049f8a094105db05e2
4
+ data.tar.gz: 945daed55cf7d9c317681a92979fa24ab4d01b64da1f58bc4ba94423abfd6919
5
5
  SHA512:
6
- metadata.gz: b5595d1f499f541f00720d5092dc92458f88b485929dbf2e88815711518f653bf32f139795c22b4ce6ba918889e2d1317929296d79ee13ef64fcf59d69a5cc95
7
- data.tar.gz: e78c32d505796774acdf32e00d82978f5021b5584f18da6e5c916ebc7ad742a198d7451b6b19cf6e37d65a96ed5f6fd2824a18449eb3a1abbcc3f901e62d4317
6
+ metadata.gz: cbd5be23ddda55ef52611525ac73868c3b3a149028b8704c4c87da3b6405a458f303956cf65976904e9c41e4577940ba5041cbaf51b5a4db229d7f74fee47adc
7
+ data.tar.gz: 3918a96712e5dc8fcde9091fdbd8fb6f1defcae577bc36618d315565bd9371f5386a582b03c9e32760f41873dde3ee3162fb7014a3e4f96c934929587aa17e5a
@@ -6,4 +6,4 @@ rvm:
6
6
  - 2.4.5
7
7
  - 2.5.3
8
8
  - ruby-head
9
- before_install: gem install bundler -v 1.16.5
9
+ before_install: gem install bundler
@@ -4,9 +4,14 @@
4
4
 
5
5
  - ...
6
6
 
7
+ ## 1.0.2
8
+
9
+ - GeoNames API changed the behavior and now we need to rescue RestClient::Unauthorized exception. [Pr #4](https://github.com/WaKeMaTTa/geo_names/pull/4)
10
+ - Fixed missing `GeoNames::DatabaseTimeoutError` class and fixed a typo in the class `GeoNames::NoResultFoundError`. [Pr #3](https://github.com/WaKeMaTTa/geo_names/pull/3) (thanks to @dgilperez)
11
+
7
12
  ## 1.0.1
8
13
 
9
- - A typo in `GeoNames.configuration` -> `username`.
14
+ - A typo in `GeoNames.configuration` -> `username`. [commit 8d8d7e3](https://github.com/WaKeMaTTa/geo_names/commit/8d8d7e3329cc4ca08209d3d99f1263c665d51135)
10
15
 
11
16
  ## 1.0.0
12
17
 
data/README.md CHANGED
@@ -49,11 +49,107 @@ end
49
49
 
50
50
  ### Searching
51
51
 
52
+ #### How to search?
53
+
54
+ First you need a `Hash` with the criteria that you want to search.
55
+
56
+ ```ruby
57
+ # example of criteria
58
+ criteria = {
59
+ country_code: 'US',
60
+ name: 'New York',
61
+ featureClass: %w[P S],
62
+ maxRows: 1,
63
+ style: 'short'
64
+ }
65
+ ```
66
+
67
+ Then you can search
68
+ ```ruby
69
+ result = GeoNames::Search.search(criteria)
70
+ ```
71
+
72
+ The `result` it will be a `Hash` if was successful, like this one:
73
+ ```ruby
74
+ { "totalResultsCount" => 1360,
75
+ "geonames" => [
76
+ { "lng" => "-74.00597",
77
+ "geonameId" => 5128581,
78
+ "countryCode" => "US",
79
+ "name" => "New York",
80
+ "toponymName" => "New York City",
81
+ "lat" => "40.71427",
82
+ "fcl" => "P",
83
+ "fcode" => "PPL"
84
+ }
85
+ ]
86
+ }
87
+ ```
88
+
89
+ Or if something was wrong it will raise an error of this list:
90
+ ```ruby
91
+ GeoNames::AuthorizationExceptionError
92
+ GeoNames::DatabaseTimeoutError
93
+ GeoNames::MissingOrInvalidParameterError
94
+ GeoNames::RecordDoesNotExistError
95
+ GeoNames::OtherError
96
+ GeoNames::NoResultFoundError
97
+ GeoNames::PostalCodeNotFoundError
98
+ GeoNames::DailyLimitOfCreditsExceededError
99
+ GeoNames::HourlyLimitOfCreditsExceededError
100
+ GeoNames::WeeklyLimitOfCreditsExceededError
101
+ GeoNames::InvalidInputError
102
+ GeoNames::ServerOverloadedExceptionError
103
+ GeoNames::ServiceNotImplementedError
104
+ GeoNames::RadiusTooLargeError
105
+ GeoNames::MaxRowsTooLargeError
106
+ GeoNames::StatusCodeNotImplementedError
107
+ ```
108
+
109
+ #### Search engines available
110
+
52
111
  ```ruby
53
- result = GeoNames::Search.search
54
- # it returns a hash of the parsed JSON result
55
- # or
56
- # raise an exception if the parsed JSON contains an error status_code
112
+ GeoNames::Address
113
+ GeoNames::Astergdem
114
+ GeoNames::Children
115
+ GeoNames::Cities
116
+ GeoNames::Configuration
117
+ GeoNames::Contains
118
+ GeoNames::CountryCode
119
+ GeoNames::CountryInfo
120
+ GeoNames::CountrySubdivision
121
+ GeoNames::Earthquakes
122
+ GeoNames::ExtendedFindNearby
123
+ GeoNames::FindNearByWeather
124
+ GeoNames::FindNearby
125
+ GeoNames::FindNearbyPOIsOSM
126
+ GeoNames::FindNearbyPlaceName
127
+ GeoNames::FindNearbyPostalCodes
128
+ GeoNames::FindNearbyStreets
129
+ GeoNames::FindNearbyStreetsOSM
130
+ GeoNames::FindNearbyWikipedia
131
+ GeoNames::FindNearestAddress
132
+ GeoNames::FindNearestIntersection
133
+ GeoNames::FindNearestIntersectionOSM
134
+ GeoNames::GeoCodeAddress
135
+ GeoNames::Get
136
+ GeoNames::Gtopo30
137
+ GeoNames::Hierarchy
138
+ GeoNames::Neighbourhood
139
+ GeoNames::Neighbours
140
+ GeoNames::Ocean
141
+ GeoNames::PostalCodeCountryInfo
142
+ GeoNames::PostalCodeLookup
143
+ GeoNames::PostalCodeSearch
144
+ GeoNames::Search
145
+ GeoNames::Siblings
146
+ GeoNames::Srtm1
147
+ GeoNames::Srtm3
148
+ GeoNames::Timezone
149
+ GeoNames::Weather
150
+ GeoNames::WeatherIcao
151
+ GeoNames::WikipediaBoundingBox
152
+ GeoNames::WikipediaSearch
57
153
  ```
58
154
 
59
155
  ## Development
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_runtime_dependency 'rest-client', '~> 2'
27
27
 
28
- spec.add_development_dependency 'bundler', '~> 1.16'
28
+ spec.add_development_dependency 'bundler'
29
29
  spec.add_development_dependency 'gem-release', '~> 2.0'
30
30
  spec.add_development_dependency 'pry-byebug', '~> 3.6'
31
31
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -31,6 +31,8 @@ module GeoNames
31
31
 
32
32
  def make_request
33
33
  RestClient.get(url, params: params)
34
+ rescue RestClient::Unauthorized => e
35
+ e.response.to_s
34
36
  end
35
37
 
36
38
  def parse(json_string)
@@ -60,12 +62,10 @@ module GeoNames
60
62
  raise(OtherError, message)
61
63
  when 13
62
64
  raise(DatabaseTimeoutError, message)
63
- when 13
64
- raise(DatabaseTimeoutError, message)
65
65
  when 14
66
66
  raise(MissingOrInvalidParameterError, message)
67
67
  when 15
68
- raise(NoResultFoundrError, message)
68
+ raise(NoResultFoundError, message)
69
69
  when 16
70
70
  raise(DuplicateExceptionError, message)
71
71
  when 17
@@ -92,19 +92,20 @@ module GeoNames
92
92
  end
93
93
  end
94
94
 
95
- class AuthorizationExceptionError < StandardError; end
96
- class MissingOrInvalidParameterError < StandardError; end
97
- class RecordDoesNotExistError < StandardError; end
98
- class OtherError < StandardError; end
99
- class NoResultFoundrError < StandardError; end
100
- class PostalCodeNotFoundError < StandardError; end
101
- class DailyLimitOfCreditsExceededError < StandardError; end
102
- class HourlyLimitOfCreditsExceededError < StandardError; end
103
- class WeeklyLimitOfCreditsExceededError < StandardError; end
104
- class InvalidInputError < StandardError; end
105
- class ServerOverloadedExceptionError < StandardError; end
106
- class ServiceNotImplementedError < StandardError; end
107
- class RadiusTooLargeError < StandardError; end
108
- class MaxRowsTooLargeError < StandardError; end
109
- class StatusCodeNotImplementedError < StandardError; end
95
+ class AuthorizationExceptionError < StandardError; end
96
+ class DatabaseTimeoutError < StandardError; end
97
+ class MissingOrInvalidParameterError < StandardError; end
98
+ class RecordDoesNotExistError < StandardError; end
99
+ class OtherError < StandardError; end
100
+ class NoResultFoundError < StandardError; end
101
+ class PostalCodeNotFoundError < StandardError; end
102
+ class DailyLimitOfCreditsExceededError < StandardError; end
103
+ class HourlyLimitOfCreditsExceededError < StandardError; end
104
+ class WeeklyLimitOfCreditsExceededError < StandardError; end
105
+ class InvalidInputError < StandardError; end
106
+ class ServerOverloadedExceptionError < StandardError; end
107
+ class ServiceNotImplementedError < StandardError; end
108
+ class RadiusTooLargeError < StandardError; end
109
+ class MaxRowsTooLargeError < StandardError; end
110
+ class StatusCodeNotImplementedError < StandardError; end
110
111
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GeoNames
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geo_names
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohamed Ziata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-20 00:00:00.000000000 Z
11
+ date: 2019-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.16'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.16'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: gem-release
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -175,8 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  requirements: []
178
- rubyforge_project:
179
- rubygems_version: 2.7.7
178
+ rubygems_version: 3.0.2
180
179
  signing_key:
181
180
  specification_version: 4
182
181
  summary: An API wrapper for GeoNames API's