maxmind 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -4
- data/README.md +2 -5
- data/lib/maxmind/request.rb +3 -7
- data/lib/maxmind/version.rb +1 -1
- data/spec/maxmind/request_spec.rb +26 -16
- data/spec/maxmind/response_spec.rb +16 -16
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0223f7f1a71376a601edbad80dfd6fe9031a4ec3
|
4
|
+
data.tar.gz: 907d96e343272de90ce1bd41cfe703e223978735
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d814a2b9c81a9a28b0777da2e4e648ec7cb295a7aa912d2a56503c3ddb61135bacde0ea2f833e8fc7fbe841f9769a0d7f707e6670f031f1a84ea2f0832bce0c
|
7
|
+
data.tar.gz: b65d325cfc013068bf024b1a2c2a0b7e3d2bf2f108c319338c5e384d7f0604d7db6d3af3a83a3dde754439fec73a2e6b490db4c10c981239509b266086f103c2
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -38,11 +38,7 @@ These are the only required fields to acquire a response from MaxMind.
|
|
38
38
|
require 'maxmind'
|
39
39
|
Maxmind.license_key = 'LICENSE_KEY'
|
40
40
|
request = Maxmind::Request.new(
|
41
|
-
:client_ip => '24.24.24.24'
|
42
|
-
:city => 'New York',
|
43
|
-
:region => 'NY',
|
44
|
-
:postal => '11434',
|
45
|
-
:country => 'US'
|
41
|
+
:client_ip => '24.24.24.24'
|
46
42
|
)
|
47
43
|
|
48
44
|
response = request.process!
|
@@ -164,6 +160,7 @@ Contributors
|
|
164
160
|
* Thomas Morgan
|
165
161
|
* Tinu Cleatus <tinu.cleatus@me.com>
|
166
162
|
* Don Pflaster <dpflaster@gmail.com>
|
163
|
+
* Igor Pstyga
|
167
164
|
|
168
165
|
Thanks to all :)
|
169
166
|
|
data/lib/maxmind/request.rb
CHANGED
@@ -120,14 +120,14 @@ module Maxmind
|
|
120
120
|
def post(query_params)
|
121
121
|
servers ||= SERVERS.map{|hostname| "https://#{hostname}/app/ccv2r"}
|
122
122
|
url = URI.parse(servers.shift)
|
123
|
-
|
123
|
+
|
124
124
|
req = Net::HTTP::Post.new(url.path)
|
125
125
|
req.set_form_data(query_params)
|
126
126
|
|
127
127
|
h = Net::HTTP.new(url.host, url.port)
|
128
128
|
h.use_ssl = true
|
129
129
|
h.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
130
|
-
|
130
|
+
|
131
131
|
# set some timeouts
|
132
132
|
h.open_timeout = 60 # this blocks forever by default, lets be a bit less crazy.
|
133
133
|
h.read_timeout = self.class.timeout || DefaultTimeout
|
@@ -147,15 +147,11 @@ module Maxmind
|
|
147
147
|
Digest::MD5.hexdigest(value.downcase)
|
148
148
|
end
|
149
149
|
end
|
150
|
-
|
150
|
+
|
151
151
|
protected
|
152
152
|
def validate
|
153
153
|
raise ArgumentError, 'License key is required' unless Maxmind::license_key
|
154
154
|
raise ArgumentError, 'IP address is required' unless client_ip
|
155
|
-
raise ArgumentError, 'City is required' unless city
|
156
|
-
raise ArgumentError, 'Region is required' unless region
|
157
|
-
raise ArgumentError, 'Postal code is required' unless postal
|
158
|
-
raise ArgumentError, 'Country is required' unless country
|
159
155
|
end
|
160
156
|
end
|
161
157
|
end
|
data/lib/maxmind/version.rb
CHANGED
@@ -14,57 +14,67 @@ describe Maxmind::Request do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "requires client IP" do
|
17
|
-
expect {
|
17
|
+
expect {
|
18
|
+
@request.client_ip = nil; @request.send(:validate)
|
19
|
+
}.to raise_exception(ArgumentError)
|
18
20
|
end
|
19
21
|
|
20
|
-
it "
|
21
|
-
expect {
|
22
|
+
it "doesn't require city" do
|
23
|
+
expect {
|
24
|
+
@request.city = nil; @request.send(:validate)
|
25
|
+
}.not_to raise_error
|
22
26
|
end
|
23
27
|
|
24
|
-
it "
|
25
|
-
expect {
|
28
|
+
it "doesn't require region" do
|
29
|
+
expect {
|
30
|
+
@request.region = nil; @request.send(:validate)
|
31
|
+
}.not_to raise_error
|
26
32
|
end
|
27
33
|
|
28
|
-
it "
|
29
|
-
expect {
|
34
|
+
it "doesn't require postal" do
|
35
|
+
expect {
|
36
|
+
@request.postal = nil; @request.send(:validate)
|
37
|
+
}.not_to raise_error
|
30
38
|
end
|
31
39
|
|
32
|
-
it "
|
33
|
-
expect {
|
40
|
+
it "doesn't require country" do
|
41
|
+
expect {
|
42
|
+
@request.country = nil; @request.send(:validate)
|
43
|
+
}.not_to raise_error
|
34
44
|
end
|
35
45
|
|
36
46
|
it "converts username to MD5" do
|
37
47
|
@request.username = 'testuser'
|
38
|
-
@request.username.
|
48
|
+
expect(@request.username).to eq '5d9c68c6c50ed3d02a2fcf54f63993b6'
|
39
49
|
end
|
40
50
|
|
41
51
|
it "converts password to MD5" do
|
42
52
|
@request.password = 'testpassword'
|
43
|
-
@request.password.
|
53
|
+
expect(@request.password).to eq 'e16b2ab8d12314bf4efbd6203906ea6c'
|
44
54
|
end
|
45
55
|
|
46
56
|
it "converts email to MD5" do
|
47
57
|
@request.email = 'test@test.com'
|
48
|
-
@request.email.
|
58
|
+
expect(@request.email).to eq 'b642b4217b34b1e8d3bd915fc65c4452'
|
49
59
|
end
|
50
60
|
|
51
61
|
it "does not double convert an md5 username" do
|
52
62
|
@request.username = 'b642b4217b34b1e8d3bd915fc65c4452'
|
53
|
-
@request.username.
|
63
|
+
expect(@request.username).to eq 'b642b4217b34b1e8d3bd915fc65c4452'
|
54
64
|
end
|
55
65
|
|
56
66
|
it "does not double convert an md5 password" do
|
57
67
|
@request.password = 'b642b4217b34b1e8d3bd915fc65c4452'
|
58
|
-
@request.password.
|
68
|
+
expect(@request.password).to eq 'b642b4217b34b1e8d3bd915fc65c4452'
|
59
69
|
end
|
60
70
|
|
61
71
|
it "does not double convert an md5 email" do
|
62
72
|
@request.email = 'b642b4217b34b1e8d3bd915fc65c4452'
|
63
|
-
@request.email.
|
73
|
+
expect(@request.email).to eq 'b642b4217b34b1e8d3bd915fc65c4452'
|
64
74
|
end
|
65
75
|
|
66
76
|
it "exposes the query parameters" do
|
67
|
-
@request.query.
|
77
|
+
expect(@request.query).to be_a Hash
|
68
78
|
end
|
69
79
|
|
70
80
|
end
|
@@ -22,59 +22,59 @@ describe Maxmind::Response do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "exposes its attributes" do
|
25
|
-
@response.attributes.
|
25
|
+
expect(@response.attributes).to be_a Hash
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "exposes the raw response body" do
|
29
|
-
@response.body.
|
29
|
+
expect(@response.body).to eq @response_body
|
30
30
|
end
|
31
31
|
|
32
32
|
it "exposes the http response code" do
|
33
|
-
@response.http_code.
|
33
|
+
expect(@response.http_code).to eq 200
|
34
34
|
end
|
35
35
|
|
36
36
|
it "has a distance" do
|
37
|
-
@response.distance.
|
37
|
+
expect(@response.distance).to eq 329
|
38
38
|
end
|
39
39
|
|
40
40
|
it "has a maxmind ID" do
|
41
|
-
@response.maxmind_id.
|
41
|
+
expect(@response.maxmind_id).to eq '9VSOSDE2'
|
42
42
|
end
|
43
43
|
|
44
44
|
it "has a risk score" do
|
45
|
-
@response.risk_score.
|
45
|
+
expect(@response.risk_score).to eq 2.0
|
46
46
|
end
|
47
47
|
|
48
48
|
it "has a score" do
|
49
|
-
@response.score.
|
49
|
+
expect(@response.score).to eq 7.66
|
50
50
|
end
|
51
51
|
|
52
52
|
it "has queries remaining" do
|
53
|
-
@response.queries_remaining.
|
53
|
+
expect(@response.queries_remaining).to eq 955
|
54
54
|
end
|
55
55
|
|
56
56
|
it "has an explanation" do
|
57
|
-
@response.explanation.
|
57
|
+
expect(@response.explanation).to be_a String
|
58
58
|
end
|
59
59
|
|
60
60
|
it "has a country match" do
|
61
|
-
@response.country_match.
|
61
|
+
expect(@response.country_match).not_to be_nil
|
62
62
|
end
|
63
63
|
|
64
64
|
it "has a boolean country match" do
|
65
|
-
@response.country_match.
|
66
|
-
@response.country_match.
|
65
|
+
expect(@response.country_match).not_to eq "Yes"
|
66
|
+
expect(@response.country_match).to be_truthy
|
67
67
|
end
|
68
68
|
|
69
69
|
it "has a phone in billing location" do
|
70
|
-
@response.phone_in_billing_location.
|
70
|
+
expect(@response.phone_in_billing_location).to be_falsey
|
71
71
|
end
|
72
72
|
|
73
73
|
it "has a phone in billing location ? method" do
|
74
|
-
@response.phone_in_billing_location
|
74
|
+
expect(@response.phone_in_billing_location?).to be_falsey
|
75
75
|
end
|
76
76
|
|
77
77
|
it "has a high risk email" do
|
78
|
-
@response.high_risk_email.
|
78
|
+
expect(@response.high_risk_email).to be_truthy
|
79
79
|
end
|
80
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maxmind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Daniels
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "A wrapper around MaxMind's minFraud anti-fraud service. \n\nhttp://www.maxmind.com/app/ccv_overview\n"
|
14
14
|
email: adam@mediadrive.ca
|
@@ -18,8 +18,8 @@ extra_rdoc_files:
|
|
18
18
|
- LICENSE
|
19
19
|
- README.md
|
20
20
|
files:
|
21
|
-
- .gitignore
|
22
|
-
- .travis.yml
|
21
|
+
- ".gitignore"
|
22
|
+
- ".travis.yml"
|
23
23
|
- Gemfile
|
24
24
|
- Guardfile
|
25
25
|
- LICENSE
|
@@ -53,17 +53,17 @@ require_paths:
|
|
53
53
|
- lib
|
54
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
|
-
- -
|
56
|
+
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
65
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.
|
66
|
+
rubygems_version: 2.4.4
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Wrapper for MaxMind's minFraud service
|