domain_check 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d77f3b5e555f4c8657ce23ff975a5ca412359796
4
+ data.tar.gz: 4a42b9a2994f8b732c963ea576e9f7a0a52fd8c7
5
+ SHA512:
6
+ metadata.gz: bf2f28e55d75b652d47c6c3e361259c35f7c1210cf6b6b8b8e71164cbca0f9bb843ca0929f52ec86beb19c3df85a07ab5a171481ae92d76ce39c7a5efffe12d9
7
+ data.tar.gz: dedae4d288593f9107776c98b6b31a84eb660cfa5b45d4b06ff85c6b57c11a56e49800afe058227e938a53529bba26a68440ebb29b92b24338042dc90c03f6a4
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ # Emacs temporary files
2
+ *~
3
+ \#*\#
4
+ .\#*
5
+
6
+ # Bundler artifacts
7
+ .bundle
8
+ bundler_stubs/
9
+ vendor/
10
+
11
+ # Ruby / Rails operational files
12
+ .rvmrc
13
+ .ruby-version
14
+
15
+ # Anything temporary
16
+ *.old
17
+ *.swp
18
+ *.swo
19
+ tmp
20
+
21
+ # Rubygems artifacts
22
+ *.gem
23
+
24
+ # Test artifacts
25
+ coverage
26
+ spec/reports
27
+ test/tmp
28
+ test/version_tmp
29
+
30
+ # Documentation
31
+ .yardoc
32
+ _yardoc
33
+ doc
34
+ rdoc
35
+
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fbo.gemspec
4
+ gemspec
5
+
6
+ gem 'whois'
7
+ gem 'ansi'
data/Gemfile.lock ADDED
@@ -0,0 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ domain_check (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ansi (1.4.3)
10
+ rake (0.9.6)
11
+ whois (3.1.2)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ ansi
18
+ bundler (~> 1.3)
19
+ domain_check!
20
+ rake
21
+ whois
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Chris Kottom
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,77 @@
1
+ # DomainCheck
2
+
3
+ DomainCheck is a simple tool written in Ruby that checks the availability of
4
+ domain names using combinations of keywords defined by the user. Based on
5
+ the lists of prefixes, suffixes, and top-level domains (TLDs) it's given,
6
+ it can (semi-)rapidly find combinations of these that are unoccupied or
7
+ display basic summary information about the domain registration.
8
+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'domain_check'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install domain_check
23
+
24
+ ## Usage
25
+
26
+ The `domain_check` executable is located in the `bin/` directory and can be
27
+ invoked in three ways:
28
+
29
+ ### 1. Single domain check
30
+
31
+ Check the availability of a single domain by passing the `-d` or `--domain`:
32
+
33
+ ```bash
34
+ $ bin/domain_check -d google.com
35
+ google.com REGISTERED, contact: Dns Admin, email: dns-admin@google.com, since: 1997-09-15, expires: 2020-09-13
36
+
37
+ ### 2. Multiple domain check
38
+
39
+ Check the availability of a multiple domains formed by combining keywords and
40
+ top-level domains using three arguments:
41
+
42
+ ```bash
43
+ $ bin/domain_check -p super,mega -s corp,plex -t com,net
44
+ supercorp.com REGISTERED, since: 2002-05-09, expires: 2014-05-09
45
+ supercorp.net AVAILABLE
46
+ superplex.com REGISTERED, since: 2003-01-11, expires: 2016-01-11
47
+ superplex.net REGISTERED, since: 2005-05-01, expires: 2015-05-01
48
+ megacorp.com REGISTERED, since: 1997-12-30, expires: 2013-12-29
49
+ megacorp.net REGISTERED, contact: Misunderstood Computer God, since: 1998-06-04, expires: 2013-06-03
50
+ megaplex.com REGISTERED, since: 1995-08-19, expires: 2014-08-18
51
+ megaplex.net REGISTERED, since: 1999-02-15, expires: 2014-02-15
52
+
53
+ ### 3. Pass a YAML file
54
+
55
+ It's also possible to create a YAML file with lists of keywords and TLDs that
56
+ will be read and parsed by the application via the `-f` or `--file` option.
57
+
58
+ ```ruby
59
+ prefixes:
60
+ - super
61
+ - mega
62
+ suffixes:
63
+ - corp
64
+ - plex
65
+ tlds:
66
+ - com
67
+ - net
68
+
69
+ This should produce the same output as shown in #2 above.
70
+
71
+ ## Contributing
72
+
73
+ 1. Fork it
74
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
75
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
76
+ 4. Push to the branch (`git push origin my-new-feature`)
77
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/domain_check ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'domain_check'
4
+ require 'date'
5
+ require 'optparse'
6
+
7
+ options = { }
8
+ opt_parser = OptionParser.new do |opts|
9
+ opts.banner = "Usage: domain_check [options]"
10
+
11
+ opts.separator ""
12
+ opts.separator "Specific options:"
13
+
14
+ opts.on("-d", "--domain DOMAIN", "Check the availability of DOMAIN") do |dom|
15
+ options[:domain] = dom
16
+ end
17
+
18
+ opts.on("-f", "--file FILE",
19
+ "Pass in a YAML configuration file at FILE") do |file|
20
+ options[:file] = file
21
+ end
22
+
23
+ opts.on("-p", "--prefixes KW1,KW2,...",
24
+ "Create domain names starting with each keyword and check them") do |prefixes|
25
+ options[:prefixes] = prefixes.split(/,/)
26
+ end
27
+
28
+ opts.on("-s", "--suffixes KW1,KW2,...",
29
+ "Create domain names ending with each keyword and check them") do |suffixes|
30
+ options[:suffixes] = suffixes.split(/,/)
31
+ end
32
+
33
+ opts.on("-t", "--tlds TLD1,TLD2,...",
34
+ "Create domain names with each of the TLDs and check them") do |tlds|
35
+ options[:tlds] = tlds.split(/,/)
36
+ end
37
+
38
+ opts.on_tail("-?", "--help", "Show this message") do
39
+ puts opts
40
+ exit
41
+ end
42
+ end
43
+
44
+ opt_parser.parse!(ARGV)
45
+
46
+ DomainCheck.new(**options).check do |result|
47
+ formatter = DomainCheck::ConsoleFormatter.new(result)
48
+ formatter.format
49
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'domain_check/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "domain_check"
8
+ spec.version = DomainCheck::VERSION
9
+ spec.authors = ["Chris Kottom"]
10
+ spec.email = ["chris@chriskottom.com"]
11
+ spec.description = %q{Bulk checking domain availability}
12
+ spec.summary = %q{Perform domain name research against a large set using combinations of relevant keywords.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,48 @@
1
+ require "ansi"
2
+ require "date"
3
+
4
+ class DomainCheck::ConsoleFormatter
5
+ def initialize(result)
6
+ @result = result
7
+ end
8
+
9
+ def format
10
+ if @result
11
+ domain = @result[:domain].ljust(24).ansi.bold.blue
12
+
13
+ if @result[:status] == :available
14
+ status = @result[:status].to_s.upcase.ansi.bold.green
15
+ puts "#{ domain } #{ status }"
16
+
17
+ elsif @result[:status] == :registered
18
+ status = @result[:status].to_s.upcase.ansi.bold.red
19
+ contact_name = @result[:contact_name]
20
+ contact_email = @result[:contact_email]
21
+
22
+ created_on = @result[:created_at]
23
+ created_on = created_on.to_date.to_s if created_on
24
+
25
+ expires_in = nil
26
+ if @result[:expires_at]
27
+ today = Date.today
28
+ days = (@result[:expires_at].to_date - today).to_i
29
+ expires_in = "#{ days } days"
30
+ if days <= 60
31
+ expires_in = expires_in.ansi.yellow.bold
32
+ end
33
+ end
34
+
35
+ params = { contact: contact_name, email: contact_email,
36
+ created: created_on, expires: expires_in }
37
+ params.reject! { |k,v| v.nil? }
38
+ param_string = params.to_a.map { |a| "#{ a[0] }: #{ a[1] }" }.join(", ")
39
+ puts "#{ domain } #{ status }" +
40
+ (", #{ params.to_a.map { |a| "#{ a[0] }: #{ a[1] }" }.join(", ") }")
41
+
42
+ elsif @result[:status] == :unknown
43
+ puts "#{ domain } #{ "UNKNOWN".ansi.red.negative.bold }"
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,59 @@
1
+ class DomainCheck::MultiCheck
2
+ DEFAULT_TLDS = %w(com net org biz info name)
3
+
4
+ def initialize(prefixes: nil, suffixes: nil, tlds: nil)
5
+ @prefixes = prefixes
6
+ @suffixes = suffixes
7
+ @tlds = tlds || DEFAULT_TLDS
8
+ @tlds.each { |tld| tld.sub!(/^\./, '') }
9
+ end
10
+
11
+ def check
12
+ results = []
13
+ domains.each do |domain|
14
+ result = DomainCheck::SingleCheck.new(domain).check
15
+ yield result if block_given?
16
+ results << result
17
+ end
18
+ results
19
+ end
20
+
21
+ protected
22
+
23
+ def domains
24
+ unless @domains
25
+ @prefixes.uniq! && @prefixes.sort! if @prefixes
26
+ @suffixes.uniq! && @suffixes.sort! if @suffixes
27
+ @tlds.sort! && @tlds.uniq!
28
+
29
+ if @prefixes && @suffixes
30
+ names = []
31
+ @prefixes.each do |prefix|
32
+ @suffixes.each do |suffix|
33
+ @tlds.each do |tld|
34
+ names << "#{ prefix }#{ suffix }.#{ tld }"
35
+ end
36
+ end
37
+ end
38
+ names
39
+ elsif prefixes
40
+ names = []
41
+ @prefixes.each do |prefix|
42
+ @tlds.each do |tld|
43
+ names << "#{ prefix }.#{ tld }"
44
+ end
45
+ end
46
+ elsif suffixes
47
+ names = []
48
+ @suffixes.each do |suffix|
49
+ @tlds.each do |tld|
50
+ names << "#{ prefix }#{ suffix }.#{ tld }"
51
+ end
52
+ end
53
+ names
54
+ else
55
+ []
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,31 @@
1
+ require "ansi"
2
+ require "date"
3
+ require "whois"
4
+
5
+ class DomainCheck::SingleCheck
6
+ def initialize(domain)
7
+ @domain = domain.downcase
8
+ end
9
+
10
+ def check
11
+ whois = Whois.whois(@domain)
12
+ if whois.available?
13
+ { :domain => @domain, :status => :available }
14
+ else
15
+ result = { :domain => @domain, :status => :registered }
16
+
17
+ contact = whois.registrant_contact || whois.admin_contact ||
18
+ whois.technical_contact || whois.contacts.first
19
+ result[:contact_name] = contact.name if contact
20
+ result[:contact_email] = contact.email if contact
21
+
22
+ result[:created_at] = whois.created_on
23
+ result[:expires_at] = whois.expires_on
24
+
25
+ yield(result) if block_given?
26
+ result
27
+ end
28
+ rescue Whois::Error
29
+ { :domain => @domain, :status => :unknown }
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ module DomainCheck
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,32 @@
1
+ require "yaml"
2
+
3
+ require_relative "domain_check/version"
4
+ require_relative "domain_check/console_formatter"
5
+ require_relative "domain_check/multi_check"
6
+ require_relative "domain_check/single_check"
7
+
8
+ module DomainCheck
9
+ extend self
10
+
11
+ def new(domain: nil, file: nil, prefixes: nil, suffixes: nil, tlds: nil)
12
+ if domain
13
+ SingleCheck.new(domain)
14
+ elsif file
15
+ config = parse_file(file)
16
+ MultiCheck.new(prefixes: config['prefixes'], suffixes: config['suffixes'], tlds: config['tlds'])
17
+ elsif prefixes && suffixes
18
+ MultiCheck.new(prefixes: prefixes, suffixes: suffixes, tlds: tlds)
19
+ elsif prefixes || suffixes || tlds
20
+ raise ArgumentError, "Must supply prefixes, suffixes, and TLDs"
21
+ else
22
+ raise ArgumentError, "No arguments given"
23
+ end
24
+ end
25
+
26
+ protected
27
+
28
+ def parse_file(filename)
29
+ YAML.load_file(filename)
30
+ end
31
+
32
+ end
data/sample.yml ADDED
@@ -0,0 +1,9 @@
1
+ prefixes:
2
+ - super
3
+ - mega
4
+ suffixes:
5
+ - corp
6
+ - plex
7
+ tlds:
8
+ - com
9
+ - net
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: domain_check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Kottom
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-24 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'
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Bulk checking domain availability
42
+ email:
43
+ - chris@chriskottom.com
44
+ executables:
45
+ - domain_check
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/domain_check
56
+ - domain_check.gemspec
57
+ - lib/domain_check.rb
58
+ - lib/domain_check/console_formatter.rb
59
+ - lib/domain_check/multi_check.rb
60
+ - lib/domain_check/single_check.rb
61
+ - lib/domain_check/version.rb
62
+ - sample.yml
63
+ homepage: ''
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.0.3
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Perform domain name research against a large set using combinations of relevant
87
+ keywords.
88
+ test_files: []