restcountry 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 85b6ae31bd4440491143a247296f9e77e9ec7d0a
4
+ data.tar.gz: a1c868ad14e3dc78e785c75b23f743b240582177
5
+ SHA512:
6
+ metadata.gz: 8446bdbaeee0a657919ead283fdf8297e345ecf4ac50c3d7027da3829e4cc10ab3a48627a41f9ca8c21f524085632327b19ba587df5fa122746b3985c27c480e
7
+ data.tar.gz: fe90e9e482bb7bbe16dc9002a875d87df42700b397f89eec072f69e543f29978bd437518dfb1a1f94cfc4955627efaf2198a3ca75f9e1d1ecab86f3afe87684c
@@ -0,0 +1,5 @@
1
+ require "restcountry/version"
2
+ require "restcountry/country"
3
+
4
+ module Restcountry
5
+ end
@@ -0,0 +1,65 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ API_URL = "https://restcountries.eu/rest/v1"
5
+
6
+ module Restcountry
7
+ class Country
8
+ attr_reader :name,
9
+ :capital,
10
+ :altSpellings,
11
+ :relevance,
12
+ :region,
13
+ :subregion,
14
+ :translations,
15
+ :population,
16
+ :latlng,
17
+ :demonym,
18
+ :area,
19
+ :gini,
20
+ :timezones,
21
+ :borders,
22
+ :nativeName,
23
+ :callingCodes,
24
+ :topLevelDomain,
25
+ :alpha2Code,
26
+ :alpha3Code,
27
+ :currencies,
28
+ :languages
29
+
30
+ def initialize(attributes)
31
+ @name = attributes["name"]
32
+ @capital = attributes["capital"]
33
+ @altSpellings = attributes["altSpellings"]
34
+ @relevance = attributes["relevance"]
35
+ @region = attributes["region"]
36
+ @subregion = attributes["subregion"]
37
+ @translations = attributes["translations"]
38
+ @population = attributes["population"]
39
+ @latlng = attributes["latlng"]
40
+ @demonym = attributes["demonym"]
41
+ @area = attributes["area"]
42
+ @gini = attributes["gini"]
43
+ @timezones = attributes["timezones"]
44
+ @borders = attributes["borders"]
45
+ @nativeName = attributes["nativeName"]
46
+ @callingCodes = attributes["callingCodes"]
47
+ @topLevelDomain = attributes["topLevelDomain"]
48
+ @alpha2Code = attributes["alpha2Code"]
49
+ @alpha3Code = attributes["alpha3Code"]
50
+ @currencies = attributes["currencies"]
51
+ @languages = attributes["languages"]
52
+ end
53
+
54
+ def self.find(name)
55
+ response = Faraday.get("#{API_URL}/name/#{name}")
56
+ response.success? ? new(JSON.parse(response.body).first) : []
57
+ end
58
+
59
+ def self.all
60
+ response = Faraday.get("#{API_URL}/all")
61
+ countries = response.success? ? JSON.parse(response.body) : []
62
+ countries.map { |attributes| new(attributes) }
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ module Restcountry
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: restcountry
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Davide Santangelo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Basic API implementation for REST Countries API http://restcountries.eu
84
+ email:
85
+ - davide.santangelo@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - lib/restcountry.rb
91
+ - lib/restcountry/country.rb
92
+ - lib/restcountry/version.rb
93
+ homepage: ''
94
+ licenses:
95
+ - MIT
96
+ metadata:
97
+ allowed_push_host: https://rubygems.org
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.4.6
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Gem to wrap BensBenzes.com API
118
+ test_files: []