restcountry 0.3.0 → 0.3.1
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 +2 -2
- data/lib/restcountry/country.rb +11 -7
- data/lib/restcountry/version.rb +1 -1
- data/spec/restcountry_spec.rb +0 -1
- data/spec/support/vcr_setup.rb +7 -0
- metadata +5 -7
- data/bin/console +0 -14
- data/bin/setup +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7d334d4e378ba7a4ffdf7f3dd3b35b329a5b1db
|
4
|
+
data.tar.gz: cb6678bfa84b5192423e7cc0b377350387fd9794
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bb19216eef2e41243af8a499cb7205d98ed200e9c8ab83c307b6dc23a7c01355fadcaf3d83b5c39efb4a11f9e6ec36db1b3ffdb18e0b7be6ee09859eb4f2b36
|
7
|
+
data.tar.gz: 49c68cc58e80ba987e96281ea6324684e375b4c0dd89afbddc5ee9de4f51b5b483efe42fef5b62be1594e20c0ae7dd4f8ecb5337f93b50ebeedc2ff0f175b828
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ require 'restcountry'
|
|
27
27
|
countries = Restcountry::Country.all
|
28
28
|
|
29
29
|
# Find a country by name
|
30
|
-
country = Restcountry::Country.
|
30
|
+
country = Restcountry::Country.find_by_name('italy')
|
31
31
|
|
32
32
|
# Access the country's attributes
|
33
33
|
country.capital
|
@@ -71,7 +71,7 @@ currencies,
|
|
71
71
|
languages
|
72
72
|
|
73
73
|
## Credits
|
74
|
-
Many thanks to Fayder Florez
|
74
|
+
Many thanks to Fayder Florez for his implementation of the API.
|
75
75
|
|
76
76
|
## License
|
77
77
|
The restcountry GEM is released under the MIT License.
|
data/lib/restcountry/country.rb
CHANGED
@@ -52,7 +52,7 @@ module Restcountry
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def self.find(name)
|
55
|
-
response =
|
55
|
+
response = get_response('name', name)
|
56
56
|
response.success? ? new(JSON.parse(response.body).first) : []
|
57
57
|
end
|
58
58
|
|
@@ -61,38 +61,42 @@ module Restcountry
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def self.find_by_currency(currency)
|
64
|
-
response =
|
64
|
+
response = get_response('currency', currency)
|
65
65
|
countries = response.success? ? JSON.parse(response.body) : []
|
66
66
|
countries.map { |attributes| new(attributes) }
|
67
67
|
end
|
68
68
|
|
69
69
|
def self.find_by_capital(capital)
|
70
|
-
response =
|
70
|
+
response = get_response('capital', capital)
|
71
71
|
response.success? ? new(JSON.parse(response.body).first) : []
|
72
72
|
end
|
73
73
|
|
74
74
|
def self.find_by_region(region)
|
75
|
-
response =
|
75
|
+
response = get_response('region', region)
|
76
76
|
countries = response.success? ? JSON.parse(response.body) : []
|
77
77
|
countries.map { |attributes| new(attributes) }
|
78
78
|
end
|
79
79
|
|
80
80
|
def self.find_by_lang(lang)
|
81
|
-
response =
|
81
|
+
response = get_response('lang', lang)
|
82
82
|
countries = response.success? ? JSON.parse(response.body) : []
|
83
83
|
countries.map { |attributes| new(attributes) }
|
84
84
|
end
|
85
85
|
|
86
86
|
def self.find_by_callingcode(callingcode)
|
87
|
-
response =
|
87
|
+
response = get_response('callingcode', callingcode)
|
88
88
|
countries = response.success? ? JSON.parse(response.body) : []
|
89
89
|
countries.map { |attributes| new(attributes) }
|
90
90
|
end
|
91
91
|
|
92
92
|
def self.all
|
93
|
-
response =
|
93
|
+
response = get_response('all')
|
94
94
|
countries = response.success? ? JSON.parse(response.body) : []
|
95
95
|
countries.map { |attributes| new(attributes) }
|
96
96
|
end
|
97
|
+
private
|
98
|
+
def self.get_response(api, action=nil)
|
99
|
+
Faraday.get("#{API_URL}/#{api.to_s}/#{action}")
|
100
|
+
end
|
97
101
|
end
|
98
102
|
end
|
data/lib/restcountry/version.rb
CHANGED
data/spec/restcountry_spec.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.3.
|
4
|
+
version: 0.3.1
|
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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -111,9 +111,7 @@ dependencies:
|
|
111
111
|
description: Basic API implementation for REST Countries API http://restcountries.eu
|
112
112
|
email:
|
113
113
|
- davide.santangelo@gmail.com
|
114
|
-
executables:
|
115
|
-
- console
|
116
|
-
- setup
|
114
|
+
executables: []
|
117
115
|
extensions: []
|
118
116
|
extra_rdoc_files: []
|
119
117
|
files:
|
@@ -123,14 +121,13 @@ files:
|
|
123
121
|
- Gemfile
|
124
122
|
- README.md
|
125
123
|
- Rakefile
|
126
|
-
- bin/console
|
127
|
-
- bin/setup
|
128
124
|
- lib/restcountry.rb
|
129
125
|
- lib/restcountry/country.rb
|
130
126
|
- lib/restcountry/version.rb
|
131
127
|
- restcountry.gemspec
|
132
128
|
- spec/restcountry_spec.rb
|
133
129
|
- spec/spec_helper.rb
|
130
|
+
- spec/support/vcr_setup.rb
|
134
131
|
homepage: https://github.com/davidesantangelo/restcountry
|
135
132
|
licenses:
|
136
133
|
- MIT
|
@@ -159,3 +156,4 @@ summary: Gem to wrap BensBenzes.com API
|
|
159
156
|
test_files:
|
160
157
|
- spec/restcountry_spec.rb
|
161
158
|
- spec/spec_helper.rb
|
159
|
+
- spec/support/vcr_setup.rb
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "restcountry"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|