geoip2 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWZmYjQxOWM2N2QyNDhhMDYwOTBmZWRhZjA1NjVmZjdhM2EyOTEwNQ==
4
+ Nzc3MGQxNTg3MzM3OGM4MGI4MGUyOGE0M2M4NTIxNTViNmU4MTc4OA==
5
5
  data.tar.gz: !binary |-
6
- MWYyZTYyMjI1NmYzNDlkOTcxM2NiNzRiOGFhZTEyM2U5MWI3ZmRhYg==
6
+ ZThlN2U5OWRmZWY2YzUyOGFmNDBkMjViODZmNmY2MWJjNTIxNTdmZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDFlZDU3YWM0MjU5YTI4MGM5OGZhMmE4NDNkZjA2OWE3Y2YwNTdhODM3MjNi
10
- NGNjOTRkYmU1NWQzZmU4N2UyY2JhMjUxOTc4ODNhMDdmMDdjZDkzOWU0MTQ1
11
- NGZiMGEyMGY3OWQ1ZWZiMzZlNjliNTQxYzdjMjFhYWM5ZmY4Mzk=
9
+ YjIwNmNjNWI5ZjExNDdkYmM4Njk5OTYyY2IwYjUxZDYwZmQ2NzU1N2VlMDli
10
+ ZWU1MWQzMzk5OTg1YzU3N2MzNjEyZjk4N2U0MDhlNzA2YzU1Mzc3MmE0N2I2
11
+ MTdjMmFjMTFhMTE2MjA1YzQ1OGZkNGM2ZGQ2Y2Q3NzQ2ZjZlYTU=
12
12
  data.tar.gz: !binary |-
13
- Mjg0OWFlMjA3OGFlNDkyYTIyYTljMTAzZDcyMTU5ZmU5MjRlZDNmM2I3NjA3
14
- NmYxZGRkYmRkNmQ0MjEwMWY5ZDY2NTFlZTMzYTgxY2NlOWQxNDA4NzZmNjVl
15
- OTE4ZDlkYjlkNzQ5OGMxYzdhOGU0ZGJjZTRjNDVhMzk2YmNlNmM=
13
+ M2U1Mjc4OTFlMjEwMmRjOTIwYzljZDQxYTYzNjMwNzdhN2U4M2FkYWE0ODY1
14
+ YjE5NWJmNDRjNDVkODU4NDgxNzJjYmUxYzY0N2MxYjgzODQ5MzZlN2ZjYzJk
15
+ NjgwNzRmMzNjZDRhOWY4NjJiNWU3MGZlMGUyOTg3M2Q1MGE3Yjc=
@@ -1,10 +1,23 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
2
4
  rvm:
3
5
  - 1.9.3
4
6
  - 2.0.0
5
- - rbx-19mode
7
+ - 2.1.1
8
+ - 2.1.3
9
+ - 2.2.0
6
10
  - ruby-head
11
+ - rbx-2
7
12
  env:
8
13
  global:
9
14
  - secure: G4j3gaAkyJvTK4spfRaraF8u8B9MwXwpmPGO0VyLJawJlX8xsjvBG3Xl4MrMTkSw3ieV/+B3S4eq/EGGe6lO8ZqxqrSKIDXlGinZK9Z9K9+umOdPUOsu9jx49i5IMrJX7g5/n63L/9rKgoefpSeyOF2KLrImseu10xLWs5MYv/s=
10
15
  - secure: g3rD71ivDVfKya1NGGfUswZbk4kurHfyVLmZ3jAU1UEnkBF+rW8OGhhm34hIsKDTawEDTzkQao5Ek8YeQIvLT4WIsXWagbXPE/v4oq3ohDUoMndnrQywlG+msuNB9zIxCD1SAzeb88Lh4MGJPnod8cmtKVhmUjzhVKRL86QHRxE=
