domain_finder 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca7e5e41e81bd2b52c90a4ffd0ad9cf020985f42
4
- data.tar.gz: 5c9f4da34ba19fcf83cd9a8c5ca4161dc3fb3f77
3
+ metadata.gz: 37023e777be05e6a03f3cf5b3493652a00d701ce
4
+ data.tar.gz: 007979d57f2718e28a507c7565d7450cd3648c88
5
5
  SHA512:
6
- metadata.gz: c15995b123ea841df90582976e3b97b8abbd83fdfd9a5721d6d83520a8170e3387692dbefbb0c846e3ff02b4f6e262496fb0b510225617649c77ea18e68dbf5c
7
- data.tar.gz: 941c3f2b21b4695eee95b5abda6b97f75f850dc25089b8ee18f20f3f58636e60d1b7f7048ffd0e09fbd2469affa0b03a88d32f3a191123718764c4d05bf41f59
6
+ metadata.gz: 945e600e875e8c6ec9900050df41c2ae4fafe26c20e8d43f1e5c0b8cf89e4986898678054d2034fa35859ae1ec1fc31561328297697dee3fa2edeb8300883c1c
7
+ data.tar.gz: 1b4582af1a8e4678c948fdb54e46d1fd931bb3d6442db46be619bc822af030c4e6713270c576790711b01eeb310b8387d08dbe578d7559d95c425c2479f678b3
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.0.0
5
+ - 1.9.3
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
- # Domain Finder
1
+ # Domain Finder [![Build Status](https://travis-ci.org/zetsubo/domain_finder.png?branch=master)](https://travis-ci.org/zetsubo/domain_finder)
2
2
 
3
3
  Say you're working on a new web project and suddenly think of a good name for it. "Well, this is sort of like Facebook, and also like Twitter," you muse. "I've got it - facetweet!"
4
4
 
5
- You _could_ open up a browser tab and check domains on a registrar. Or, you could search _right in your terminal_ with Domain Finder.
5
+ You _could_ open up a browser tab and check domains on a registrar. Or, you could search _right in your terminal_ with domain_finder.
6
+
7
+ ![](screenshots/domainfinder.png)
6
8
 
7
9
  ## Installation
8
10
 
@@ -12,4 +14,36 @@ Easy peasy lemon squeezy:
12
14
 
13
15
  ## Usage
14
16
 
15
- TODO: Write usage instructions here
17
+ After installing, simply type `domain foo` in your terminal. Feeling particularly lazy? You can even search for multiple domains at once:
18
+
19
+ ```
20
+ domain facetweet twitbook
21
+ ** facetweet **
22
+ ✘ facetweet.com
23
+ ✘ facetweet.net
24
+ ○ facetweet.org
25
+ ✘ facetweet.co
26
+ ○ facetweet.io
27
+ ✘ facetweet.me
28
+ ○ facetw.ee
29
+ ? face.tw
30
+ ✘ facetwe.et
31
+ ✘ fac.et
32
+ ✘ f.ac
33
+ ** twitbook **
34
+ ✘ twitbook.com
35
+ ✘ twitbook.net
36
+ ○ twitbook.org
37
+ ○ twitbook.co
38
+ ○ twitbook.io
39
+ ○ twitbook.me
40
+ ○ twit.bo
41
+ ? twit.book
42
+ ✘ tw
43
+ ✘ twit.boo
44
+ ✘ tw.it
45
+ ```
46
+
47
+ ## Support
48
+
49
+ domain_finder works (and is tested) with Ruby 1.9.3, 2.0.0 and 2.1.0.
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -19,5 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "vcr", "~> 2.8"
22
+ spec.add_development_dependency "rake", "~> 10.1"
23
+ spec.add_development_dependency "webmock", "~> 1.16"
24
+ spec.add_development_dependency "rspec", "~> 2.14"
22
25
 
23
26
  end
data/lib/domain_finder.rb CHANGED
@@ -12,15 +12,21 @@ module DomainFinder
12
12
  results = []
13
13
 
14
14
  domains.each do |domain|
15
- uri = URI(URL)
15
+ uri = URI.parse(URL)
16
16
  params = { q: domain }
17
17
  uri.query = URI.encode_www_form(params)
18
- res = Net::HTTP.get_response(uri)
18
+
19
+ http = Net::HTTP.new(uri.host, uri.port)
20
+ http.use_ssl = true
21
+
22
+ request = Net::HTTP::Get.new(uri.request_uri)
23
+
24
+ res = http.request(request)
19
25
 
20
26
  results << "** #{domain} **" if domains.size > 1
21
27
 
22
28
  if res.is_a?(Net::HTTPSuccess)
