restcountry 0.5.1 → 0.5.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/lib/restcountry/country.rb +3 -3
- data/lib/restcountry/version.rb +1 -1
- data/spec/restcountry_spec.rb +7 -0
- 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: 0772e628d7e33207c1cfd7342b4e68a39ea85768
|
|
4
|
+
data.tar.gz: fabef54668f31e8473624fde5ab80b3b15de7202
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 815261d29b8a01fb33b892ca7c07a12e09373e7504c598dd18f807a004824e9c259383dffe1c8c4100b71e4f83ef2f77e05bce4b4da45abf635113940c0e413d
|
|
7
|
+
data.tar.gz: 11e634be63f78605b7239d1d7bb1e0196901639610bf1052d809ef091c52c714612aa109e6dedf563caf2c808f8dc532770c05363e2890d22bfc66d4e8ec5180
|
data/lib/restcountry/country.rb
CHANGED
|
@@ -53,7 +53,7 @@ module Restcountry
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def self.find(name, fulltext = false)
|
|
56
|
-
countries = get_response('name', name + "?fullText=#{fulltext
|
|
56
|
+
countries = get_response('name', name + "?fullText=#{fulltext}")
|
|
57
57
|
new(countries.first) unless countries.empty?
|
|
58
58
|
end
|
|
59
59
|
|
|
@@ -100,14 +100,14 @@ module Restcountry
|
|
|
100
100
|
countries = get_response('all')
|
|
101
101
|
countries.map { |attributes| new(attributes) }
|
|
102
102
|
end
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
private
|
|
105
105
|
|
|
106
106
|
private_class_method
|
|
107
107
|
def self.get_response(api, action = nil)
|
|
108
108
|
url = URI.parse(URI.encode("#{API_URL}#{api ? '/' + api : ''}/#{action}"))
|
|
109
109
|
response = Faraday.get(url)
|
|
110
|
-
|
|
110
|
+
response.success? ? JSON.parse(response.body) : []
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
end
|
data/lib/restcountry/version.rb
CHANGED
data/spec/restcountry_spec.rb
CHANGED
|
@@ -35,6 +35,13 @@ describe Restcountry do
|
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
it 'get capital London from country United Kingdom' do
|
|
39
|
+
VCR.use_cassette 'find' do
|
|
40
|
+
country = Restcountry::Country.find('United Kingdom')
|
|
41
|
+
expect(country.capital).to eq('London')
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
38
45
|
it 'get region Europe from country Ukraine' do
|
|
39
46
|
VCR.use_cassette 'find' do
|
|
40
47
|
country = Restcountry::Country.find('Ukraine')
|
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.5.
|
|
4
|
+
version: 0.5.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-
|
|
11
|
+
date: 2015-06-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|