16
+ deploy:
17
+ provider: rubygems
18
+ api_key:
19
+ secure: OHCDhtvywzcjqhOqYEdNEvoPbW+D+shnPZlBq9jJi1Om69LEfGi4qBWPMUCDurKkguSi+GhwHNph2MU4Q9ucEYCUw4WmbTtGbnTmGPgetpiRExTh33h+FFHWCcsPfkUX53vwNf5wddA6WoHnopG3Y9geNEh4dqDVeACoLa6zOfk=
20
+ gem: geoip2
21
+ on:
22
+ branch: master
23
+ repo: YotpoLtd/geoip2
data/Gemfile CHANGED
@@ -1,16 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rake'
4
3
  gem 'yard'
5
4
  gem 'redcarpet'
6
-
7
- group :test do
8
- gem 'coveralls', :require => false
9
- gem 'rspec'
10
- gem 'simplecov', :require => false
11
- gem 'webmock'
12
- gem 'vcr'
13
- end
14
-
15
5
  # Specify your gem's dependencies in yotpo-api-connector.gemspec
16
- gemspec
6
+ gemspec
data/README.md CHANGED
@@ -6,6 +6,8 @@ Integration with MaxMind GeoIP2 API
6
6
 
7
7
  [![Build Status](https://travis-ci.org/YotpoLtd/geoip2.png?branch=master)](https://travis-ci.org/YotpoLtd/geoip2)
8
8
  [![Coverage Status](https://coveralls.io/repos/YotpoLtd/geoip2/badge.png)](https://coveralls.io/r/YotpoLtd/geoip2)
9
+ [![Dependency Status](https://gemnasium.com/YotpoLtd/geoip2.png)](https://gemnasium.com/YotpoLtd/geoip2)
10
+ [![Code Climate](https://codeclimate.com/github/YotpoLtd/geoip2.png)](https://codeclimate.com/github/YotpoLtd/geoip2)
9
11
 
10
12
  ## Installation
11
13
 
@@ -20,11 +20,15 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.3'
22
22
  spec.add_development_dependency 'rake'
23
- spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'coveralls', '~> 0.7.1'
24
+ spec.add_development_dependency 'rspec', '~> 3.0.0'
25
+ spec.add_development_dependency 'simplecov', '~> 0.9.0'
26
+ spec.add_development_dependency 'webmock', '~> 1.18.0'
27
+ spec.add_development_dependency 'vcr', '~> 2.9.2'
24
28
 
25
29
  spec.add_dependency 'faraday'
26
30
  spec.add_dependency 'typhoeus'
27
31
  spec.add_dependency 'faraday_middleware'
28
- spec.add_dependency 'rash'
29
32
  spec.add_dependency 'activesupport'
33
+ spec.add_dependency 'hashie'
30
34
  end
@@ -46,7 +46,7 @@ module Geoip2
46
46
  def client
47
47
  @client ||= Geoip2::Client.new({
48
48
  host: self.host || 'geoip.maxmind.com',
49
- base_path: self.base_path || '/geoip/v2.0',
49
+ base_path: self.base_path || '/geoip/v2.1',
50
50
  parallel_requests: self.parallel_requests || 5,
51
51
  user_id: self.user_id,
52
52
  license_key: self.license_key
@@ -54,15 +54,20 @@ module Geoip2
54
54
  end
55
55
 
56
56
  private
57
+ attr_reader :geoip_client
57
58
 
58
59
  #
59
60
  # executes any function on the Geoip2::Client instance
60
61
  #
61
62
  # @param args [*] any argument that we want to pass to the client function
62
63
  # @param block [Block] any block that is passed to the client function
64
+ def reset_client
65
+ @client = nil
66
+ end
67
+
63
68
  def method_missing(method_name, *args, &block)
64
69
  return super unless client.respond_to?(method_name)
65
70
  client.send(method_name, *args, &block)
66
71
  end
67
72
  end
68
- end
73
+ end
@@ -1,8 +1,8 @@
1
1
  module Geoip2
2
2
  module Api
3
3
  module City
4
- def city(ip)
5
- get("/city/#{ip}")
4
+ def city(ip, faraday_options = {})
5
+ get("/city/#{ip}", {}, faraday_options)
6
6
  end
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
1
  module Geoip2
2
2
  module Api
3
3
  module CityIspOrg
4
- def city_isp_org(ip)
5
- get("/city_isp_org/#{ip}")
4
+ def city_isp_org(ip, faraday_options = {})
5
+ get("/city_isp_org/#{ip}", {}, faraday_options)
6
6
  end
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
1
  module Geoip2
2
2
  module Api
3
3
  module Country
4
- def country(ip)
5
- get("/country/#{ip}")
4
+ def country(ip, faraday_options = {})
5
+ get("/country/#{ip}", {}, faraday_options)
6
6
  end
7
7
  end
8
8
  end
@@ -0,0 +1,9 @@
1
+ module Geoip2
2
+ module Api
3
+ module Insights
4
+ def insights(ip, faraday_options = {})
5
+ get("/insights/#{ip}", {}, faraday_options)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,8 +1,8 @@
1
1
  module Geoip2
2
2
  module Api
3
3
  module Omni
4
- def omni(ip)
5
- get("/omni/#{ip}")
4
+ def omni(ip, faraday_options = {})
5
+ get("/omni/#{ip}", {}, faraday_options)
6
6
  end
7
7
  end
8
8
  end
@@ -1,3 +1,4 @@
1
+ require 'geoip2/api/insights'
1
2
  require 'geoip2/api/city'
2
3
  require 'geoip2/api/city_isp_org'
3
4
  require 'geoip2/api/country'
@@ -11,9 +12,10 @@ require 'faraday_middleware'
11
12
  module Geoip2
12
13
  class Client
13
14
 
14
- include Geoip2::Api::City
15
- include Geoip2::Api::Country
16
15
  include Geoip2::Api::CityIspOrg
16
+ include Geoip2::Api::Insights
17
+ include Geoip2::Api::Country
18
+ include Geoip2::Api::City
17
19
  include Geoip2::Api::Omni
18
20
 
19
21
  #
@@ -33,10 +35,10 @@ module Geoip2
33
35
  #
34
36
  # @param url [String] the relative path in the Geoip2 API
35
37
  # @param params [Hash] the url params that should be passed in the request
36
- def get(url, params = {})
38
+ def get(url, params = {}, faraday_options = {})
37
39
  params = params.inject({}){|memo,(k,v)| memo[k.to_s] = v; memo}
38
40
  preform(@base_path + url, :get, params: params) do
39
- return connection.get(@base_path + url, params).body
41
+ return connection(faraday_options).get(@base_path + url, params).body
40
42
  end
41
43
  end
42
44
 
@@ -70,23 +72,28 @@ module Geoip2
70
72
 
71
73
  #
72
74
  # @return an instance of Faraday initialized with all that this gem needs
73
- def connection
74
- @connection ||= Faraday.new(url: @base_url, parallel_manager: Typhoeus::Hydra.new(max_concurrency: @parallel_requests)) do |conn|
75
+ def connection(faraday_options = {})
76
+ if @faraday_options != faraday_options
77
+ options = {url: @base_url, parallel_manager: Typhoeus::Hydra.new(max_concurrency: @parallel_requests)}.merge(faraday_options)
78
+ @faraday_options = faraday_options
79
+ @connection = Faraday.new(options) do |conn|
75
80
 
76
- conn.request :basic_auth, @user, @password
81
+ conn.request :basic_auth, @user, @password
77
82
 
78
- # Set the response to be rashified
79
- conn.response :rashify
83
+ # Set the response to be mashified
84
+ conn.response :mashify
80
85
 
81
- # Setting request and response to use JSON/XML
82
- conn.request :json
83
- conn.response :json
86
+ # Setting request and response to use JSON/XML
87
+ conn.request :json
88
+ conn.response :json
84
89
 
85
- # Set to use instrumentals to get time logs
86
- conn.use :instrumentation
90
+ # Set to use instrumentals to get time logs
91
+ conn.use :instrumentation
87
92
 
88
- conn.adapter :typhoeus
93
+ conn.adapter :typhoeus
94
+ end
89
95
  end
96
+ @connection
90
97
  end
91
98
  end
92
- end
99
+ end
@@ -1,3 +1,3 @@
1
1
  module Geoip2
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -1,38 +1,36 @@
1
1
  require 'helper'
2
2
 
3
3
  describe Geoip2::Api::Country do
4
- describe '#country' do
5
- before(:all) do
4
+ describe '#country', version: "2.0" do
5
+ let!(:response) do
6
6
  VCR.use_cassette('get_country') do
7
- @response = Geoip2.country('62.219.147.28')
7
+ Geoip2.country('62.219.147.28')
8
8
  end
9
9
  end
10
- subject { @response }
11
- it { should be_a ::Hashie::Rash }
12
- it { should respond_to :country }
13
- it { should respond_to :continent }
14
- it { should respond_to :registered_country }
15
- it { should respond_to :maxmind }
16
- it { should respond_to :traits }
17
-
18
- it /have an iso_code in country/ do
19
- expect(subject.country).to include :iso_code
20
- expect(subject.country.iso_code).to eq 'IL'
10
+
11
+ [:country, :continent, :registered_country, :maxmind, :traits].each do |met|
12
+ it "response to #{met}" do
13
+ expect(response.respond_to?(met)).to eql(true)
14
+ end
21
15
  end
22
16
 
23
- it /has a names array in country/ do
24
- expect(subject.country).to include :names
25
- expect(subject.country.names).to be_a ::Hashie::Rash
17
+ it "have an iso_code in country" do
18
+ expect(response.country).to include :iso_code
19
+ expect(response.country.iso_code).to eq 'IL'
26
20
  end
27
21
 
28
- it /has a 'en' name and it's value should be Israel/ do
29
- expect(subject.country.names.en).to eq 'Israel'
22
+ it "has a names array in country" do
23
+ expect(response.country).to include :names
24
+ expect(response.country.names).to be_a ::Hashie::Mash
30
25
  end
31
26
 
32
- it /has a queries_remaining value in maxmind/ do
33
- expect(subject.maxmind).to include :queries_remaining
34
- expect(subject.maxmind.queries_remaining).to eq 995
27
+ it "has a 'en' name and it's value should be Israel" do
28
+ expect(response.country.names.en).to eq 'Israel'
35
29
  end
36
30
 
31
+ it "has a queries_remaining value in maxmind" do
32
+ expect(response.maxmind).to include :queries_remaining
33
+ expect(response.maxmind.queries_remaining).to eq 995
34
+ end
37
35
  end
38
- end
36
+ end
@@ -0,0 +1,40 @@
1
+ require 'helper'
2
+ describe Geoip2::Api::Insights, version: "2.1" do
3
+ describe '#insights'do
4
+ let!(:response) do
5
+ VCR.use_cassette('insights') do
6
+ Geoip2.insights('0.0.0.0')
7
+ end
8
+ end
9
+
10
+ [:country, :continent, :registered_country, :maxmind, :traits].each do |met|
11
+ it "response to #{met}" do
12
+ expect(response.respond_to?(met)).to eql(true)
13
+ end
14
+ end
15
+
16
+ it "response is Rash" do
17
+ expect(response).to be_a_kind_of(::Hashie::Mash)
18
+ end
19
+
20
+ it "have an iso_code in country" do
21
+ expect(response.country).to include :iso_code
22
+ expect(response.country.iso_code).to eq 'LV'
23
+ end
24
+
25
+ it "has a names array in country" do
26
+ expect(response.country).to include :names
27
+ expect(response.country.names).to be_a ::Hashie::Mash
28
+ end
29
+
30
+ it "has a 'en' name and it's value should be Israel" do
31
+ expect(response.country.names.en).to eq 'Latvia'
32
+ end
33
+
34
+ it "has a queries_remaining value in maxmind" do
35
+ expect(response.maxmind).to include :queries_remaining
36
+ expect(response.maxmind.queries_remaining).to eq 149995
37
+ end
38
+
39
+ end
40
+ end
@@ -44,4 +44,33 @@ http_interactions:
44
44
  ImlwX2FkZHJlc3MiOiI2Mi4yMTkuMTQ3LjI4In19
45
45
  http_version:
46
46
  recorded_at: Thu, 24 Oct 2013 06:56:47 GMT
47
- recorded_with: VCR 2.6.0
47
+ - request:
48
+ method: get
49
+ uri: https://geoip.maxmind.com/geoip/v2.1/country/62.219.147.28
50
+ body:
51
+ encoding: US-ASCII
52
+ string: ''
53
+ headers:
54
+ User-Agent:
55
+ - Faraday v0.9.0
56
+ Authorization:
57
+ - Basic Og==
58
+ response:
59
+ status:
60
+ code: 401
61
+ message: Unauthorized
62
+ headers:
63
+ Www-Authenticate:
64
+ - Basic realm="geoip2"
65
+ Content-Length:
66
+ - '96'
67
+ Content-Type:
68
+ - application/vnd.maxmind.com-error+json; charset=UTF-8; version=2.1
69
+ Date:
70
+ - Fri, 22 Aug 2014 14:11:19 GMT
71
+ body:
72
+ encoding: UTF-8
73
+ string: '{"error":"A user ID and license key are required to use this service","code":"USER_ID_REQUIRED"}'
74
+ http_version:
75
+ recorded_at: Fri, 22 Aug 2014 14:11:19 GMT
76
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,115 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://geoip.maxmind.com/geoip/v2.1/insights/0.0.0.0
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Authorization:
13
+ - Basic OTIxMDk6V2FPZk1ScGc5RlU0
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Vary:
20
+ - Accept
21
+ Content-Length:
22
+ - '1266'
23
+ Content-Type:
24
+ - application/vnd.maxmind.com-insights+json; charset=UTF-8; version=2.1
25
+ Date:
26
+ - Fri, 15 Aug 2014 10:56:59 GMT
27
+ body:
28
+ encoding: ASCII-8BIT
29
+ string: !binary |-
30
+ eyJjb3VudHJ5Ijp7Imlzb19jb2RlIjoiTFYiLCJuYW1lcyI6eyJwdC1CUiI6
31
+ IkxldMO0bmlhIiwiZXMiOiJMZXRvbmlhIiwicnUiOiLQm9Cw0YLQstC40Y8i
32
+ LCJlbiI6IkxhdHZpYSIsInpoLUNOIjoi5ouJ6ISx57u05LqaIiwiZnIiOiJM
33
+ ZXR0b25pZSIsImRlIjoiTGV0dGxhbmQiLCJqYSI6IuODqeODiOODk+OCouWF
34
+ seWSjOWbvSJ9LCJjb25maWRlbmNlIjo5NiwiZ2VvbmFtZV9pZCI6NDU4MjU4
35
+ fSwibG9jYXRpb24iOnsibG9uZ2l0dWRlIjoyNC4xLCJsYXRpdHVkZSI6NTYu
36
+ OTUsInRpbWVfem9uZSI6IkV1cm9wZS9SaWdhIiwiYWNjdXJhY3lfcmFkaXVz
37
+ IjozfSwic3ViZGl2aXNpb25zIjpbeyJpc29fY29kZSI6IlJJWCIsIm5hbWVz
38
+ Ijp7ImVuIjoiUmlnYSIsInJ1Ijoi0KDQuNCz0LAifSwiY29uZmlkZW5jZSI6
39
+ NzQsImdlb25hbWVfaWQiOjQ1NjE3M31dLCJjaXR5Ijp7Im5hbWVzIjp7InB0
40
+ LUJSIjoiUmlnYSIsImVzIjoiUmlnYSIsInJ1Ijoi0KDQuNCz0LAiLCJlbiI6
41
+ IlJpZ2EiLCJ6aC1DTiI6IumHjOWKoCIsImZyIjoiUmlnYSIsImRlIjoiUmln
42
+ YSIsImphIjoi44Oq44KsIn0sImNvbmZpZGVuY2UiOjc0LCJnZW9uYW1lX2lk
43
+ Ijo0NTYxNzJ9LCJjb250aW5lbnQiOnsibmFtZXMiOnsicHQtQlIiOiJFdXJv
44
+ cGEiLCJlcyI6IkV1cm9wYSIsInJ1Ijoi0JXQstGA0L7Qv9CwIiwiZW4iOiJF
45
+ dXJvcGUiLCJ6aC1DTiI6Iuasp+a0siIsImZyIjoiRXVyb3BlIiwiZGUiOiJF
46
+ dXJvcGEiLCJqYSI6IuODqOODvOODreODg+ODkSJ9LCJnZW9uYW1lX2lkIjo2
47
+ MjU1MTQ4LCJjb2RlIjoiRVUifSwibWF4bWluZCI6eyJxdWVyaWVzX3JlbWFp
48
+ bmluZyI6MTQ5OTk1fSwicmVnaXN0ZXJlZF9jb3VudHJ5Ijp7Imlzb19jb2Rl
49
+ IjoiTFYiLCJuYW1lcyI6eyJwdC1CUiI6IkxldMO0bmlhIiwiZXMiOiJMZXRv
50
+ bmlhIiwicnUiOiLQm9Cw0YLQstC40Y8iLCJlbiI6IkxhdHZpYSIsInpoLUNO
51
+ Ijoi5ouJ6ISx57u05LqaIiwiZnIiOiJMZXR0b25pZSIsImRlIjoiTGV0dGxh
52
+ bmQiLCJqYSI6IuODqeODiOODk+OCouWFseWSjOWbvSJ9LCJnZW9uYW1lX2lk
53
+ Ijo0NTgyNTh9LCJ0cmFpdHMiOnsidXNlcl90eXBlIjoicmVzaWRlbnRpYWwi
54
+ LCJkb21haW4iOiJiYWx0aWNvbS5sdiIsImF1dG9ub21vdXNfc3lzdGVtX251
55
+ bWJlciI6MjQ2NTEsImlwX2FkZHJlc3MiOiI4My45OS4xNTkuMTkzIiwib3Jn
56
+ YW5pemF0aW9uIjoiQmFsdGljb20gSlNDIiwiaXNwIjoiSnNjIEJhbHRpY29t
57
+ IiwiYXV0b25vbW91c19zeXN0ZW1fb3JnYW5pemF0aW9uIjoiSlNDIEJBTFRJ
58
+ Q09NIn19
59
+ http_version:
60
+ recorded_at: Fri, 15 Aug 2014 10:56:59 GMT
61
+ - request:
62
+ method: get
63
+ uri: https://geoip.maxmind.com/geoip/v2.0/insights/0.0.0.0
64
+ body:
65
+ encoding: US-ASCII
66
+ string: ''
67
+ headers:
68
+ User-Agent:
69
+ - Faraday v0.9.0
70
+ Authorization:
71
+ - Basic Og==
72
+ response:
73
+ status:
74
+ code: 404
75
+ message: Not Found
76
+ headers:
77
+ Content-Type:
78
+ - text/plain
79
+ Transfer-Encoding:
80
+ - chunked
81
+ Date:
82
+ - Fri, 22 Aug 2014 13:56:43 GMT
83
+ body:
84
+ encoding: UTF-8
85
+ string: Not Found
86
+ http_version:
87
+ recorded_at: Fri, 22 Aug 2014 13:56:43 GMT
88
+ - request:
89
+ method: get
90
+ uri: https://geoip.maxmind.com/geoip/v2.0/insights/0.0.0.0
91
+ body:
92
+ encoding: US-ASCII
93
+ string: ''
94
+ headers:
95
+ User-Agent:
96
+ - Faraday v0.9.0
97
+ Authorization:
98
+ - Basic Og==
99
+ response:
100
+ status:
101
+ code: 404
102
+ message: Not Found
103
+ headers:
104
+ Content-Type:
105
+ - text/plain
106
+ Transfer-Encoding:
107
+ - chunked
108
+ Date:
109
+ - Fri, 22 Aug 2014 14:02:25 GMT
110
+ body:
111
+ encoding: UTF-8
112
+ string: Not Found
113
+ http_version:
114
+ recorded_at: Fri, 22 Aug 2014 14:02:25 GMT
115
+ recorded_with: VCR 2.9.2
@@ -5,7 +5,7 @@ require 'webmock/rspec'
5
5
  require 'geoip2'
6
6
  require 'vcr'
7
7
 
8
-
8
+ Dir["./spec/support/**/*.rb"].sort.each { |f| require f}
9
9
 
10
10
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
11
11
  SimpleCov::Formatter::HTMLFormatter,
@@ -19,17 +19,4 @@ VCR.configure do |c|
19
19
  c.ignore_hosts 'coveralls.io'
20
20
  c.cassette_library_dir = 'spec/cassettes'
21
21
  c.default_cassette_options = { :record => :new_episodes }
22
- end
23
-
24
- RSpec.configure do |config|
25
- config.expect_with :rspec do |c|
26
- c.syntax = :expect
27
- end
28
-
29
- config.before(:all) do
30
- Geoip2.configure do |conf|
31
- conf.license_key = ENV['LICENSE_KEY']
32
- conf.user_id = ENV['USER_ID']
33
- end
34
- end
35
22
  end
@@ -0,0 +1,12 @@
1
+ RSpec.configure do |config|
2
+ config.before do |example|
3
+ Geoip2.configure do |conf|
4
+ Geoip2.send(:reset_client)
5
+ conf.license_key = ENV['LICENSE_KEY']
6
+ if example.metadata[:version]
7
+ conf.base_path = "/geoip/v#{example.metadata[:version]}"
8
+ end
9
+ conf.user_id = ENV['USER_ID']
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoip2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Shub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-24 00:00:00.000000000 Z
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,19 +39,75 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: coveralls
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.7.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.7.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.9.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 1.18.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 1.18.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 2.9.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 2.9.2
55
111
  - !ruby/object:Gem::Dependency
56
112
  name: faraday
57
113
  requirement: !ruby/object:Gem::Requirement
@@ -95,7 +151,7 @@ dependencies:
95
151
  - !ruby/object:Gem::Version
96
152
  version: '0'
97
153
  - !ruby/object:Gem::Dependency
98
- name: rash
154
+ name: activesupport
99
155
  requirement: !ruby/object:Gem::Requirement
100
156
  requirements:
101
157
  - - ! '>='
@@ -109,7 +165,7 @@ dependencies:
109
165
  - !ruby/object:Gem::Version
110
166
  version: '0'
111
167
  - !ruby/object:Gem::Dependency
112
- name: activesupport
168
+ name: hashie
113
169
  requirement: !ruby/object:Gem::Requirement
114
170
  requirements:
115
171
  - - ! '>='
@@ -142,13 +198,17 @@ files:
142
198
  - lib/geoip2/api/city.rb
143
199
  - lib/geoip2/api/city_isp_org.rb
144
200
  - lib/geoip2/api/country.rb
201
+ - lib/geoip2/api/insights.rb
145
202
  - lib/geoip2/api/omni.rb
146
203
  - lib/geoip2/client.rb
147
204
  - lib/geoip2/version.rb
148
205
  - spec/api/country_spec.rb
206
+ - spec/api/insights_spec.rb
149
207
  - spec/cassettes/get_country.yml
208
+ - spec/cassettes/insights.yml
150
209
  - spec/geoip2_spec.rb
151
210
  - spec/helper.rb
211
+ - spec/support/helper.rb
152
212
  homepage: https://github.com/YotpoLtd/geoip2
153
213
  licenses:
154
214
  - GPLv2
@@ -169,13 +229,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
229
  version: '0'
170
230
  requirements: []
171
231
  rubyforge_project:
172
- rubygems_version: 2.1.9
232
+ rubygems_version: 2.4.5
173
233
  signing_key:
174
234
  specification_version: 4
175
235
  summary: Integration with MaxMind GeoIP2 API
176
236
  test_files:
177
237
  - spec/api/country_spec.rb
238
+ - spec/api/insights_spec.rb
178
239
  - spec/cassettes/get_country.yml
240
+ - spec/cassettes/insights.yml
179
241
  - spec/geoip2_spec.rb
180
242
  - spec/helper.rb
181
- has_rdoc:
243
+ - spec/support/helper.rb