23
- results << parse_results(res.body)
29
+ results += parse_results(res.body)
24
30
  elsif res.is_a?(Net::HTTPBadRequest)
25
31
  results << "Registrar doesn't like your request. Try a different one."
26
32
  else
@@ -39,11 +45,11 @@ module DomainFinder
39
45
  json['results'].map do |result|
40
46
  case result['availability']
41
47
  when 'available'
42
- " #{result['domain']}"
48
+ "o #{result['domain']}"
43
49
  when 'maybe'
44
50
  "? #{result['domain']}"
45
51
  else
46
- " #{result['domain']}"
52
+ "x #{result['domain']}"
47
53
  end
48
54
  end
49
55
  end
@@ -1,3 +1,3 @@
1
1
  module DomainFinder
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://domai.nr/api/json/search?q=thezets
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - max-age=0, private, must-revalidate
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Etag:
26
+ - "\"cbe3081c4d4868f313dce61692a3c7a2\""
27
+ Strict-Transport-Security:
28
+ - max-age=31536000
29
+ Vary:
30
+ - Accept-Encoding
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Request-Id:
36
+ - c4809227-5138-4acd-9d78-8e9f0d217607
37
+ X-Runtime:
38
+ - '0.025812'
39
+ X-Ua-Compatible:
40
+ - chrome=1
41
+ X-Xss-Protection:
42
+ - 1; mode=block
43
+ Content-Length:
44
+ - '233'
45
+ Connection:
46
+ - keep-alive
47
+ body:
48
+ encoding: UTF-8
49
+ string: "{\"query\":\"thezets\",\"results\":[{\"domain\":\"thezets.com\",\"host\":\"\",\"subdomain\":\"thezets.com\",\"path\":\"\",\"availability\":\"taken\",\"register_url\":\"https://domai.nr/thezets.com/register\"},{\"domain\":\"thezets.net\",\"host\":\"\",\"subdomain\":\"thezets.net\",\"path\":\"\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/thezets.net/register\"},{\"domain\":\"thezets.org\",\"host\":\"\",\"subdomain\":\"thezets.org\",\"path\":\"\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/thezets.org/register\"},{\"domain\":\"thezets.co\",\"host\":\"\",\"subdomain\":\"thezets.co\",\"path\":\"\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/thezets.co/register\"},{\"domain\":\"thezets.io\",\"host\":\"\",\"subdomain\":\"thezets.io\",\"path\":\"\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/thezets.io/register\"},{\"domain\":\"thezets.me\",\"host\":\"\",\"subdomain\":\"thezets.me\",\"path\":\"\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/thezets.me/register\"},{\"domain\":\"th\",\"host\":\"\",\"subdomain\":\"th\",\"path\":\"/ezets\",\"availability\":\"tld\",\"register_url\":\"https://domai.nr/th/register\"},{\"domain\":\"thez.et\",\"host\":\"\",\"subdomain\":\"thez.et\",\"path\":\"/s\",\"availability\":\"unavailable\",\"register_url\":\"https://domai.nr/thez.et/register\"}]}"
50
+ http_version:
51
+ recorded_at: Tue, 11 Feb 2014 08:21:33 GMT
52
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,101 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://domai.nr/api/json/search?q=twitbook
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - max-age=0, private, must-revalidate
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Etag:
26
+ - "\"991602b3520ae947ebcfc13839765713\""
27
+ Strict-Transport-Security:
28
+ - max-age=31536000
29
+ Vary:
30
+ - Accept-Encoding
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Request-Id:
36
+ - 93da875e-09f8-41e6-a2f9-78e70cf33336
37
+ X-Runtime:
38
+ - '0.029765'
39
+ X-Ua-Compatible:
40
+ - chrome=1
41
+ X-Xss-Protection:
42
+ - 1; mode=block
43
+ Content-Length:
44
+ - '281'
45
+ Connection:
46
+ - keep-alive
47
+ body:
48
+ encoding: UTF-8
49
+ string: "{\"query\":\"twitbook\",\"results\":[{\"domain\":\"twitbook.com\",\"host\":\"\",\"subdomain\":\"twitbook.com\",\"path\":\"\",\"availability\":\"taken\",\"register_url\":\"https://domai.nr/twitbook.com/register\"},{\"domain\":\"twitbook.net\",\"host\":\"\",\"subdomain\":\"twitbook.net\",\"path\":\"\",\"availability\":\"taken\",\"register_url\":\"https://domai.nr/twitbook.net/register\"},{\"domain\":\"twitbook.org\",\"host\":\"\",\"subdomain\":\"twitbook.org\",\"path\":\"\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/twitbook.org/register\"},{\"domain\":\"twitbook.co\",\"host\":\"\",\"subdomain\":\"twitbook.co\",\"path\":\"\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/twitbook.co/register\"},{\"domain\":\"twitbook.io\",\"host\":\"\",\"subdomain\":\"twitbook.io\",\"path\":\"\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/twitbook.io/register\"},{\"domain\":\"twitbook.me\",\"host\":\"\",\"subdomain\":\"twitbook.me\",\"path\":\"\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/twitbook.me/register\"},{\"domain\":\"twit.bo\",\"host\":\"\",\"subdomain\":\"twit.bo\",\"path\":\"/ok\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/twit.bo/register\"},{\"domain\":\"twit.book\",\"host\":\"\",\"subdomain\":\"twit.book\",\"path\":\"\",\"availability\":\"maybe\",\"register_url\":\"https://domai.nr/twit.book/register\"},{\"domain\":\"tw\",\"host\":\"\",\"subdomain\":\"tw\",\"path\":\"/itbook\",\"availability\":\"tld\",\"register_url\":\"https://domai.nr/tw/register\"},{\"domain\":\"twit.boo\",\"host\":\"\",\"subdomain\":\"twit.boo\",\"path\":\"/k\",\"availability\":\"unavailable\",\"register_url\":\"https://domai.nr/twit.boo/register\"},{\"domain\":\"tw.it\",\"host\":\"\",\"subdomain\":\"tw.it\",\"path\":\"/book\",\"availability\":\"unavailable\",\"register_url\":\"https://domai.nr/tw.it/register\"}]}"
50
+ http_version:
51
+ recorded_at: Tue, 11 Feb 2014 08:23:42 GMT
52
+ - request:
53
+ method: get
54
+ uri: https://domai.nr/api/json/search?q=facetweet
55
+ body:
56
+ encoding: US-ASCII
57
+ string: ''
58
+ headers:
59
+ Accept-Encoding:
60
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
61
+ Accept:
62
+ - "*/*"
63
+ User-Agent:
64
+ - Ruby
65
+ response:
66
+ status:
67
+ code: 200
68
+ message: OK
69
+ headers:
70
+ Cache-Control:
71
+ - max-age=0, private, must-revalidate
72
+ Content-Type:
73
+ - application/json; charset=utf-8
74
+ Etag:
75
+ - "\"690c76ea706deb2af84b658efa10e7dd\""
76
+ Strict-Transport-Security:
77
+ - max-age=31536000
78
+ Vary:
79
+ - Accept-Encoding
80
+ X-Content-Type-Options:
81
+ - nosniff
82
+ X-Frame-Options:
83
+ - SAMEORIGIN
84
+ X-Request-Id:
85
+ - 5a010c19-b461-4e9c-8cc0-072247e09466
86
+ X-Runtime:
87
+ - '0.033554'
88
+ X-Ua-Compatible:
89
+ - chrome=1
90
+ X-Xss-Protection:
91
+ - 1; mode=block
92
+ Content-Length:
93
+ - '288'
94
+ Connection:
95
+ - keep-alive
96
+ body:
97
+ encoding: UTF-8
98
+ string: "{\"query\":\"facetweet\",\"results\":[{\"domain\":\"facetweet.com\",\"host\":\"\",\"subdomain\":\"facetweet.com\",\"path\":\"\",\"availability\":\"taken\",\"register_url\":\"https://domai.nr/facetweet.com/register\"},{\"domain\":\"facetweet.net\",\"host\":\"\",\"subdomain\":\"facetweet.net\",\"path\":\"\",\"availability\":\"taken\",\"register_url\":\"https://domai.nr/facetweet.net/register\"},{\"domain\":\"facetweet.org\",\"host\":\"\",\"subdomain\":\"facetweet.org\",\"path\":\"\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/facetweet.org/register\"},{\"domain\":\"facetweet.co\",\"host\":\"\",\"subdomain\":\"facetweet.co\",\"path\":\"\",\"availability\":\"taken\",\"register_url\":\"https://domai.nr/facetweet.co/register\"},{\"domain\":\"facetweet.io\",\"host\":\"\",\"subdomain\":\"facetweet.io\",\"path\":\"\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/facetweet.io/register\"},{\"domain\":\"facetweet.me\",\"host\":\"\",\"subdomain\":\"facetweet.me\",\"path\":\"\",\"availability\":\"taken\",\"register_url\":\"https://domai.nr/facetweet.me/register\"},{\"domain\":\"facetw.ee\",\"host\":\"\",\"subdomain\":\"facetw.ee\",\"path\":\"/t\",\"availability\":\"available\",\"register_url\":\"https://domai.nr/facetw.ee/register\"},{\"domain\":\"face.tw\",\"host\":\"\",\"subdomain\":\"face.tw\",\"path\":\"/eet\",\"availability\":\"maybe\",\"register_url\":\"https://domai.nr/face.tw/register\"},{\"domain\":\"facetwe.et\",\"host\":\"\",\"subdomain\":\"facetwe.et\",\"path\":\"\",\"availability\":\"unavailable\",\"register_url\":\"https://domai.nr/facetwe.et/register\"},{\"domain\":\"fac.et\",\"host\":\"\",\"subdomain\":\"fac.et\",\"path\":\"/weet\",\"availability\":\"unavailable\",\"register_url\":\"https://domai.nr/fac.et/register\"},{\"domain\":\"f.ac\",\"host\":\"\",\"subdomain\":\"f.ac\",\"path\":\"/etweet\",\"availability\":\"taken\",\"register_url\":\"https://domai.nr/f.ac/register\"}]}"
99
+ http_version:
100
+ recorded_at: Tue, 11 Feb 2014 08:23:43 GMT
101
+ recorded_with: VCR 2.8.0
@@ -1,7 +1,22 @@
1
- describe DomainFinder do
1
+ describe DomainFinder, :vcr do
2
2
 
