restcountry 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/restcountry/country.rb +27 -24
- data/lib/restcountry/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 465f64d7d8a2e84d0945b7f9e82c9df1913d3a97
|
|
4
|
+
data.tar.gz: 0fdd40748dac35069919c0f1d64b55d66292f540
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8082395ad93696bc70036f65ef22e08f97c3419ebd9b827d75cd08e14d596919b7b6c4ff9916678aaf870067061c0d2afbcf259f247155fb752cdbb3597ef451
|
|
7
|
+
data.tar.gz: a0c87e0e049c536b7e76f6afd940c83689abc10fa519e72d8e897978271896172a453c71fd8a18330ee02e35f4a780089d0162235df4340fad7b389e2e79a0d6
|
data/README.md
CHANGED
data/lib/restcountry/country.rb
CHANGED
|
@@ -2,7 +2,7 @@ require 'faraday'
|
|
|
2
2
|
require 'json'
|
|
3
3
|
require 'uri'
|
|
4
4
|
|
|
5
|
-
API_URL =
|
|
5
|
+
API_URL = 'https://restcountries.eu/rest/v1'
|
|
6
6
|
|
|
7
7
|
module Restcountry
|
|
8
8
|
class Country
|
|
@@ -29,27 +29,27 @@ module Restcountry
|
|
|
29
29
|
:languages
|
|
30
30
|
|
|
31
31
|
def initialize(attributes)
|
|
32
|
-
@name = attributes[
|
|
33
|
-
@capital = attributes[
|
|
34
|
-
@altSpellings = attributes[
|
|
35
|
-
@relevance = attributes[
|
|
36
|
-
@region = attributes[
|
|
37
|
-
@subregion = attributes[
|
|
38
|
-
@translations = attributes[
|
|
39
|
-
@population = attributes[
|
|
40
|
-
@latlng = attributes[
|
|
41
|
-
@demonym = attributes[
|
|
42
|
-
@area = attributes[
|
|
43
|
-
@gini = attributes[
|
|
44
|
-
@timezones = attributes[
|
|
45
|
-
@borders = attributes[
|
|
46
|
-
@nativeName = attributes[
|
|
47
|
-
@callingCodes = attributes[
|
|
48
|
-
@topLevelDomain = attributes[
|
|
49
|
-
@alpha2Code = attributes[
|
|
50
|
-
@alpha3Code = attributes[
|
|
51
|
-
@currencies = attributes[
|
|
52
|
-
@languages = attributes[
|
|
32
|
+
@name = attributes['name']
|
|
33
|
+
@capital = attributes['capital']
|
|
34
|
+
@altSpellings = attributes['altSpellings']
|
|
35
|
+
@relevance = attributes['relevance']
|
|
36
|
+
@region = attributes['region']
|
|
37
|
+
@subregion = attributes['subregion']
|
|
38
|
+
@translations = attributes['translations']
|
|
39
|
+
@population = attributes['population']
|
|
40
|
+
@latlng = attributes['latlng']
|
|
41
|
+
@demonym = attributes['demonym']
|
|
42
|
+
@area = attributes['area']
|
|
43
|
+
@gini = attributes['gini']
|
|
44
|
+
@timezones = attributes['timezones']
|
|
45
|
+
@borders = attributes['borders']
|
|
46
|
+
@nativeName = attributes['nativeName']
|
|
47
|
+
@callingCodes = attributes['callingCodes']
|
|
48
|
+
@topLevelDomain = attributes['topLevelDomain']
|
|
49
|
+
@alpha2Code = attributes['alpha2Code']
|
|
50
|
+
@alpha3Code = attributes['alpha3Code']
|
|
51
|
+
@currencies = attributes['currencies']
|
|
52
|
+
@languages = attributes['languages']
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def self.find(name)
|
|
@@ -95,8 +95,11 @@ module Restcountry
|
|
|
95
95
|
countries = get_response('all')
|
|
96
96
|
countries.map { |attributes| new(attributes) }
|
|
97
97
|
end
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
|
|
99
|
+
private
|
|
100
|
+
|
|
101
|
+
private_class_method
|
|
102
|
+
def self.get_response(api, action = nil)
|
|
100
103
|
response = Faraday.get(URI.parse(URI.encode("#{API_URL}/#{api.to_s}/#{action}")))
|
|
101
104
|
return response.success? ? JSON.parse(response.body) : []
|
|
102
105
|
end
|
data/lib/restcountry/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: restcountry
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Davide Santangelo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-04-
|
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|