domainr 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Steve Agalloco
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.
@@ -0,0 +1,31 @@
1
+ h1. domainr
2
+
3
+ Ruby wrapper for the "Domainr API":http://domai.nr/api.
4
+
5
+ h2. Installation
6
+
7
+ <pre><code>gem install domainr</code></pre>
8
+
9
+ h2. Usage
10
+
11
+ You can use Domainr to retrieve information about a domain:
12
+
13
+ <pre><code>Domainr.info('google.com')</code></pre>
14
+
15
+ You can also search Domainr based on a search term:
16
+
17
+ <pre><code>Domainr.search('twitter')</code></pre>
18
+
19
+ h2. Note on Patches/Pull Requests
20
+
21
+ * Fork the project.
22
+ * Make your feature addition or bug fix.
23
+ * Add tests for it. This is important so I don't break it in a
24
+ future version unintentionally.
25
+ * Commit, do not mess with rakefile, version, or history.
26
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
27
+ * Send me a pull request. Bonus points for topic branches.
28
+
29
+ h2. Copyright
30
+
31
+ Copyright (c) 2010 Steve Agalloco. See LICENSE for details.
@@ -0,0 +1,62 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ $:.unshift('lib')
5
+
6
+ begin
7
+ require 'jeweler'
8
+ require 'domainr/version'
9
+ Jeweler::Tasks.new do |gem|
10
+ gem.name = "domainr"
11
+ gem.summary = %Q{Ruby wrapper for the Domainr API}
12
+ gem.description = %Q{Ruby wrapper for the Domainr API}
13
+ gem.email = "steve.agalloco@gmail.com"
14
+ gem.homepage = "http://github.com/spagalloco/domainr"
15
+ gem.authors = ["Steve Agalloco"]
16
+
17
+ gem.add_dependency(%q<httparty>, [">= 0.5.2"])
18
+ gem.add_dependency(%q<hashie>, [">= 0.2.0"])
19
+
20
+ gem.add_development_dependency "shoulda", ">= 0"
21
+ gem.add_development_dependency "fakeweb", ">= 0"
22
+ gem.add_development_dependency 'redgreen', ">= 0"
23
+
24
+ gem.version = Domainr::VERSION
25
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
26
+ end
27
+ Jeweler::GemcutterTasks.new
28
+ rescue LoadError
29
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
30
+ end
31
+
32
+ require 'rake/testtask'
33
+ Rake::TestTask.new(:test) do |test|
34
+ test.libs << 'lib' << 'test'
35
+ test.pattern = 'test/**/test_*.rb'
36
+ test.verbose = true
37
+ end
38
+
39
+ begin
40
+ require 'rcov/rcovtask'
41
+ Rcov::RcovTask.new do |test|
42
+ test.libs << 'test'
43
+ test.pattern = 'test/**/test_*.rb'
44
+ test.verbose = true
45
+ end
46
+ rescue LoadError
47
+ task :rcov do
48
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
49
+ end
50
+ end
51
+
52
+ task :test => :check_dependencies
53
+
54
+ task :default => :test
55
+
56
+ require 'rake/rdoctask'
57
+ Rake::RDocTask.new do |rdoc|
58
+ rdoc.rdoc_dir = 'rdoc'
59
+ rdoc.title = "domainr #{Domainr::VERSION}"
60
+ rdoc.rdoc_files.include('README*')
61
+ rdoc.rdoc_files.include('lib/**/*.rb')
62
+ end
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{domainr}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Steve Agalloco"]
12
+ s.date = %q{2010-07-07}
13
+ s.description = %q{Ruby wrapper for the Domainr API}
14
+ s.email = %q{steve.agalloco@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.textile"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.textile",
24
+ "Rakefile",
25
+ "domainr.gemspec",
26
+ "lib/domainr.rb",
27
+ "lib/domainr/version.rb",
28
+ "test/fixtures/empty_info.json",
29
+ "test/fixtures/empty_search.json",
30
+ "test/fixtures/info.json",
31
+ "test/fixtures/search.json",
32
+ "test/helper.rb",
33
+ "test/test_domainr.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/spagalloco/domainr}
36
+ s.rdoc_options = ["--charset=UTF-8"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.3.7}
39
+ s.summary = %q{Ruby wrapper for the Domainr API}
40
+ s.test_files = [
41
+ "test/helper.rb",
42
+ "test/test_domainr.rb"
43
+ ]
44
+
45
+ if s.respond_to? :specification_version then
46
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
+ s.specification_version = 3
48
+
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<httparty>, [">= 0.5.2"])
51
+ s.add_runtime_dependency(%q<hashie>, [">= 0.2.0"])
52
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
53
+ s.add_development_dependency(%q<fakeweb>, [">= 0"])
54
+ s.add_development_dependency(%q<redgreen>, [">= 0"])
55
+ else
56
+ s.add_dependency(%q<httparty>, [">= 0.5.2"])
57
+ s.add_dependency(%q<hashie>, [">= 0.2.0"])
58
+ s.add_dependency(%q<shoulda>, [">= 0"])
59
+ s.add_dependency(%q<fakeweb>, [">= 0"])
60
+ s.add_dependency(%q<redgreen>, [">= 0"])
61
+ end
62
+ else
63
+ s.add_dependency(%q<httparty>, [">= 0.5.2"])
64
+ s.add_dependency(%q<hashie>, [">= 0.2.0"])
65
+ s.add_dependency(%q<shoulda>, [">= 0"])
66
+ s.add_dependency(%q<fakeweb>, [">= 0"])
67
+ s.add_dependency(%q<redgreen>, [">= 0"])
68
+ end
69
+ end
70
+
@@ -0,0 +1,23 @@
1
+ require 'hashie'
2
+ require 'httparty'
3
+
4
+ require 'domainr/version'
5
+
6
+ module Domainr
7
+ extend self
8
+
9
+ include HTTParty
10
+ format :json
11
+ base_uri 'domai.nr'
12
+
13
+ def search(term)
14
+ options = { :q => term }
15
+ Hashie::Mash.new(get('/api/json/search', { :query => options }))
16
+ end
17
+
18
+ def info(domain)
19
+ options = { :q => domain }
20
+ Hashie::Mash.new(get('/api/json/info', { :query => options }))
21
+ end
22
+
23
+ end
@@ -0,0 +1,3 @@
1
+ module Domainr
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,10 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: text/javascript+json
3
+ Date: Wed, 07 Jul 2010 03:36:37 GMT
4
+ Server: Google Frontend
5
+ Cache-Control: private, x-gzip-ok=""
6
+ X-Xss-Protection: 0
7
+ Transfer-Encoding: Identity
8
+ Connection: close
9
+
10
+ {"query": "d", "error": {"status": 404, "message": "No results found."}}
@@ -0,0 +1,10 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: text/javascript+json
3
+ Date: Wed, 07 Jul 2010 03:27:35 GMT
4
+ Server: Google Frontend
5
+ Cache-Control: private, x-gzip-ok=""
6
+ X-Xss-Protection: 0
7
+ Transfer-Encoding: Identity
8
+ Connection: close
9
+
10
+ {"query": "", "results": [], "error": {"status": 404, "message": "No results found."}}
@@ -0,0 +1,10 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: text/javascript+json
3
+ Date: Wed, 07 Jul 2010 02:48:41 GMT
4
+ Server: Google Frontend
5
+ Cache-Control: private, x-gzip-ok=""
6
+ X-Xss-Protection: 0
7
+ Transfer-Encoding: Identity
8
+ Connection: close
9
+
10
+ {"domain": "domai.nr", "whois_url": "http://domai.nr/domai.nr/whois", "register_url": "http://domai.nr/domai.nr/register", "tld": {"domain": "nr", "domain_idna": "nr", "wikipedia_url": "http://wikipedia.org/wiki/.nr", "iana_url": "http://www.iana.org/domains/root/db/nr.html"}, "registrars": [{"registrar": "cenpac.net.nr", "name": "CenpacNET", "register_url": "http://domai.nr/domai.nr/register/cenpac.net.nr"}], "host": "", "path": "", "www_url": "http://domai.nr/domai.nr/www", "query": "domai.nr", "subdomain": "domai.nr", "domain_idna": "domai.nr", "availability": "taken"}
@@ -0,0 +1,10 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: text/javascript+json
3
+ Date: Wed, 07 Jul 2010 02:49:22 GMT
4
+ Server: Google Frontend
5
+ Cache-Control: private, x-gzip-ok=""
6
+ X-Xss-Protection: 0
7
+ Transfer-Encoding: Identity
8
+ Connection: close
9
+
10
+ {"query": "domainr", "results": [{"domain": "domainr.com", "register_url": "http://domai.nr/domainr.com/register", "host": "", "path": "", "subdomain": "domainr.com", "availability": "maybe"}, {"domain": "domainr.net", "register_url": "http://domai.nr/domainr.net/register", "host": "", "path": "", "subdomain": "domainr.net", "availability": "maybe"}, {"domain": "domainr.org", "register_url": "http://domai.nr/domainr.org/register", "host": "", "path": "", "subdomain": "domainr.org", "availability": "maybe"}, {"domain": "domai.nr", "register_url": "http://domai.nr/domai.nr/register", "host": "", "path": "", "subdomain": "domai.nr", "availability": "taken"}, {"domain": "doma.in", "register_url": "http://domai.nr/doma.in/register", "host": "", "path": "/r", "subdomain": "doma.in", "availability": "maybe"}, {"domain": "dom.ai", "register_url": "http://domai.nr/dom.ai/register", "host": "", "path": "/nr", "subdomain": "dom.ai", "availability": "maybe"}, {"domain": "do.ma", "register_url": "http://domai.nr/do.ma/register", "host": "", "path": "/inr", "subdomain": "do.ma", "availability": "maybe"}, {"domain": "d.om", "register_url": "http://domai.nr/d.om/register", "host": "", "path": "/ainr", "subdomain": "d.om", "availability": "unavailable"}, {"domain": "dm.nr", "register_url": "http://domai.nr/dm.nr/register", "host": "", "path": "", "subdomain": "dm.nr", "availability": "maybe"}, {"domain": "d.mai.nr", "register_url": "http://domai.nr/d.mai.nr/register", "host": "d.", "path": "", "subdomain": "mai.nr", "availability": "available"}, {"domain": "d.mn", "register_url": "http://domai.nr/d.mn/register", "host": "", "path": "/r", "subdomain": "d.mn", "availability": "unavailable"}, {"domain": "d.ma.in", "register_url": "http://domai.nr/d.ma.in/register", "host": "d.", "path": "/r", "subdomain": "ma.in", "availability": "unavailable"}, {"domain": "d.m.ai", "register_url": "http://domai.nr/d.m.ai/register", "host": "d.", "path": "/nr", "subdomain": "m.ai", "availability": "taken"}, {"domain": "d.ma", "register_url": "http://domai.nr/d.ma/register", "host": "", "path": "/inr", "subdomain": "d.ma", "availability": "available"}, {"domain": "dm", "register_url": "http://domai.nr/dm/register", "host": "", "path": "/nr", "subdomain": "dm", "availability": "tld"}, {"domain": "do", "register_url": "http://domai.nr/do/register", "host": "", "path": "/mainr", "subdomain": "do", "availability": "tld"}]}
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'fakeweb'
5
+ require 'redgreen'
6
+
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
9
+ require 'domainr'
10
+
11
+ FakeWeb.allow_net_connect = false
12
+
13
+ FakeWeb.register_uri(:get, "http://domai.nr/api/json/info?q=domai.nr", :response => File.join(File.dirname(__FILE__), 'fixtures', 'info.json'), :content_type => "text/javascript+json; charset=utf-8", :status => ["200", "OK"])
14
+ FakeWeb.register_uri(:get, "http://domai.nr/api/json/info?q=d", :response => File.join(File.dirname(__FILE__), 'fixtures', 'empty_info.json'), :content_type => "text/javascript+json; charset=utf-8", :status => ["200", "OK"])
15
+ FakeWeb.register_uri(:get, "http://domai.nr/api/json/search?q=domainr", :response => File.join(File.dirname(__FILE__), 'fixtures', 'search.json'), :content_type => "text/javascript+json; charset=utf-8", :status => ["200", "OK"])
16
+ FakeWeb.register_uri(:get, "http://domai.nr/api/json/search?q=", :response => File.join(File.dirname(__FILE__), 'fixtures', 'empty_search.json'), :content_type => "text/javascript+json; charset=utf-8", :status => ["200", "OK"])
@@ -0,0 +1,59 @@
1
+ require 'helper'
2
+
3
+ class TestDomainr < Test::Unit::TestCase
4
+
5
+ context "Searching Domainr" do
6
+ context "with a search term" do
7
+ setup do
8
+ @domains = Domainr.search('domainr')
9
+ end
10
+
11
+ should "include the query term" do
12
+ assert_equal 'domainr', @domains.query
13
+ end
14
+
15
+ should "return results" do
16
+ assert_equal @domains.results.size, 16
17
+
18
+ first_result = @domains.results.first
19
+ assert_equal first_result.domain, 'domainr.com'
20
+ assert_equal first_result.availability, 'maybe'
21
+
22
+ second_result = @domains.results[1]
23
+ assert_equal second_result.domain, 'domainr.net'
24
+ assert_equal second_result.availability, 'maybe'
25
+ end
26
+ end
27
+
28
+ context "without a search term" do
29
+ should "return an error" do
30
+ @domains = Domainr.search(nil)
31
+ assert_equal @domains.results.size, 0
32
+ assert @domains.error
33
+ assert_equal @domains.error.status, 404
34
+ assert_equal @domains.error.message, 'No results found.'
35
+ end
36
+ end
37
+ end
38
+
39
+ context "Retrieving info from Domainr" do
40
+ context "with a valid search term"do
41
+ should "return results" do
42
+ @domain = Domainr.info('domai.nr')
43
+ assert @domain.registrars
44
+ assert_equal @domain.domain, 'domai.nr'
45
+ assert_equal @domain.availability, 'taken'
46
+ assert_equal @domain.tld.domain, 'nr'
47
+ end
48
+ end
49
+
50
+ context "with an invalid search term" do
51
+ should "return an error" do
52
+ @domain = Domainr.info('d')
53
+ assert @domain.error
54
+ assert_equal @domain.error.status, 404
55
+ assert_equal @domain.error.message, 'No results found.'
56
+ end
57
+ end
58
+ end
59
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: domainr
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Steve Agalloco
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-07 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: httparty
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 0
32
+ - 5
33
+ - 2
34
+ version: 0.5.2
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: hashie
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 23
46
+ segments:
47
+ - 0
48
+ - 2
49
+ - 0
50
+ version: 0.2.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: shoulda
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ type: :development
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: fakeweb
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ type: :development
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ name: redgreen
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ type: :development
94
+ version_requirements: *id005
95
+ description: Ruby wrapper for the Domainr API
96
+ email: steve.agalloco@gmail.com
97
+ executables: []
98
+
99
+ extensions: []
100
+
101
+ extra_rdoc_files:
102
+ - LICENSE
103
+ - README.textile
104
+ files:
105
+ - .document
106
+ - .gitignore
107
+ - LICENSE
108
+ - README.textile
109
+ - Rakefile
110
+ - domainr.gemspec
111
+ - lib/domainr.rb
112
+ - lib/domainr/version.rb
113
+ - test/fixtures/empty_info.json
114
+ - test/fixtures/empty_search.json
115
+ - test/fixtures/info.json
116
+ - test/fixtures/search.json
117
+ - test/helper.rb
118
+ - test/test_domainr.rb
119
+ has_rdoc: true
120
+ homepage: http://github.com/spagalloco/domainr
121
+ licenses: []
122
+
123
+ post_install_message:
124
+ rdoc_options:
125
+ - --charset=UTF-8
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ hash: 3
134
+ segments:
135
+ - 0
136
+ version: "0"
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ hash: 3
143
+ segments:
144
+ - 0
145
+ version: "0"
146
+ requirements: []
147
+
148
+ rubyforge_project:
149
+ rubygems_version: 1.3.7
150
+ signing_key:
151
+ specification_version: 3
152
+ summary: Ruby wrapper for the Domainr API
153
+ test_files:
154
+ - test/helper.rb
155
+ - test/test_domainr.rb