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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 721868f79209e1a64f3ebf97e3e55107f14b3f22
4
- data.tar.gz: f03f3ff568894e3d15b8da23d6f173cd0c85f6e5
3
+ metadata.gz: e7d334d4e378ba7a4ffdf7f3dd3b35b329a5b1db
4
+ data.tar.gz: cb6678bfa84b5192423e7cc0b377350387fd9794
5
5
  SHA512:
6
- metadata.gz: 1eef3bb6ce960793f03fde50e83e1d88d0944fe427344891e7867a35c1e5ca53924519db6254d6e292b467e4d6b63b9fb94a5410b2a14b8eaeb120dddabacbd3
7
- data.tar.gz: 4fe4766e0d039b3c22dcba3a5d89f24d1410a53deb4d98ebc0e75e7359c2142a5a6f93954d32b1c276f59f643d96c5dc9e3f142cca7af6a8ff3c7313bba77283
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.find('italy')
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(https://twitter.com/fayderflorez) for his implementation of the API.
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.
@@ -52,7 +52,7 @@ module Restcountry
52
52
  end
53
53
 
54
54
  def self.find(name)
55
- response = Faraday.get("#{API_URL}/name/#{name}")
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 = Faraday.get("#{API_URL}/currency/#{currency}")
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 = Faraday.get("#{API_URL}/capital/#{capital}")
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 = Faraday.get("#{API_URL}/region/#{region}")
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 = Faraday.get("#{API_URL}/lang/#{lang}")
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 = Faraday.get("#{API_URL}/callingcode/#{callingcode}")
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 = Faraday.get("#{API_URL}/all")
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
@@ -1,3 +1,3 @@
1
1
  module Restcountry
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
  require 'vcr'
3
3
 
4
4
  describe Restcountry do
5
-
6
5
  it 'get a response from api' do
7
6
  VCR.use_cassette 'find_by_name' do
8
7
  result = Restcountry::Country.all
@@ -0,0 +1,7 @@
1
+ # spec/support/vcr_setup.rb
2
+ VCR.configure do |c|
3
+ #the directory where your cassettes will be saved
4
+ c.cassette_library_dir = 'spec/vcr'
5
+ # your HTTP request service. You can also use fakeweb, webmock, and more
6
+ c.hook_into :typhoeus
7
+ end
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.0
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-14 00:00:00.000000000 Z
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
@@ -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
data/bin/setup DELETED
@@ -1,7 +0,0 @@
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