3
- class DomainFinder
3
+ it 'GETs domains from registrar' do
4
+ expect(DomainFinder::search(['thezets'])).to eq ["x thezets.com", "o thezets.net", "o thezets.org", "o thezets.co",
5
+ "o thezets.io", "o thezets.me", "x th", "x thez.et"]
6
+ end
7
+
8
+ it 'GETs multiple queries' do
9
+ expect(DomainFinder::search(['twitbook', 'facetweet'])).
10
+ to eq ["** twitbook **", "x twitbook.com", "x twitbook.net","o twitbook.org", "o twitbook.co",
11
+ "o twitbook.io", "o twitbook.me", "o twit.bo", "? twit.book", "x tw", "x twit.boo", "x tw.it",
12
+ "** facetweet **", "x facetweet.com", "x facetweet.net", "o facetweet.org", "x facetweet.co",
13
+ "o facetweet.io", "x facetweet.me", "o facetw.ee", "? face.tw", "x facetwe.et", "x fac.et", "x f.ac"]
14
+
15
+ end
4
16
 
17
+ it 'raises an error if the API response code is unexpected (not 200 or 400)' do
18
+ stub_request(:get, "https://domai.nr/api/json/search?q=thezets").to_return(status: 500, body: '', headers: {})
19
+ expect{DomainFinder::search(['thezets'])}.to raise_error(RuntimeError, "Error 500 while accessing domain registrar")
5
20
  end
