quova 0.0.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.
- data/.gitignore +5 -0
- data/Gemfile +2 -0
- data/LICENSE +20 -0
- data/README.md +70 -0
- data/Rakefile +2 -0
- data/lib/quova.rb +1 -0
- data/lib/quova/qod.rb +154 -0
- data/lib/quova/version.rb +3 -0
- data/quova.gemspec +27 -0
- data/spec/qod_spec.rb +361 -0
- data/spec/spec_helper.rb +4 -0
- metadata +100 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Chris Corbyn
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# A Quova API Client for Ruby
|
2
|
+
|
3
|
+
This gem provides a thin wrapper around Quova's GeoIP web service. It is
|
4
|
+
extremely simple to use, accepting IP addresses as input and returning plain
|
5
|
+
ruby Hash objects in response. Data-types will be cast where appropriate (e.g.
|
6
|
+
`:longitude` and `:latitude` are provided as `Float` types).
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
gem install quova
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
Currently, support is only provided for the QOD (Query on Demand) REST API.
|
15
|
+
|
16
|
+
Usage is simple:
|
17
|
+
|
18
|
+
qod = Quova::QOD.new(:id => "your-id", :password => "your-password")
|
19
|
+
info = qod.info("4.2.2.2")
|
20
|
+
|
21
|
+
Or you can use the alternative syntax:
|
22
|
+
|
23
|
+
info = qod["4.2.2.2"]
|
24
|
+
|
25
|
+
This returns a Hash with the following elements:
|
26
|
+
|
27
|
+
:ip_address => String
|
28
|
+
:ip_type => String
|
29
|
+
:anonymizer_status => String
|
30
|
+
:network_tld => String
|
31
|
+
:network_sld => String
|
32
|
+
:aol => Boolean
|
33
|
+
:carrier => String
|
34
|
+
:asn => String
|
35
|
+
:connection => String
|
36
|
+
:line_speed => String
|
37
|
+
:routing_type => String
|
38
|
+
:continent_name => String
|
39
|
+
:country_code => String
|
40
|
+
:country_confidence => Integer
|
41
|
+
:region_name => String
|
42
|
+
:region_confidence => Integer
|
43
|
+
:state_name => String
|
44
|
+
:state_confidence => Integer
|
45
|
+
:city_name => String
|
46
|
+
:city_confidence => Integer
|
47
|
+
:postal_code => String
|
48
|
+
:time_zone => String
|
49
|
+
:area_code => String
|
50
|
+
:longitude => Float
|
51
|
+
:latitude => Float
|
52
|
+
:dma_id => Integer
|
53
|
+
:msa_id => Integer
|
54
|
+
|
55
|
+
For any field that was returned blank, or missing, `nil` will be present in the
|
56
|
+
result Hash.
|
57
|
+
|
58
|
+
## Resources
|
59
|
+
|
60
|
+
- [Source](https://github.com/d11wtq/quova)
|
61
|
+
- [Issues](https://github.com/d11wtq/quova/issues)
|
62
|
+
|
63
|
+
## Disclaimer
|
64
|
+
|
65
|
+
The official maintainer of this Gem, Chris Corbyn (@d11wtq) is no way
|
66
|
+
affiliated with, nor representative of Quova. This code is provided free of
|
67
|
+
charge and shall be used at your own risk.
|
68
|
+
|
69
|
+
|
70
|
+
Copyright (C) 2011 Chris Corbyn
|
data/Rakefile
ADDED
data/lib/quova.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'quova/qod'
|
data/lib/quova/qod.rb
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'virtus'
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
module Quova
|
6
|
+
|
7
|
+
# Interface to the Quova QOD (Query On Demand) service
|
8
|
+
#
|
9
|
+
# @api public
|
10
|
+
class QOD
|
11
|
+
|
12
|
+
# Initialize the QOD client with Quova API credentials
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# Quova::QOD.new(:id => "account-id", :password => "account-password")
|
16
|
+
#
|
17
|
+
# @param [Hash] options
|
18
|
+
# Hash containing :id and :password for Quova
|
19
|
+
#
|
20
|
+
# @api public
|
21
|
+
def initialize(options)
|
22
|
+
base = "https://%s:%s@webservices.quova.com/ipinfo"
|
23
|
+
@resource = RestClient::Resource.new(base % [options[:id], options[:password]])
|
24
|
+
end
|
25
|
+
|
26
|
+
# Query the API for a given IP address
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# qod.info("4.2.2.2") # => { ... }
|
30
|
+
#
|
31
|
+
# @param [String, IPAddr, #to_s] ip
|
32
|
+
# The IP address to look up
|
33
|
+
#
|
34
|
+
# @return [Hash]
|
35
|
+
# A Hash containing a key for each element. Provided fields:
|
36
|
+
#
|
37
|
+
# :ip_address
|
38
|
+
# :ip_type
|
39
|
+
# :anonymizer_status
|
40
|
+
# :network_tld
|
41
|
+
# :network_sld
|
42
|
+
# :aol
|
43
|
+
# :carrier
|
44
|
+
# :asn
|
45
|
+
# :connection
|
46
|
+
# :line_speed
|
47
|
+
# :routing_type
|
48
|
+
# :continent_name
|
49
|
+
# :country_code
|
50
|
+
# :country_confidence
|
51
|
+
# :region_name
|
52
|
+
# :region_confidence
|
53
|
+
# :state_name
|
54
|
+
# :state_confidence
|
55
|
+
# :city_name
|
56
|
+
# :city_confidence
|
57
|
+
# :postal_code
|
58
|
+
# :time_zone
|
59
|
+
# :area_code
|
60
|
+
# :longitude
|
61
|
+
# :latitude
|
62
|
+
# :dma_id
|
63
|
+
# :msa_id
|
64
|
+
#
|
65
|
+
# @api public
|
66
|
+
def info(ip)
|
67
|
+
parse_xml(@resource[ip.to_s].get.body)
|
68
|
+
end
|
69
|
+
|
70
|
+
alias_method :[], :info
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
# Map XML to a meaningful Hash
|
75
|
+
#
|
76
|
+
# @api private
|
77
|
+
def parse_xml(xml)
|
78
|
+
paths = {
|
79
|
+
:ip_address => "IPAddress",
|
80
|
+
:ip_type => "IPType",
|
81
|
+
:anonymizer_status => "AnonymizerStatus",
|
82
|
+
:network_tld => "Domain TopLevel",
|
83
|
+
:network_sld => "Domain SecondLevel",
|
84
|
+
:aol => "AOL",
|
85
|
+
:carrier => "Carrier",
|
86
|
+
:asn => "ASN",
|
87
|
+
:connection => "Connection",
|
88
|
+
:line_speed => "LineSpeed",
|
89
|
+
:routing_type => "IPRoutingType",
|
90
|
+
:continent_name => "Continent Name",
|
91
|
+
:country_code => "Country Name",
|
92
|
+
:country_confidence => "Country Confidence",
|
93
|
+
:region_name => "Region Name",
|
94
|
+
:region_confidence => "Region Confidence",
|
95
|
+
:state_name => "State Name",
|
96
|
+
:state_confidence => "State Confidence",
|
97
|
+
:city_name => "City Name",
|
98
|
+
:city_confidence => "City Confidence",
|
99
|
+
:postal_code => "City PostalCode",
|
100
|
+
:time_zone => "City TimeZone",
|
101
|
+
:area_code => "City AreaCode",
|
102
|
+
:longitude => "Coordinates Longitude",
|
103
|
+
:latitude => "Coordinates Latitude",
|
104
|
+
:dma_id => "DMA Id",
|
105
|
+
:msa_id => "MSA Id"
|
106
|
+
}
|
107
|
+
|
108
|
+
doc = Nokogiri::XML(xml)
|
109
|
+
result = Result.new
|
110
|
+
|
111
|
+
paths.each_pair do |attr, selector|
|
112
|
+
node = doc.at_css(selector)
|
113
|
+
result.attribute_set(attr, node.text) if node && node.text != ""
|
114
|
+
end
|
115
|
+
|
116
|
+
result.attributes
|
117
|
+
end
|
118
|
+
|
119
|
+
# Internally maps Strings from the API to the correct types
|
120
|
+
#
|
121
|
+
# @api private
|
122
|
+
class Result
|
123
|
+
include Virtus
|
124
|
+
|
125
|
+
attribute :ip_address, String
|
126
|
+
attribute :ip_type, String
|
127
|
+
attribute :anonymizer_status, String
|
128
|
+
attribute :network_tld, String
|
129
|
+
attribute :network_sld, String
|
130
|
+
attribute :aol, Boolean
|
131
|
+
attribute :carrier, String
|
132
|
+
attribute :asn, String
|
133
|
+
attribute :connection, String
|
134
|
+
attribute :line_speed, String
|
135
|
+
attribute :routing_type, String
|
136
|
+
attribute :continent_name, String
|
137
|
+
attribute :country_code, String
|
138
|
+
attribute :country_confidence, Integer
|
139
|
+
attribute :region_name, String
|
140
|
+
attribute :region_confidence, Integer
|
141
|
+
attribute :state_name, String
|
142
|
+
attribute :state_confidence, Integer
|
143
|
+
attribute :city_name, String
|
144
|
+
attribute :city_confidence, Integer
|
145
|
+
attribute :postal_code, String
|
146
|
+
attribute :time_zone, String
|
147
|
+
attribute :area_code, String
|
148
|
+
attribute :longitude, Float
|
149
|
+
attribute :latitude, Float
|
150
|
+
attribute :dma_id, Integer
|
151
|
+
attribute :msa_id, Integer
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
data/quova.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "quova/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "quova"
|
7
|
+
s.version = Quova::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Flippa.com Pty. Ltd."]
|
10
|
+
s.email = ["chris@flippa.com"]
|
11
|
+
s.homepage = "http://flippa.com/"
|
12
|
+
s.summary = %q{Quova GeoIP Client for Ruby}
|
13
|
+
s.description = %q{Provides a high-level client for Quova's On-Demand REST API}
|
14
|
+
|
15
|
+
s.rubyforge_project = "quova"
|
16
|
+
|
17
|
+
s.add_dependency "rest-client", "~> 1.6.3"
|
18
|
+
s.add_dependency "virtus"
|
19
|
+
s.add_dependency "nokogiri", "~> 1.5.0"
|
20
|
+
|
21
|
+
s.add_development_dependency "rspec", "~> 2.6"
|
22
|
+
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
|
+
s.require_paths = ["lib"]
|
27
|
+
end
|
data/spec/qod_spec.rb
ADDED
@@ -0,0 +1,361 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Quova::QOD do
|
4
|
+
describe "#initialize" do
|
5
|
+
it "prepares a RestClient with the given credentials" do
|
6
|
+
RestClient::Resource.should_receive(:new).with("https://an-id:a-password@webservices.quova.com/ipinfo")
|
7
|
+
Quova::QOD.new(:id => "an-id", :password => "a-password")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#info" do
|
12
|
+
before(:each) do
|
13
|
+
@resource = double()
|
14
|
+
@response = double()
|
15
|
+
@resource.stub(:[]) { @resource }
|
16
|
+
@resource.stub(:get) { @response }
|
17
|
+
@response.stub(:body) { "" }
|
18
|
+
RestClient::Resource.stub(:new) { @resource }
|
19
|
+
@qod = Quova::QOD.new(:id => "id", :password => "password")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "queries the API for the given IP" do
|
23
|
+
@resource.should_receive(:[]).with("4.2.2.2") { @resource }
|
24
|
+
@resource.should_receive(:get) { @response }
|
25
|
+
|
26
|
+
@qod.info("4.2.2.2")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "is aliased by []" do
|
30
|
+
@resource.should_receive(:[]).with("4.2.2.2") { @resource }
|
31
|
+
@resource.should_receive(:get) { @response }
|
32
|
+
|
33
|
+
@qod["4.2.2.2"].should == @qod.info("4.2.2.2")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "maps <IPAddress/> to :ip_address" do
|
37
|
+
@response.stub(:body) do
|
38
|
+
<<-XML
|
39
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
40
|
+
<IPAddress>4.2.2.2</IPAddress>
|
41
|
+
</IpInfo>
|
42
|
+
XML
|
43
|
+
end
|
44
|
+
|
45
|
+
@qod.info("4.2.2.2")[:ip_address].should == "4.2.2.2"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "maps <IPType/> to :ip_type" do
|
49
|
+
@response.stub(:body) do
|
50
|
+
<<-XML
|
51
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
52
|
+
<IPType>Mapped</IPType>
|
53
|
+
</IpInfo>
|
54
|
+
XML
|
55
|
+
end
|
56
|
+
|
57
|
+
@qod.info("4.2.2.2")[:ip_type].should == "Mapped"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "maps <AnonymizerStatus/> to :anonymizer_status" do
|
61
|
+
@response.stub(:body) do
|
62
|
+
<<-XML
|
63
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
64
|
+
<AnonymizerStatus>SUSPECT</AnonymizerStatus>
|
65
|
+
</IpInfo>
|
66
|
+
XML
|
67
|
+
end
|
68
|
+
|
69
|
+
@qod.info("4.2.2.2")[:anonymizer_status].should == "SUSPECT"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "maps <Network><Domain><TopLevel/></Domain></Network> to :network_tld" do
|
73
|
+
@response.stub(:body) do
|
74
|
+
<<-XML
|
75
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
76
|
+
<Network><Domain><TopLevel>.net.au</TopLevel></Domain></Network>
|
77
|
+
</IpInfo>
|
78
|
+
XML
|
79
|
+
end
|
80
|
+
|
81
|
+
@qod.info("4.2.2.2")[:network_tld].should == ".net.au"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "maps <Network><Domain><SecondLevel/></Domain></Network> to :network_sld" do
|
85
|
+
@response.stub(:body) do
|
86
|
+
<<-XML
|
87
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
88
|
+
<Network><Domain><SecondLevel>iinet</SecondLevel></Domain></Network>
|
89
|
+
</IpInfo>
|
90
|
+
XML
|
91
|
+
end
|
92
|
+
|
93
|
+
@qod.info("4.2.2.2")[:network_sld].should == "iinet"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "maps <Network><AOL/></Network> to :aol" do
|
97
|
+
@response.stub(:body) do
|
98
|
+
<<-XML
|
99
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
100
|
+
<Network><AOL>0</AOL></Network>
|
101
|
+
</IpInfo>
|
102
|
+
XML
|
103
|
+
end
|
104
|
+
|
105
|
+
@qod.info("4.2.2.2")[:aol].should be(false)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "maps <Network><Carrier/></Network> to :carrier" do
|
109
|
+
@response.stub(:body) do
|
110
|
+
<<-XML
|
111
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
112
|
+
<Network><Carrier>iinet limited</Carrier></Network>
|
113
|
+
</IpInfo>
|
114
|
+
XML
|
115
|
+
end
|
116
|
+
|
117
|
+
@qod.info("4.2.2.2")[:carrier].should == "iinet limited"
|
118
|
+
end
|
119
|
+
|
120
|
+
it "maps <Network><ASN/></Network> to :asn" do
|
121
|
+
@response.stub(:body) do
|
122
|
+
<<-XML
|
123
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
124
|
+
<Network><ASN>3356</ASN></Network>
|
125
|
+
</IpInfo>
|
126
|
+
XML
|
127
|
+
end
|
128
|
+
|
129
|
+
@qod.info("4.2.2.2")[:asn].should == "3356"
|
130
|
+
end
|
131
|
+
|
132
|
+
it "maps <Network><Connection/></Network> to :connection" do
|
133
|
+
@response.stub(:body) do
|
134
|
+
<<-XML
|
135
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
136
|
+
<Network><Connection>dsl</Connection></Network>
|
137
|
+
</IpInfo>
|
138
|
+
XML
|
139
|
+
end
|
140
|
+
|
141
|
+
@qod.info("4.2.2.2")[:connection].should == "dsl"
|
142
|
+
end
|
143
|
+
|
144
|
+
it "maps <Network><LineSpeed/></Network> to :line_speed" do
|
145
|
+
@response.stub(:body) do
|
146
|
+
<<-XML
|
147
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
148
|
+
<Network><LineSpeed>medium</LineSpeed></Network>
|
149
|
+
</IpInfo>
|
150
|
+
XML
|
151
|
+
end
|
152
|
+
|
153
|
+
@qod.info("4.2.2.2")[:line_speed].should == "medium"
|
154
|
+
end
|
155
|
+
|
156
|
+
it "maps <Network><IPRoutingType/></Network> to :routing_type" do
|
157
|
+
@response.stub(:body) do
|
158
|
+
<<-XML
|
159
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
160
|
+
<Network><IPRoutingType>fixed</IPRoutingType></Network>
|
161
|
+
</IpInfo>
|
162
|
+
XML
|
163
|
+
end
|
164
|
+
|
165
|
+
@qod.info("4.2.2.2")[:routing_type].should == "fixed"
|
166
|
+
end
|
167
|
+
|
168
|
+
it "maps <Location><Continent><Name/></Continent></Location> to :continent_name" do
|
169
|
+
@response.stub(:body) do
|
170
|
+
<<-XML
|
171
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
172
|
+
<Location><Continent><Name>oceania</Name></Continent></Location>
|
173
|
+
</IpInfo>
|
174
|
+
XML
|
175
|
+
end
|
176
|
+
|
177
|
+
@qod.info("4.2.2.2")[:continent_name].should == "oceania"
|
178
|
+
end
|
179
|
+
|
180
|
+
it "maps <Location><Country><Name/></Country></Location> to :country_code" do
|
181
|
+
# I think this is actually a bug in the Quova API, but it is how it is
|
182
|
+
@response.stub(:body) do
|
183
|
+
<<-XML
|
184
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
185
|
+
<Location><Country><Name>au</Name></Country></Location>
|
186
|
+
</IpInfo>
|
187
|
+
XML
|
188
|
+
end
|
189
|
+
|
190
|
+
@qod.info("4.2.2.2")[:country_code].should == "au"
|
191
|
+
end
|
192
|
+
|
193
|
+
it "maps <Location><Country><Confidence/></Country></Location> to :country_confidence" do
|
194
|
+
@response.stub(:body) do
|
195
|
+
<<-XML
|
196
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
197
|
+
<Location><Country><Confidence>94</Confidence></Country></Location>
|
198
|
+
</IpInfo>
|
199
|
+
XML
|
200
|
+
end
|
201
|
+
|
202
|
+
@qod.info("4.2.2.2")[:country_confidence].should == 94
|
203
|
+
end
|
204
|
+
|
205
|
+
it "maps <Location><Region><Name/></Region></Location> to :region_name" do
|
206
|
+
@response.stub(:body) do
|
207
|
+
<<-XML
|
208
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
209
|
+
<Location><Region><Name>test</Name></Region></Location>
|
210
|
+
</IpInfo>
|
211
|
+
XML
|
212
|
+
end
|
213
|
+
|
214
|
+
@qod.info("4.2.2.2")[:region_name].should == "test"
|
215
|
+
end
|
216
|
+
|
217
|
+
it "maps <Location><Region><Confidence/></Region></Location> to :region_confidence" do
|
218
|
+
@response.stub(:body) do
|
219
|
+
<<-XML
|
220
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
221
|
+
<Location><Region><Confidence>43</Confidence></Region></Location>
|
222
|
+
</IpInfo>
|
223
|
+
XML
|
224
|
+
end
|
225
|
+
|
226
|
+
@qod.info("4.2.2.2")[:region_confidence].should == 43
|
227
|
+
end
|
228
|
+
|
229
|
+
it "maps <Location><State><Name/></State></Location> to :state_name" do
|
230
|
+
@response.stub(:body) do
|
231
|
+
<<-XML
|
232
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
233
|
+
<Location><State><Name>victoria</Name></State></Location>
|
234
|
+
</IpInfo>
|
235
|
+
XML
|
236
|
+
end
|
237
|
+
|
238
|
+
@qod.info("4.2.2.2")[:state_name].should == "victoria"
|
239
|
+
end
|
240
|
+
|
241
|
+
it "maps <Location><State><Confidence/></State></Location> to :state_confidence" do
|
242
|
+
@response.stub(:body) do
|
243
|
+
<<-XML
|
244
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
245
|
+
<Location><State><Confidence>86</Confidence></State></Location>
|
246
|
+
</IpInfo>
|
247
|
+
XML
|
248
|
+
end
|
249
|
+
|
250
|
+
@qod.info("4.2.2.2")[:state_confidence].should == 86
|
251
|
+
end
|
252
|
+
|
253
|
+
it "maps <Location><City><Name/></City></Location> to :city_name" do
|
254
|
+
@response.stub(:body) do
|
255
|
+
<<-XML
|
256
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
257
|
+
<Location><City><Name>melbourne</City></State></Location>
|
258
|
+
</IpInfo>
|
259
|
+
XML
|
260
|
+
end
|
261
|
+
|
262
|
+
@qod.info("4.2.2.2")[:city_name].should == "melbourne"
|
263
|
+
end
|
264
|
+
|
265
|
+
it "maps <Location><City><Confidence/></City></Location> to :city_confidence" do
|
266
|
+
@response.stub(:body) do
|
267
|
+
<<-XML
|
268
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
269
|
+
<Location><City><Confidence>51</Confidence></City></Location>
|
270
|
+
</IpInfo>
|
271
|
+
XML
|
272
|
+
end
|
273
|
+
|
274
|
+
@qod.info("4.2.2.2")[:city_confidence].should == 51
|
275
|
+
end
|
276
|
+
|
277
|
+
it "maps <Location><City><PostalCode/></City></Location> to :postal_code" do
|
278
|
+
@response.stub(:body) do
|
279
|
+
<<-XML
|
280
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
281
|
+
<Location><City><PostalCode>3000</PostalCode></City></Location>
|
282
|
+
</IpInfo>
|
283
|
+
XML
|
284
|
+
end
|
285
|
+
|
286
|
+
@qod.info("4.2.2.2")[:postal_code].should == "3000"
|
287
|
+
end
|
288
|
+
|
289
|
+
it "maps <Location><City><TimeZone/></City></Location> to :time_zone" do
|
290
|
+
@response.stub(:body) do
|
291
|
+
<<-XML
|
292
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
293
|
+
<Location><City><TimeZone>+10.0</TimeZone></City></Location>
|
294
|
+
</IpInfo>
|
295
|
+
XML
|
296
|
+
end
|
297
|
+
|
298
|
+
@qod.info("4.2.2.2")[:time_zone].should == "+10.0"
|
299
|
+
end
|
300
|
+
|
301
|
+
it "maps <Location><City><AreaCode/></City></Location> to :area_code" do
|
302
|
+
@response.stub(:body) do
|
303
|
+
<<-XML
|
304
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
305
|
+
<Location><City><AreaCode>03</AreaCode></City></Location>
|
306
|
+
</IpInfo>
|
307
|
+
XML
|
308
|
+
end
|
309
|
+
|
310
|
+
@qod.info("4.2.2.2")[:area_code].should == "03"
|
311
|
+
end
|
312
|
+
|
313
|
+
it "maps <Location><Coordinates><Longitude/></Coordinates></Location> to :longitude" do
|
314
|
+
@response.stub(:body) do
|
315
|
+
<<-XML
|
316
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
317
|
+
<Location><Coordinates><Longitude>145.031113</Longitude></Coordinates></Location>
|
318
|
+
</IpInfo>
|
319
|
+
XML
|
320
|
+
end
|
321
|
+
|
322
|
+
@qod.info("4.2.2.2")[:longitude].should == 145.031113
|
323
|
+
end
|
324
|
+
|
325
|
+
it "maps <Location><Coordinates><Latitude/></Coordinates></Location> to :latitude" do
|
326
|
+
@response.stub(:body) do
|
327
|
+
<<-XML
|
328
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
329
|
+
<Location><Coordinates><Latitude>-37.8808327</Latitude></Coordinates></Location>
|
330
|
+
</IpInfo>
|
331
|
+
XML
|
332
|
+
end
|
333
|
+
|
334
|
+
@qod.info("4.2.2.2")[:latitude].should == -37.8808327
|
335
|
+
end
|
336
|
+
|
337
|
+
it "maps <Location><DMA><Id/></DMA></Location> to :dma_id" do
|
338
|
+
@response.stub(:body) do
|
339
|
+
<<-XML
|
340
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
341
|
+
<Location><DMA><Id>1234</Id></DMA></Location>
|
342
|
+
</IpInfo>
|
343
|
+
XML
|
344
|
+
end
|
345
|
+
|
346
|
+
@qod.info("4.2.2.2")[:dma_id].should == 1234
|
347
|
+
end
|
348
|
+
|
349
|
+
it "maps <Location><MSA><Id/></MSA></Location> to :msa_id" do
|
350
|
+
@response.stub(:body) do
|
351
|
+
<<-XML
|
352
|
+
<IpInfo xmlns="https://webservices.quova.com/ipinfo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
353
|
+
<Location><MSA><Id>1234</Id></MSA></Location>
|
354
|
+
</IpInfo>
|
355
|
+
XML
|
356
|
+
end
|
357
|
+
|
358
|
+
@qod.info("4.2.2.2")[:msa_id].should == 1234
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quova
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Flippa.com Pty. Ltd.
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-07-10 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: &14962280 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.6.3
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *14962280
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: virtus
|
27
|
+
requirement: &14961780 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *14961780
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: nokogiri
|
38
|
+
requirement: &14961200 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.5.0
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *14961200
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &14960620 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.6'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *14960620
|
58
|
+
description: Provides a high-level client for Quova's On-Demand REST API
|
59
|
+
email:
|
60
|
+
- chris@flippa.com
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .gitignore
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- lib/quova.rb
|
71
|
+
- lib/quova/qod.rb
|
72
|
+
- lib/quova/version.rb
|
73
|
+
- quova.gemspec
|
74
|
+
- spec/qod_spec.rb
|
75
|
+
- spec/spec_helper.rb
|
76
|
+
homepage: http://flippa.com/
|
77
|
+
licenses: []
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project: quova
|
96
|
+
rubygems_version: 1.8.5
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Quova GeoIP Client for Ruby
|
100
|
+
test_files: []
|