robowhois 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,7 @@
1
+ # Bundler
1
2
  .bundle
2
3
  pkg/*
3
- yardoc
4
+
5
+ # YARD
6
+ .yardoc
7
+ yardoc/
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## Release 0.2.0
5
+
6
+ * NEW: Added support for Heroku ROBOWHOIS_API_KEY environment variable
7
+
8
+
4
9
  ## Release 0.1.0
5
10
 
6
11
  * First release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- robowhois (0.1.0)
4
+ robowhois (0.2.0)
5
5
  httparty (~> 0.8.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  This is the official Ruby client for [RoboWhois](http://www.robowhois.com/) [API](http://docs.robowhois.com/api/).
4
4
 
5
+ [RoboWhois](http://www.robowhois.com/) is a web service that provides an API suite to **access WHOIS records and domain related information with a unified, consistent interface**.
6
+
7
+ Using RoboWhois API you can:
8
+
9
+ - check domain availability for any supported TLD
10
+ - lookup WHOIS information for a domain and retrieve the WHOIS record
11
+ - access WHOIS data using a consistent, well-structured, HTTP-based interface
12
+ - retrieve WHOIS details parsed as convenient JSON structure
13
+
14
+ Visit RoboWhois [site](http://www.robowhois.com/) and [documentation](http://docs.robowhois.com/) to learn more about the service.
15
+
5
16
 
6
17
  ## Installation
7
18
 
@@ -12,7 +12,7 @@ class RoboWhois
12
12
  # Holds information about library version.
13
13
  module Version
14
14
  MAJOR = 0
15
- MINOR = 1
15
+ MINOR = 2
16
16
  PATCH = 0
17
17
  BUILD = nil
18
18
 
data/lib/robo_whois.rb CHANGED
@@ -18,7 +18,7 @@ class RoboWhois
18
18
  end
19
19
 
20
20
  class APIError < Error
21
-
21
+ # @return [Hash] The :key => "value" hash of attributes.
22
22
  attr_reader :attributes
23
23
 
24
24
  def initialize(attributes)
@@ -30,13 +30,21 @@ class RoboWhois
30
30
 
31
31
  base_uri "http://api.robowhois.com"
32
32
 
33
+ # @return [HTTParty::Response] The response object returned by the last API call.
33
34
  attr_reader :last_response
34
35
 
35
36
 
36
- def initialize(api_key)
37
- @auth = { :username => api_key, :password => "X" }
37
+ def initialize(options = {})
38
+ options[:api_key] = (options[:api_key] || ENV["ROBOWHOIS_API_KEY"]).to_s
39
+
40
+ raise ArgumentError, "Missing API key" if options[:api_key].empty?
41
+
42
+ @auth = { :username => options[:api_key], :password => "X" }
38
43
  end
39
44
 
45
+ # Gets the current API key.
46
+ #
47
+ # @return [String]
40
48
  def api_key
41
49
  @auth[:username]
42
50
  end
data/robowhois.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "robowhois"
5
- s.version = "0.1.0"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Simone Carletti"]
@@ -1,12 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe RoboWhois do
4
- let(:client) { RoboWhois.new('API_KEY') }
4
+ let(:client) { RoboWhois.new(:api_key => 'API_KEY') }
5
5
 
6
6
  describe "#initialize" do
7
- it "sets api_key" do
7
+ it "sets api_key from argument" do
8
+ client = RoboWhois.new(:api_key => 'API_KEY')
8
9
  client.api_key.should == 'API_KEY'
9
10
  end
11
+
12
+ it "sets api_key from environment" do
13
+ ENV['ROBOWHOIS_API_KEY'] = 'ENV_KEY'
14
+ client = RoboWhois.new
15
+ client.api_key.should == 'ENV_KEY'
16
+ ENV.delete('ROBOWHOIS_API_KEY')
17
+ end
18
+
19
+ it "raises if no api_key is set" do
20
+ lambda {
21
+ RoboWhois.new
22
+ }.should raise_error(ArgumentError, "Missing API key")
23
+ end
10
24
  end
11
25
 
12
26
  describe "#request" do
@@ -163,7 +177,7 @@ describe RoboWhois do
163
177
 
164
178
  context "request failure" do
165
179
  describe "BadCredentials" do
166
- let(:client) { client = RoboWhois.new('BAD_KEY') }
180
+ let(:client) { client = RoboWhois.new(:api_key => 'BAD_KEY') }
167
181
 
168
182
  before do
169
183
  stub_get('http://BAD_KEY:X@api.robowhois.com/account', 'error_bad_credentials')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: robowhois
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70172086412360 !ruby/object:Gem::Requirement
16
+ requirement: &70097769102120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.8.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70172086412360
24
+ version_requirements: *70097769102120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70172086411840 !ruby/object:Gem::Requirement
27
+ requirement: &70097769101600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.9'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70172086411840
35
+ version_requirements: *70097769101600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yard
38
- requirement: &70172086411380 !ruby/object:Gem::Requirement
38
+ requirement: &70097769101200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70172086411380
46
+ version_requirements: *70097769101200
47
47
  description: Ruby client for the RoboWhois API.
48
48
  email:
49
49
  - weppos@weppos.net