6
21
 
7
22
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'domain_finder'
2
2
  require 'vcr'
3
+ require 'webmock/rspec'
3
4
 
4
5
  VCR.configure do |c|
5
6
  c.cassette_library_dir = 'spec/cassettes'
@@ -9,9 +10,9 @@ VCR.configure do |c|
9
10
  end
10
11
 
11
12
  RSpec.configure do |c|
12
- config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ c.treat_symbols_as_metadata_keys_with_true_values = true
13
14
 
14
- config.expect_with :rspec do |c|
15
+ c.expect_with :rspec do |c|
15
16
  c.syntax = :expect
16
17
  end
17
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domain_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jade McGough
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-10 00:00:00.000000000 Z
11
+ date: 2014-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vcr
@@ -24,6 +24,48 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.8'
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.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webmock
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.14'
27
69
  description: Check website domain availability from the command line
28
70
  email:
29
71
  - jade@thezets.com
@@ -34,6 +76,7 @@ extra_rdoc_files: []
34
76
  files:
35
77
  - ".gitignore"
36
78
  - ".rspec"
79
+ - ".travis.yml"
37
80
  - Gemfile
38
81
  - LICENSE.txt
39
82
  - README.md
@@ -44,6 +87,8 @@ files:
44
87
  - lib/domain_finder/version.rb
45
88
  - screenshots/domainfinder.png
46
89
  - screenshots/domainfinder2.png
90
+ - spec/cassettes/DomainFinder/GETs_domains_from_registrar.yml
91
+ - spec/cassettes/DomainFinder/GETs_multiple_queries.yml
47
92
  - spec/domain_finder_spec.rb
48
93
  - spec/spec_helper.rb
49
94
  homepage: https://github.com/zetsubo/domain_finder
@@ -71,5 +116,7 @@ signing_key:
71
116
  specification_version: 4
72
117
  summary: Domain availability checker
73
118
  test_files:
119
+ - spec/cassettes/DomainFinder/GETs_domains_from_registrar.yml
120
+ - spec/cassettes/DomainFinder/GETs_multiple_queries.yml
74
121
  - spec/domain_finder_spec.rb
75
122
  - spec/spec_helper.rb