restcountry 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/restcountry/country.rb +17 -0
- 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: 1a429265f869e9e6ffe13bd678e2ba0aff7c96ea
|
4
|
+
data.tar.gz: 19a44f69d860716260bc18a861d1b539ba4a047a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51715b81c443153436c10f5ff9bb17f4e5a7f0c31aa0e760d1f70bb219a761d20a270efc8be1625a4546ff4e3c339cc607322100b17e51f4aa5b09bc7da3d316
|
7
|
+
data.tar.gz: a2831453ea9fb595dc9ea72607571368dd5d9050d582125aa6eca49de81e7681f2921ce37b53984c419a90831d74fd4d524efe8ef23ee13b7cff6de36dd8de57
|
data/lib/restcountry/country.rb
CHANGED
@@ -56,6 +56,23 @@ module Restcountry
|
|
56
56
|
response.success? ? new(JSON.parse(response.body).first) : []
|
57
57
|
end
|
58
58
|
|
59
|
+
def self.find_by_currency(currency)
|
60
|
+
response = Faraday.get("#{API_URL}/currency/#{currency}")
|
61
|
+
countries = response.success? ? JSON.parse(response.body) : []
|
62
|
+
countries.map { |attributes| new(attributes) }
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.find_by_capital(capital)
|
66
|
+
response = Faraday.get("#{API_URL}/capital/#{capital}")
|
67
|
+
response.success? ? new(JSON.parse(response.body).first) : []
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.find_by_region(region)
|
71
|
+
response = Faraday.get("#{API_URL}/region/#{region}")
|
72
|
+
countries = response.success? ? JSON.parse(response.body) : []
|
73
|
+
countries.map { |attributes| new(attributes) }
|
74
|
+
end
|
75
|
+
|
59
76
|
def self.all
|
60
77
|
response = Faraday.get("#{API_URL}/all")
|
61
78
|
countries = response.success? ? JSON.parse(response.body) : []
|
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
|
+
version: 0.2.0
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|