restcountry 0.4.1 → 0.4.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
  SHA1:
3
- metadata.gz: 31b72f9b6341b901e0dcdfef43644f7402a7c21b
4
- data.tar.gz: 44baa3a54106c04ed6b7255e1cb38c0690032d8d
3
+ metadata.gz: 465f64d7d8a2e84d0945b7f9e82c9df1913d3a97
4
+ data.tar.gz: 0fdd40748dac35069919c0f1d64b55d66292f540
5
5
  SHA512:
6
- metadata.gz: 0df55880c0e479810d11e850a8443b6d095c8293a71ed2adbc96136d9acc1baecdad051ef957808cdc8c56a2f447506e0745f4e3056a89958212f77290c58937
7
- data.tar.gz: 12a2197b1d3f77651d7b2e90f852a9aaa2faa78963a8b4290cc000bd9092f5e87ba083a3b772f6d304f2db2ba0f77dccd34ff0642456f19ede884a7a51da9de3
6
+ metadata.gz: 8082395ad93696bc70036f65ef22e08f97c3419ebd9b827d75cd08e14d596919b7b6c4ff9916678aaf870067061c0d2afbcf259f247155fb752cdbb3597ef451
7
+ data.tar.gz: a0c87e0e049c536b7e76f6afd940c83689abc10fa519e72d8e897978271896172a453c71fd8a18330ee02e35f4a780089d0162235df4340fad7b389e2e79a0d6
data/README.md CHANGED
@@ -45,6 +45,10 @@ country = Restcountry::Country.find_by_capital('Rome')
45
45
  country.name
46
46
  #=> Italy
47
47
 
48
+ countries = Restcountry::Country.find_by_lang('it')
49
+ countries.first
50
+ #=> Italy
51
+
48
52
  ```
49
53
  ## Attributes
50
54
 
@@ -2,7 +2,7 @@ require 'faraday'
2
2
  require 'json'
3
3
  require 'uri'
4
4
 
5
- API_URL = "https://restcountries.eu/rest/v1"
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["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"]
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
- private
99
- def self.get_response(api, action=nil)
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
@@ -1,3 +1,3 @@
1
1
  module Restcountry
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
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.1
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-16 00:00:00.000000000 Z
11
+ date: 2015-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler