iprofiler 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +39 -12
- data/README.md +4 -0
- data/changelog.markdown +11 -1
- data/lib/iprofiler/client.rb +3 -2
- data/lib/iprofiler/version.rb +1 -1
- data/spec/cases/api_spec.rb +3 -0
- metadata +2 -1
data/README.markdown
CHANGED
@@ -6,26 +6,53 @@ Travis CI : [![Build Status](https://secure.travis-ci.org/kandadaboggu/iprofiler
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
Add the following line to your Gemfile.
|
10
10
|
|
11
|
-
|
11
|
+
gem 'iprofiler'
|
12
|
+
bundle install
|
12
13
|
|
13
|
-
|
14
|
-
require 'iprofiler'
|
14
|
+
## Usage
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
**Setting the connection parameters globally**
|
17
|
+
|
18
|
+
Iprofiler.configure do |config|
|
19
|
+
config.api_key = "foo"
|
20
|
+
config.api_secret = "bar"
|
21
|
+
config.api_host = "http://localhost:3000"
|
22
|
+
end
|
23
|
+
client = Iprofiler::Client.new
|
24
|
+
|
25
|
+
|
26
|
+
**Setting the connection parameters per connection**
|
27
|
+
|
28
|
+
client = Iprofiler::Client.new ("foo", "bar", "http://localhost:3000")
|
29
|
+
|
30
|
+
**Invoking the API**
|
31
|
+
|
32
|
+
client = Iprofiler::Client.new
|
33
|
+
client.company_lookup(:company_name => "Bank Of America")
|
34
|
+
client.company_lookup(:ip_address => "10.10.10.2")
|
35
|
+
client.company_lookup(:domain => "bankofamerica.com")
|
36
|
+
client.company_lookup(:url => "accipitercom.com")
|
37
|
+
|
38
|
+
**Error/ISP handling**
|
39
|
+
|
40
|
+
reply = client.company_lookup(:ip_address => "2.228.11.0")
|
19
41
|
if reply.status == :found
|
20
|
-
|
21
|
-
|
42
|
+
if reply.company.type == "company"
|
43
|
+
puts "Processed Company"
|
22
44
|
else
|
45
|
+
puts "Ignored ISP"
|
23
46
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
47
|
+
elsif reply.status == :not_found
|
48
|
+
puts "Not found"
|
49
|
+
elsif reply.status == :insufficient_input
|
50
|
+
puts "Invalid input"
|
51
|
+
elsif reply.status == :error
|
52
|
+
puts "Error #{reply.error}"
|
27
53
|
end
|
28
54
|
|
55
|
+
|
29
56
|
## TODO
|
30
57
|
|
31
58
|
|
data/README.md
ADDED
data/changelog.markdown
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 0.0
|
3
|
+
## 0.1.0 - March 05, 2013
|
4
4
|
|
5
5
|
* Initial release
|
6
|
+
|
7
|
+
## 0.1.1 - March 08, 2013
|
8
|
+
|
9
|
+
* Added missing authentication parameter check
|
10
|
+
|
11
|
+
## 0.1.2 - March 08, 2013
|
12
|
+
|
13
|
+
* Symbolized the type value in company structure
|
14
|
+
* Updated README.markdown
|
15
|
+
|
data/lib/iprofiler/client.rb
CHANGED
@@ -80,8 +80,6 @@ module Iprofiler
|
|
80
80
|
return Mash.new.tap do |reply|
|
81
81
|
reply.status = :error
|
82
82
|
reply.code = 400
|
83
|
-
|
84
|
-
missing = CONNECTION_PARAMETERS.none?{ |attr| send(attr).nil?}
|
85
83
|
reply.error = "Invalid or missing API connection parameter(s)[#{missing_credentials.join(",")}]"
|
86
84
|
end
|
87
85
|
end
|
@@ -92,6 +90,9 @@ module Iprofiler
|
|
92
90
|
reply.code = code
|
93
91
|
if code == 200
|
94
92
|
reply.status = reply.status.to_sym
|
93
|
+
if reply.status == :found
|
94
|
+
reply.company.type = reply.company.type.to_sym
|
95
|
+
end
|
95
96
|
else
|
96
97
|
reply.status = :error
|
97
98
|
end
|
data/lib/iprofiler/version.rb
CHANGED
data/spec/cases/api_spec.rb
CHANGED
@@ -99,18 +99,21 @@ describe Iprofiler::Api do
|
|
99
99
|
reply = client.company_lookup(:company_name => company.name)
|
100
100
|
reply.code.should eq(200)
|
101
101
|
reply.status.should eq(:found)
|
102
|
+
reply.company.type.should eq(:company)
|
102
103
|
end
|
103
104
|
|
104
105
|
it "should be able to query using domain name" do
|
105
106
|
reply = client.company_lookup(:domain => company.url)
|
106
107
|
reply.code.should eq(200)
|
107
108
|
reply.status.should eq(:found)
|
109
|
+
reply.company.type.should eq(:company)
|
108
110
|
end
|
109
111
|
|
110
112
|
it "should be able to query using ip address" do
|
111
113
|
reply = client.company_lookup(:ip_address => company.ip_address)
|
112
114
|
reply.code.should eq(200)
|
113
115
|
reply.status.should eq(:found)
|
116
|
+
reply.company.type.should eq(:company)
|
114
117
|
end
|
115
118
|
|
116
119
|
it "should be able to query using employee email id" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iprofiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -171,6 +171,7 @@ files:
|
|
171
171
|
- Gemfile
|
172
172
|
- LICENSE
|
173
173
|
- README.markdown
|
174
|
+
- README.md
|
174
175
|
- Rakefile
|
175
176
|
- changelog.markdown
|
176
177
|
- iprofiler.gemspec
|