restcountry 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a429265f869e9e6ffe13bd678e2ba0aff7c96ea
4
- data.tar.gz: 19a44f69d860716260bc18a861d1b539ba4a047a
3
+ metadata.gz: 5d3d0c000b23698040620e022dc74aac3ef9e92e
4
+ data.tar.gz: b7665617042e687ce1c30025d202ce0b715517c9
5
5
  SHA512:
6
- metadata.gz: 51715b81c443153436c10f5ff9bb17f4e5a7f0c31aa0e760d1f70bb219a761d20a270efc8be1625a4546ff4e3c339cc607322100b17e51f4aa5b09bc7da3d316
7
- data.tar.gz: a2831453ea9fb595dc9ea72607571368dd5d9050d582125aa6eca49de81e7681f2921ce37b53984c419a90831d74fd4d524efe8ef23ee13b7cff6de36dd8de57
6
+ metadata.gz: 63a06b0884b54aa9939b347d6c81db2ff18cfe83954ad6c7c7d8fccf70229880711f2944bf1792a291349d54062430ee3a44e6171625010e8d0bde9ccc273797
7
+ data.tar.gz: 3e73fab420dd9b1c52e1beec11a0b122eca9c6d2d9b857e2bb15b961f7888607051ca0b2c2440471dcb463c38964688dc1f2127699729af3f3c66a029119dee2
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in restcountry.gemspec
4
+ gemspec
@@ -0,0 +1,78 @@
1
+ # Restcountry
2
+
3
+ This is a sample gem to wrap REST Countries API http://restcountries.eu
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'restcountry'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install restcountry
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'restcountry'
25
+
26
+ # Find all countries
27
+ countries = Restcountry::Country.all
28
+
29
+ # Find a country by name
30
+ country = Restcountry::Country.find('italy')
31
+
32
+ # Access the country's attributes
33
+ country.capital
34
+ #=> Rome
35
+
36
+ country.region
37
+ #=> Europe
38
+
39
+ country.callingCodes
40
+ #=> "39"
41
+
42
+ # Find a country by capital
43
+ country = Restcountry::Country.find_by_capital('Rome')
44
+
45
+ country.name
46
+ #=> Italy
47
+
48
+ ```
49
+ ## Attributes
50
+
51
+ name,
52
+ capital,
53
+ altSpellings,
54
+ relevance,
55
+ region,
56
+ subregion,
57
+ translations,
58
+ population,
59
+ latlng,
60
+ demonym,
61
+ area,
62
+ gini,
63
+ timezones,
64
+ borders,
65
+ nativeName,
66
+ callingCodes,
67
+ topLevelDomain,
68
+ alpha2Code,
69
+ alpha3Code,
70
+ currencies,
71
+ languages
72
+
73
+ ## Credits
74
+ Many thanks to Fayder Florez(https://twitter.com/fayderflorez) for his implementation of the API.
75
+
76
+ ## License
77
+ The restcountry GEM is released under the MIT License.
78
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -73,6 +73,12 @@ module Restcountry
73
73
  countries.map { |attributes| new(attributes) }
74
74
  end
75
75
 
76
+ def self.find_by_lang(lang)
77
+ response = Faraday.get("#{API_URL}/lang/#{lang}")
78
+ countries = response.success? ? JSON.parse(response.body) : []
79
+ countries.map { |attributes| new(attributes) }
80
+ end
81
+
76
82
  def self.all
77
83
  response = Faraday.get("#{API_URL}/all")
78
84
  countries = response.success? ? JSON.parse(response.body) : []
@@ -1,3 +1,3 @@
1
1
  module Restcountry
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'restcountry/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "restcountry"
8
+ spec.version = Restcountry::VERSION
9
+ spec.authors = ["Davide Santangelo"]
10
+ spec.email = ["davide.santangelo@gmail.com"]
11
+
12
+ if spec.respond_to?(:metadata)
13
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
14
+ end
15
+
16
+ spec.summary = %q{Gem to wrap BensBenzes.com API}
17
+ spec.description = %q{Basic API implementation for REST Countries API http://restcountries.eu}
18
+ spec.homepage = "https://github.com/davidesantangelo/restcountry"
19
+ spec.license = "MIT"
20
+
21
+ spec.files = `git ls-files`.split($/)
22
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.8"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency 'rspec'
29
+
30
+ spec.add_dependency "faraday"
31
+ spec.add_dependency "json"
32
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Restcountry do
4
+ it 'has a version number' do
5
+ expect(Restcountry::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'get capital Rome from country Italy' do
9
+ country = Restcountry::Country.find('Italy')
10
+ expect(country.capital).to eq('Rome')
11
+ end
12
+
13
+ it 'get capital Madrid from country Spain' do
14
+ country = Restcountry::Country.find('Spain')
15
+ expect(country.capital).to eq('Madrid')
16
+ end
17
+
18
+ it 'get region Europe from country Ukraine' do
19
+ country = Restcountry::Country.find('Ukraine')
20
+ expect(country.region).to eq('Europe')
21
+ end
22
+
23
+ it 'get name Estonia from capital Tallinn' do
24
+ country = Restcountry::Country.find_by_capital('Tallinn')
25
+ expect(country.capital).to eq('Tallinn')
26
+ end
27
+
28
+ it 'get name from first country from language it' do
29
+ countries = Restcountry::Country.find_by_lang('it')
30
+ expect(countries.first.name).to eq('Italy')
31
+ end
32
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'restcountry'
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.2.0
4
+ version: 0.2.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-09 00:00:00.000000000 Z
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,14 +83,27 @@ dependencies:
83
83
  description: Basic API implementation for REST Countries API http://restcountries.eu
84
84
  email:
85
85
  - davide.santangelo@gmail.com
86
- executables: []
86
+ executables:
87
+ - console
88
+ - setup
87
89
  extensions: []
88
90
  extra_rdoc_files: []
89
91
  files:
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - ".travis.yml"
95
+ - Gemfile
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
90
100
  - lib/restcountry.rb
91
101
  - lib/restcountry/country.rb
92
102
  - lib/restcountry/version.rb
93
- homepage: ''
103
+ - restcountry.gemspec
104
+ - spec/restcountry_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage: https://github.com/davidesantangelo/restcountry
94
107
  licenses:
95
108
  - MIT
96
109
  metadata:
@@ -115,4 +128,6 @@ rubygems_version: 2.4.6
115
128
  signing_key:
116
129
  specification_version: 4
117
130
  summary: Gem to wrap BensBenzes.com API
118
- test_files: []
131
+ test_files:
132
+ - spec/restcountry_spec.rb
133
+ - spec/spec_helper.rb