ripe_db_client 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.rvmrc +1 -0
- data/.travis.yml +18 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +53 -0
- data/Rakefile +19 -0
- data/lib/ripe_db_client.rb +5 -0
- data/lib/ripe_db_client/exceptions.rb +83 -0
- data/lib/ripe_db_client/query_and_parse.rb +34 -0
- data/lib/ripe_db_client/query_client.rb +117 -0
- data/lib/ripe_db_client/version.rb +4 -0
- data/ripe_db_client.gemspec +36 -0
- data/spec/fixtures/vcr_cassettes/data_sources_object.yml +28 -0
- data/spec/fixtures/vcr_cassettes/person_object.yml +38 -0
- data/spec/query_and_parse_spec.rb +34 -0
- data/spec/ripe_db_client_spec.rb +78 -0
- data/spec/spec_helper.rb +25 -0
- metadata +227 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a2d9a0e460815225826d0477b9f3619b01a58cad
|
4
|
+
data.tar.gz: 59e8b4e5152248880a9c0e9505fbdd415f0b93e5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0abb331a66f8f8994a575ae5994c88292fb7e5e1368a8eb4f4df2b592db9f0babd3890f32529a42025745f2cce569f3711465b087c2f1d410618ef3d5f227b4b
|
7
|
+
data.tar.gz: 2bad54d84436f52abd81a6973d2b5e054e0823715cf4a42304f62ea58f1a37b92a0d488dfb1f4e75beb383234785aa400deca6adb04d86273e62d8a1267d967b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
GEM_RDB
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p0
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use `cat .ruby-version`@`cat .ruby-gemset`
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
rvm:
|
2
|
+
- 1.8.7
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- 2.0.0
|
6
|
+
- ree
|
7
|
+
- jruby-19mode
|
8
|
+
- jruby-18mode
|
9
|
+
- rbx-18mode
|
10
|
+
- rbx-19mode
|
11
|
+
matrix:
|
12
|
+
allow_failures:
|
13
|
+
- rvm: rbx-18mode
|
14
|
+
- rvm: jruby-18mode
|
15
|
+
- rvm: jruby-19mode
|
16
|
+
|
17
|
+
|
18
|
+
script: "bundle exec rake"
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Mike Simkins
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
[![Gem Version][GV img]][Gem Version]
|
2
|
+
[![Build Status][BS img]][Build Status]
|
3
|
+
[![Dependency Status][DS img]][Dependency Status]
|
4
|
+
[![Coverage Status][CS img]][Coverage Status]
|
5
|
+
|
6
|
+
[Gem Version]: https://rubygems.org/gems/ripe_db_client
|
7
|
+
[Build Status]: https://travis-ci.org/msimkins/RipeDbClient
|
8
|
+
[travis pull requests]: https://travis-ci.org/msimkins/RipeDbClient/pull_requests
|
9
|
+
[Dependency Status]: https://gemnasium.com/msimkins/RipeDbClient
|
10
|
+
[Coverage Status]: https://coveralls.io/r/msimkins/RipeDbClient
|
11
|
+
|
12
|
+
[GV img]: https://badge.fury.io/rb/RipeDbClient.png
|
13
|
+
[BS img]: https://travis-ci.org/msimkins/RipeDbClient.png
|
14
|
+
[DS img]: https://gemnasium.com/msimkins/RipeDbClient.png
|
15
|
+
[CS img]: https://coveralls.io/repos/msimkins/RipeDbClient/badge.png?branch=master
|
16
|
+
|
17
|
+
# RipeDbClient
|
18
|
+
|
19
|
+
This GEM is an interface to the RIPE Database API, using their RESTFUL access service
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
Add this line to your application's Gemfile:
|
24
|
+
|
25
|
+
gem 'ripe_db_client'
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
$ bundle
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
$ gem install ripe_db_client
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
### Create a Client Object
|
38
|
+
|
39
|
+
client = RipeDbClient::Query.new
|
40
|
+
|
41
|
+
### Lookup a database object by type, and reference
|
42
|
+
|
43
|
+
some_hash = client.lookup('mntner','RIPE-DBM-MNT')
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require 'yard'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new do |t|
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
YARD::Rake::YardocTask.new do |t|
|
10
|
+
t.files = ['lib/**/*.rb']
|
11
|
+
t.options = [
|
12
|
+
'--protected',
|
13
|
+
'--title', 'RipeDbClient'
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
task :docs => :yard
|
18
|
+
task :default => :spec
|
19
|
+
task :test => :spec
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module RipeDbClient
|
2
|
+
|
3
|
+
#
|
4
|
+
# Error Class - Inherits from Standard Error
|
5
|
+
#
|
6
|
+
# @author Mike Simkins
|
7
|
+
#
|
8
|
+
class Error < StandardError
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
# This error is raised when a user has not specified a value for a mandatory parameter
|
13
|
+
#
|
14
|
+
# raise RipeDbClient::BadParameter.new("search parameter missing", "dblookup")
|
15
|
+
#
|
16
|
+
# The passed message, action, and subject are optional and can later be retrieved when
|
17
|
+
# rescuing from the exception.
|
18
|
+
#
|
19
|
+
# exception.message # => "search parameter missing"
|
20
|
+
# exception.action # => "dblookup"
|
21
|
+
#
|
22
|
+
# If the message is not specified (or is nil) it will default to "You have an Invalid or Missing Parameter"
|
23
|
+
# This default can be overridden by setting default_message.
|
24
|
+
#
|
25
|
+
# exception.default_message = "Default error message"
|
26
|
+
# exception.message # => "Default error message"
|
27
|
+
#
|
28
|
+
#
|
29
|
+
# @author Mike Simkins
|
30
|
+
#
|
31
|
+
class BadParameter < Error
|
32
|
+
attr_reader :action, :subject
|
33
|
+
attr_writer :default_message
|
34
|
+
|
35
|
+
def initialize (message = nil, action = nil, subject = nil)
|
36
|
+
@message = message
|
37
|
+
@action = action
|
38
|
+
@subject = subject
|
39
|
+
@default_message = "You have an Invalid or Missing Parameter"
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# @return [String] Returns the error message
|
44
|
+
def to_s
|
45
|
+
@message || @default_message
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# This error is raised when a user tries to access an unsupported function
|
50
|
+
#
|
51
|
+
# raise RipeDbClient::Unsupported.new("my secret feature", "top secret")
|
52
|
+
#
|
53
|
+
# The passed message, action, and subject are optional and can later be retrieved when
|
54
|
+
# rescuing from the exception.
|
55
|
+
#
|
56
|
+
# exception.message # => "my secret feature"
|
57
|
+
# exception.action # => "top_secret"
|
58
|
+
#
|
59
|
+
# If the message is not specified (or is nil) it will default to "The feature you require is not currently supported"
|
60
|
+
# This default can be overridden by setting default_message.
|
61
|
+
#
|
62
|
+
# exception.default_message = "Default error message"
|
63
|
+
# exception.message # => "Default error message"
|
64
|
+
#
|
65
|
+
# @author Mike Simkins
|
66
|
+
#
|
67
|
+
class Unsupported < Error
|
68
|
+
attr_reader :action, :subject
|
69
|
+
attr_writer :default_message
|
70
|
+
|
71
|
+
def initialize (message = nil, action = nil, subject = nil)
|
72
|
+
@message = message
|
73
|
+
@action = action
|
74
|
+
@subject = subject
|
75
|
+
@default_message = "The feature you require is not currently supported"
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [String] Returns the error message
|
79
|
+
def to_s
|
80
|
+
@message || @default_message
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module RipeDbClient
|
2
|
+
class Query
|
3
|
+
|
4
|
+
#
|
5
|
+
# Look up the exact value of the key/value pair
|
6
|
+
# @param lookup_key [String]
|
7
|
+
# This is the name of the person you are doing the lookup for
|
8
|
+
# @param return_raw [Boolean]
|
9
|
+
# Set this to true to return the RAW(Unparsed) Hash
|
10
|
+
#
|
11
|
+
# @example lookup_person("MPS31-RIPE")
|
12
|
+
#
|
13
|
+
# @return [Hash] The Hash of values for the returned object
|
14
|
+
#
|
15
|
+
|
16
|
+
def lookup_person(lookup_key,return_raw = false)
|
17
|
+
local_result = self.lookup('person', "#{lookup_key}")
|
18
|
+
if return_raw
|
19
|
+
return local_result
|
20
|
+
else
|
21
|
+
return person_parser(local_result)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def person_parser(returned_hash)
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#
|
2
|
+
# RipeDbClient - An Interface to the RIPE Database RESTful services
|
3
|
+
#
|
4
|
+
# @author Mike Simkins
|
5
|
+
#
|
6
|
+
module RipeDbClient
|
7
|
+
|
8
|
+
#
|
9
|
+
# Query: The class encapsulating all query methods on the RIPE REST Database service
|
10
|
+
#
|
11
|
+
# @author Mike Simkins
|
12
|
+
#
|
13
|
+
class Query
|
14
|
+
|
15
|
+
# @param api_key[String] API Key generated from the RIPE DB Portal
|
16
|
+
# @param api_environment [String] Either 'production' or 'test'
|
17
|
+
# @param base_query_path [String] URI Path (do not include http:// or https:// )
|
18
|
+
#
|
19
|
+
# @return [Object] Returns the Client Instance
|
20
|
+
#
|
21
|
+
def initialize(api_key = nil, api_environment = nil ,base_query_path = 'apps.db.ripe.net/whois')
|
22
|
+
@auth_key = api_key
|
23
|
+
@app_environment = api_environment || 'test'
|
24
|
+
@base_query_path = base_query_path
|
25
|
+
self.set_secure_queries(false)
|
26
|
+
self.set_data_source('ripe')
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# The set_data_source function allows you to manually set a database source to query for the object.
|
31
|
+
#
|
32
|
+
# @param sourceid [String] The Registry source to query - Currently supports RIPE, AFriNic, and APnic
|
33
|
+
#
|
34
|
+
# @return [String] The new Source Registry
|
35
|
+
# If the passed parameters are invalid, then the method throws a RipeDbClient::Unsupported
|
36
|
+
# exception
|
37
|
+
def set_data_source(sourceid)
|
38
|
+
if %w(ripe afrinic apnic).include? sourceid.downcase
|
39
|
+
@source_registry = sourceid
|
40
|
+
else
|
41
|
+
raise RipeDbClient::Unsupported.new('The only Supported registries are RIPE, AFRINIC, and APNIC', 'set_data_source')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# The source_registry? function allows you to manually set a database source to query for the object.
|
46
|
+
#
|
47
|
+
# @return [String] The new Source Registry
|
48
|
+
# If the passed parameters are invalid, then the method throws a RipeDbClient::Unsupported
|
49
|
+
# exception
|
50
|
+
def source_registry?
|
51
|
+
@source_registry
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
#
|
56
|
+
# As standard, queries are performed over the HTTP protocol. If you pass a true value to this function,
|
57
|
+
# it will use queries over HTTPS
|
58
|
+
# @param secure_mode [Boolean] Enable queries over HTTPS
|
59
|
+
# @return [String] - The current access URI
|
60
|
+
def set_secure_queries(secure_mode)
|
61
|
+
if secure_mode
|
62
|
+
@base_query_uri = 'https://' + @base_query_path
|
63
|
+
else
|
64
|
+
@base_query_uri = 'http://' + @base_query_path
|
65
|
+
end
|
66
|
+
@base_query_uri
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# Check tp see if we are performing queries over https
|
71
|
+
# @return [Boolean] - If we are currently using https
|
72
|
+
def secure_queries?
|
73
|
+
@base_query_uri.include? 'https://'
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
#
|
78
|
+
# Returns a hash of all the data sources supported by the REST Client Interface
|
79
|
+
#
|
80
|
+
# @return [Hash] The Raw Hash of supported data sources
|
81
|
+
#
|
82
|
+
def get_supported_data_sources
|
83
|
+
service_url = "#{@base_query_uri}/sources.json"
|
84
|
+
response = HTTParty.get(service_url)
|
85
|
+
response
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
#
|
90
|
+
# Look up the exact value of the key/value pair
|
91
|
+
# @param lookup_key [String]
|
92
|
+
# This is the object type you are looking for. This should be currently one of the RIPE
|
93
|
+
# database supported types ('person', 'mntner','abuse-c'....)
|
94
|
+
# @param lookup_value [String] The actual key you are looking for ('RIPE-DBM-MNT')
|
95
|
+
# @param lookup_source [String] The optional registry to use if it is not the default, or current registry
|
96
|
+
#
|
97
|
+
# @example lookup("mntner","RIPE-DBM-MNT")
|
98
|
+
# @example lookup("person","RIPE-DBM-MNT")
|
99
|
+
#
|
100
|
+
# @return [Hash] The Hash of values for the returned object
|
101
|
+
#
|
102
|
+
def lookup(lookup_key, lookup_value, lookup_source = nil)
|
103
|
+
if lookup_key.nil? || lookup_key.empty?
|
104
|
+
raise RipeDbClient::BadParameter.new('lookup_key cannot be empty, or nil', 'lookup')
|
105
|
+
end
|
106
|
+
if lookup_value.nil? || lookup_value.empty?
|
107
|
+
raise RipeDbClient::BadParameter.new('lookup_value cannot be empty, or nil', 'lookup')
|
108
|
+
end
|
109
|
+
if lookup_source.nil? || lookup_source.empty?
|
110
|
+
lookup_source = @source_registry
|
111
|
+
end
|
112
|
+
service_url = "#{@base_query_uri}/lookup/#{lookup_source.downcase}/#{lookup_key.downcase}/#{lookup_value}.json"
|
113
|
+
response = HTTParty.get(service_url)
|
114
|
+
response
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ripe_db_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'ripe_db_client'
|
8
|
+
spec.version = RipeDbClient::VERSION
|
9
|
+
spec.authors = ['Mike Simkins']
|
10
|
+
spec.email = ['software@g7obs.com']
|
11
|
+
spec.description = %q{Programatical Interface to the RIPE Database API (REST Client) - THIS IS NOT YET READY FOR PRIME TIME}
|
12
|
+
spec.summary = %q{This provides a number of methods to query the RIPE Database, or to Update the Database }
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
# RubyForge info
|
21
|
+
spec.homepage = 'http://ripedbclient.rubyforge.org'
|
22
|
+
spec.rubyforge_project = 'ripedbclient'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3.0'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 2.12.0'
|
27
|
+
spec.add_development_dependency 'yard', '~> 0.8.0'
|
28
|
+
spec.add_development_dependency 'redcarpet', '~> 2.2.0'
|
29
|
+
spec.add_development_dependency 'vcr', '~> 2.4.0'
|
30
|
+
spec.add_development_dependency 'webmock', '~> 1.10.0'
|
31
|
+
spec.add_development_dependency 'simplecov', '~> 0.7.0'
|
32
|
+
spec.add_development_dependency 'coveralls', '~> 0.6.0'
|
33
|
+
|
34
|
+
spec.add_dependency 'httparty', '~> 0.11.0'
|
35
|
+
spec.add_dependency 'hashie', '~> 2.0.0'
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://apps.db.ripe.net/whois/sources.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Date:
|
16
|
+
- Mon, 15 Apr 2013 14:34:35 GMT
|
17
|
+
Content-Type:
|
18
|
+
- application/json
|
19
|
+
Connection:
|
20
|
+
- close
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
body:
|
24
|
+
encoding: UTF-8
|
25
|
+
string: "{\n\t\t\"whois-resources\":{\n\t\t\"service\":\"getSupportedDataSources\",\n\t\t\"link\":{\n\t\t\"xlink:type\":\"locator\",\n\t\t\"xlink:href\":\"http://apps.db.ripe.net/whois/sources\"}\n\t\t,\n\t\t\"sources\":{\n\t\t\"source\":[\n\t\t{\n\t\t\"name\":\"RIPE\",\n\t\t\"id\":\"ripe\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"APNIC\",\n\t\t\"id\":\"apnic\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"AfriNIC\",\n\t\t\"id\":\"afrinic\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"TEST\",\n\t\t\"id\":\"test\"}\n\t\t]\n\t\t}\n\t\t,\n\t\t\"grs-sources\":{\n\t\t\"source\":[\n\t\t{\n\t\t\"name\":\"RIPE-GRS\",\n\t\t\"id\":\"ripe-grs\",\n\t\t\"grs-id\":\"ripe-grs\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"AFRINIC-GRS\",\n\t\t\"id\":\"afrinic-grs\",\n\t\t\"grs-id\":\"afrinic-grs\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"APNIC-GRS\",\n\t\t\"id\":\"apnic-grs\",\n\t\t\"grs-id\":\"apnic-grs\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"ARIN-GRS\",\n\t\t\"id\":\"arin-grs\",\n\t\t\"grs-id\":\"arin-grs\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"LACNIC-GRS\",\n\t\t\"id\":\"lacnic-grs\",\n\t\t\"grs-id\":\"lacnic-grs\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"JPIRR-GRS\",\n\t\t\"id\":\"jpirr-grs\",\n\t\t\"grs-id\":\"jpirr-grs\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"RADB-GRS\",\n\t\t\"id\":\"radb-grs\",\n\t\t\"grs-id\":\"radb-grs\"}\n\t\t]\n\t\t}\n\t\t}\n\t\t}\n\t\t"
|
26
|
+
http_version:
|
27
|
+
recorded_at: Mon, 15 Apr 2013 14:34:35 GMT
|
28
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://apps.db.ripe.net/whois/lookup/ripe/person/MPS31-RIPE.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Date:
|
16
|
+
- Mon, 15 Apr 2013 12:57:07 GMT
|
17
|
+
Content-Type:
|
18
|
+
- application/json
|
19
|
+
Connection:
|
20
|
+
- close
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
body:
|
24
|
+
encoding: UTF-8
|
25
|
+
string: "{\n\t\t\"whois-resources\":{\n\t\t\"service\":\"lookup\",\n\t\t\"xsi:noNamespaceSchemaLocation\":\"http://apps.db.ripe.net/whois/xsd/whois-resources.xsd\",\n\t\t\"link\":{\n\t\t\"xlink:type\":\"locator\",\n\t\t\"xlink:href\":\"http://apps.db.ripe.net/whois/lookup/ripe/person/MPS31-RIPE.json\"}\n\t\t,\n\t\t\"objects\":{\n\t\t\"object\":{\n\t\t\"type\":\"person\",\n\t\t\"link\":{\n\t\t\"xlink:type\":\"locator\",\n\t\t\"xlink:href\":\"http://apps.db.ripe.net/whois/lookup/ripe/person/MPS31-RIPE\"}\n\t\t,\n\t\t\"source\":{\n\t\t\"id\":\"ripe\"}\n\t\t,\n\t\t\"primary-key\":{\n\t\t\"attribute\":{\n\t\t\"name\":\"nic-hdl\",\n\t\t\"value\":\"MPS31-RIPE\"}\n\t\t}\n\t\t,\n\t\t\"attributes\":{\n\t\t\"attribute\":[\n\t\t{\n\t\t\"name\":\"person\",\n\t\t\"value\":\"Mike
|
26
|
+
Simkins\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"address\",\n\t\t\"value\":\"SunGard
|
27
|
+
Availability Services\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"address\",\n\t\t\"value\":\"Lighterman
|
28
|
+
House\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"address\",\n\t\t\"value\":\"3 Clove
|
29
|
+
Crescent\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"address\",\n\t\t\"value\":\"London
|
30
|
+
E14 2BB\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"phone\",\n\t\t\"value\":\"+44 (0)
|
31
|
+
20 8080 8060\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"e-mail\",\n\t\t\"value\":\"mike.simkins@sungard.com\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"notify\",\n\t\t\"value\":\"mike.simkins@sungard.com\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"nic-hdl\",\n\t\t\"value\":\"MPS31-RIPE\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"mnt-by\",\n\t\t\"value\":\"CWS-RIPE-MNT\",\n\t\t\"referenced-type\":\"mntner\",\n\t\t\"link\":{\n\t\t\"xlink:type\":\"locator\",\n\t\t\"xlink:href\":\"http://apps.db.ripe.net/whois/lookup/ripe/mntner/CWS-RIPE-MNT\"}\n\t\t}\n\t\t,\n\t\t{\n\t\t\"name\":\"changed\",\n\t\t\"value\":\"mike.simkins@sungard.com
|
32
|
+
20040817\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"changed\",\n\t\t\"value\":\"mike.simkins@sungard.com
|
33
|
+
20060717\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"changed\",\n\t\t\"value\":\"mike.simkins@sungard.com
|
34
|
+
20061227\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"changed\",\n\t\t\"value\":\"mike.simkins@sungard.com
|
35
|
+
20130111\"}\n\t\t,\n\t\t{\n\t\t\"name\":\"source\",\n\t\t\"value\":\"RIPE\"}\n\t\t]\n\t\t}\n\t\t}\n\t\t}\n\t\t}\n\t\t}\n\t\t"
|
36
|
+
http_version:
|
37
|
+
recorded_at: Mon, 15 Apr 2013 12:57:07 GMT
|
38
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe RipeDbClient do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@client = RipeDbClient::Query.new('test', 'test')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'RipeDbClient::Query Object' do
|
11
|
+
describe 'Query and Parse Functions' do
|
12
|
+
describe 'Person Object' do
|
13
|
+
|
14
|
+
it 'SHOULD be able to look up a RAW PERSON record' do
|
15
|
+
VCR.use_cassette('person_object') do
|
16
|
+
response = @client.lookup_person('MPS31-RIPE', true)
|
17
|
+
response.should_not be_nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'SHOULD be able to provide a COOKED PERSON record' do
|
22
|
+
VCR.use_cassette('person_object') do
|
23
|
+
response = @client.lookup_person('MPS31-RIPE', false)
|
24
|
+
response.should be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe RipeDbClient do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@client = RipeDbClient::Query.new('test', 'test')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "RipeDbClient::Query Object" do
|
11
|
+
|
12
|
+
it "SHOULD create a new client" do
|
13
|
+
c = RipeDbClient::Query.new
|
14
|
+
c.should_not be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "SHOULD default to the RIPE registry on creation" do
|
18
|
+
c = RipeDbClient::Query.new
|
19
|
+
c.source_registry?.should == "ripe"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "SHOULD change the registry if you call the set_data_source function with a valid registry" do
|
23
|
+
c = RipeDbClient::Query.new
|
24
|
+
c.source_registry?.should == "ripe"
|
25
|
+
c.set_data_source("apnic")
|
26
|
+
c.source_registry?.should == "apnic"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "SHOULD NOT change the registry if you call the set_data_source function with an invalid registry" do
|
30
|
+
c = RipeDbClient::Query.new
|
31
|
+
c.source_registry?.should == "ripe"
|
32
|
+
expect { c.set_data_source("arin") }.to raise_error(RipeDbClient::Unsupported, 'The only Supported registries are RIPE, AFRINIC, and APNIC')
|
33
|
+
c.source_registry?.should == "ripe"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "SHOULD use http as its default mechanism" do
|
37
|
+
c = RipeDbClient::Query.new
|
38
|
+
c.secure_queries?.should be_false
|
39
|
+
end
|
40
|
+
|
41
|
+
it "SHOULD use https for queries if you set it up via set_secure_queries" do
|
42
|
+
c = RipeDbClient::Query.new
|
43
|
+
c.secure_queries?.should be_false
|
44
|
+
c.set_secure_queries(true)
|
45
|
+
c.secure_queries?.should be_true
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
it "SHOULD retrieve a list of the available query sources" do
|
50
|
+
c = RipeDbClient::Query.new
|
51
|
+
VCR.use_cassette('data_sources_object') do
|
52
|
+
response = c.get_supported_data_sources
|
53
|
+
response.should_not be_nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it "SHOULD raise an exception if the lookup_key is nil" do
|
58
|
+
c = RipeDbClient::Query.new
|
59
|
+
expect { c.lookup(nil,"something") }.to raise_error(RipeDbClient::BadParameter, 'lookup_key cannot be empty, or nil')
|
60
|
+
end
|
61
|
+
|
62
|
+
it "SHOULD raise an exception if the lookup_key is empty" do
|
63
|
+
c = RipeDbClient::Query.new
|
64
|
+
expect { c.lookup("","something") }.to raise_error(RipeDbClient::BadParameter, 'lookup_key cannot be empty, or nil')
|
65
|
+
end
|
66
|
+
|
67
|
+
it "SHOULD raise an exception if the lookup_value is nil" do
|
68
|
+
c = RipeDbClient::Query.new
|
69
|
+
expect { c.lookup("something", nil) }.to raise_error(RipeDbClient::BadParameter, 'lookup_value cannot be empty, or nil')
|
70
|
+
end
|
71
|
+
|
72
|
+
it "SHOULD raise an exception if the lookup_value is empty" do
|
73
|
+
c = RipeDbClient::Query.new
|
74
|
+
expect { c.lookup("something", "") }.to raise_error(RipeDbClient::BadParameter, 'lookup_value cannot be empty, or nil')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
8
|
+
SimpleCov.start
|
9
|
+
|
10
|
+
|
11
|
+
require 'ripe_db_client'
|
12
|
+
require 'vcr'
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
16
|
+
config.run_all_when_everything_filtered = true
|
17
|
+
config.filter_run :focus
|
18
|
+
config.order = 'random'
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
VCR.configure do |c|
|
23
|
+
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
24
|
+
c.hook_into :webmock
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ripe_db_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Simkins
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 10.0.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 10.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.12.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.12.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.8.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: redcarpet
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.2.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.2.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.4.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.4.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.10.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.10.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.7.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.7.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: coveralls
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.6.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.6.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: httparty
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ~>
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.11.0
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ~>
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.11.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: hashie
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ~>
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 2.0.0
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ~>
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 2.0.0
|
167
|
+
description: Programatical Interface to the RIPE Database API (REST Client) - THIS
|
168
|
+
IS NOT YET READY FOR PRIME TIME
|
169
|
+
email:
|
170
|
+
- software@g7obs.com
|
171
|
+
executables: []
|
172
|
+
extensions: []
|
173
|
+
extra_rdoc_files: []
|
174
|
+
files:
|
175
|
+
- .gitignore
|
176
|
+
- .rspec
|
177
|
+
- .ruby-gemset
|
178
|
+
- .ruby-version
|
179
|
+
- .rvmrc
|
180
|
+
- .travis.yml
|
181
|
+
- Gemfile
|
182
|
+
- LICENSE.txt
|
183
|
+
- README.md
|
184
|
+
- Rakefile
|
185
|
+
- lib/ripe_db_client.rb
|
186
|
+
- lib/ripe_db_client/exceptions.rb
|
187
|
+
- lib/ripe_db_client/query_and_parse.rb
|
188
|
+
- lib/ripe_db_client/query_client.rb
|
189
|
+
- lib/ripe_db_client/version.rb
|
190
|
+
- ripe_db_client.gemspec
|
191
|
+
- spec/fixtures/vcr_cassettes/data_sources_object.yml
|
192
|
+
- spec/fixtures/vcr_cassettes/person_object.yml
|
193
|
+
- spec/query_and_parse_spec.rb
|
194
|
+
- spec/ripe_db_client_spec.rb
|
195
|
+
- spec/spec_helper.rb
|
196
|
+
homepage: http://ripedbclient.rubyforge.org
|
197
|
+
licenses:
|
198
|
+
- MIT
|
199
|
+
metadata: {}
|
200
|
+
post_install_message:
|
201
|
+
rdoc_options: []
|
202
|
+
require_paths:
|
203
|
+
- lib
|
204
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - '>='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
requirements: []
|
215
|
+
rubyforge_project: ripedbclient
|
216
|
+
rubygems_version: 2.0.3
|
217
|
+
signing_key:
|
218
|
+
specification_version: 4
|
219
|
+
summary: This provides a number of methods to query the RIPE Database, or to Update
|
220
|
+
the Database
|
221
|
+
test_files:
|
222
|
+
- spec/fixtures/vcr_cassettes/data_sources_object.yml
|
223
|
+
- spec/fixtures/vcr_cassettes/person_object.yml
|
224
|
+
- spec/query_and_parse_spec.rb
|
225
|
+
- spec/ripe_db_client_spec.rb
|
226
|
+
- spec/spec_helper.rb
|
227
|
+
has_rdoc:
|