docheck 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/docheck CHANGED
@@ -1,33 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- begin
4
- require File.expand_path('../../lib/docheck.rb', __FILE__)
5
- rescue LoadError
6
- require 'rubygems'
7
- require File.expand_path('../../lib/docheck.rb', __FILE__)
8
- end
9
-
10
- require 'optparse'
11
-
12
- begin
13
- OptionParser.new do |opts|
14
- opts.banner = "Usage: docheck [basename]. Example: docheck google"
15
-
16
- opts.on("-v", "--version", "Show version") do
17
- puts "Docheck #{Docheck::VERSION}"
18
- end
19
-
20
- opts.on("-n", "--name NAME", "Execute domain name checker") do |name|
21
- Docheck::Application.new(name).print
22
- end
23
-
24
- opts.on_tail("-h", "--help", "Show help") do
25
- puts opts
26
- exit
27
- end
28
- end.parse!
29
- rescue OptionParser::InvalidOption
30
- puts "Invalid option"
31
- rescue OptionParser::MissingArgument
32
- puts "Missing argument"
33
- end
3
+ require File.expand_path('../../lib/docheck/command.rb', __FILE__)
data/docheck.gemspec CHANGED
@@ -1,25 +1,32 @@
1
- require File.expand_path('../version.rb', __FILE__)
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "docheck/version"
2
4
 
3
- Gem::Specification.new do |spec|
4
- spec.authors = 'Kunto Aji Kristianto'
5
- spec.add_dependency('whois', '~> 1.3.8')
6
- spec.add_development_dependency('shoulda')
7
- spec.description = <<-EOF
5
+ Gem::Specification.new do |s|
6
+ s.name = "docheck"
7
+ s.version = Docheck::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = "Kunto Aji Kristianto"
10
+ s.email = "kunto.aji.kr@gmail.com"
11
+ s.homepage = "http://github.com/kuntoaji/docheck"
12
+ s.summary = 'Domain name availability checker'
13
+ s.description = <<-EOF
8
14
  Domain name availability checker.
9
15
  EOF
10
- spec.email = 'kunto.aji.kr@gmail.com'
11
- spec.executables << 'docheck'
12
- spec.extra_rdoc_files = ['README.rdoc', 'LICENSE']
13
- spec.files = ['.gitignore', 'docheck.gemspec', 'LICENSE',
14
- 'README.rdoc', 'version.rb', 'bin/docheck', 'lib/docheck.rb',
15
- 'test/docheck_test.rb', 'test/helper.rb']
16
- spec.has_rdoc = true
17
- spec.homepage = 'http://github.com/kuntoaji/docheck'
18
- spec.name = 'docheck'
19
- spec.rdoc_options = ['--main', 'README.rdoc']
20
- spec.required_ruby_version = '>= 1.8.7'
21
- spec.requirements << 'ruby-whois, v1.3.8 or greater'
22
- spec.summary = 'Domain name availability checker.'
23
- spec.test_files = ['test/docheck_test.rb', 'test/helper.rb']
24
- spec.version = Docheck::VERSION
16
+
17
+ s.rubyforge_project = "docheck"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+
24
+ s.has_rdoc = true
25
+ s.rdoc_options = ['--main', 'README.rdoc']
26
+ s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
27
+
28
+ s.required_ruby_version = '>= 1.8.7'
29
+ s.requirements << 'ruby-whois, v1.6.6 or greater'
30
+ s.add_dependency('whois', '~> 1.6.6')
31
+ s.add_development_dependency('shoulda')
25
32
  end
@@ -0,0 +1,74 @@
1
+ module Docheck
2
+ class Application
3
+
4
+ # DNS name of the generic top-level domain
5
+ # http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
6
+ TLD = %w[aero asia biz cat com coop edu gov info
7
+ int jobs mil mobi museum name net org pro tel travel]
8
+
9
+ attr_reader :available_domains, :registered_domains
10
+
11
+ # base_name is sld (Second Level Domain) and
12
+ # converted to lower case.
13
+ def initialize(base_name)
14
+ @base_name = base_name.to_s.downcase
15
+ @available_domains = []
16
+ @registered_domains = []
17
+ end
18
+
19
+ # Print the fetch result.
20
+ def print
21
+ result = fetch
22
+
23
+ puts "\nDocheck Result\n"
24
+ puts "--------------\n"
25
+ puts "Available Domains:"
26
+ result.first.map{|domain_name| puts "- #{domain_name}"}
27
+ puts "\n"
28
+ puts "Registered Domains:"
29
+ result.last.map{|domain_name| puts "- #{domain_name}"}
30
+ end
31
+
32
+ # Check domain name availability
33
+ # and return the result as array.
34
+ #
35
+ # The first element of array will return all
36
+ # available domains as array.
37
+ #
38
+ # The last element of array will return all
39
+ # registered domains as array.
40
+ def fetch
41
+ attempts = 0
42
+ TLD.each do |tld|
43
+ domain_name = "#{@base_name}.#{tld}"
44
+ begin
45
+ whois_domain = Whois.whois(domain_name)
46
+
47
+ if whois_domain.available?
48
+ @available_domains << domain_name
49
+ elsif whois_domain.registered?
50
+ @registered_domains << domain_name
51
+ end
52
+ rescue Timeout::Error
53
+ if attempts <= 3
54
+ attempts += 1
55
+ retry
56
+ else
57
+ attempts = 0
58
+ next
59
+ end
60
+ rescue
61
+ if attempts <= 3
62
+ attempts += 1
63
+ retry
64
+ else
65
+ attempts = 0
66
+ next
67
+ end
68
+ end
69
+ end
70
+
71
+ return [@available_domains, @registered_domains]
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,31 @@
1
+ begin
2
+ require File.expand_path('../../docheck.rb', __FILE__)
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require File.expand_path('../../docheck.rb', __FILE__)
6
+ end
7
+
8
+ require 'optparse'
9
+
10
+ begin
11
+ OptionParser.new do |opts|
12
+ opts.banner = "Usage: docheck [basename]. Example: docheck google"
13
+
14
+ opts.on("-v", "--version", "Show version") do
15
+ puts "Docheck #{Docheck::VERSION}"
16
+ end
17
+
18
+ opts.on("-n", "--name NAME", "Execute domain name checker") do |name|
19
+ Docheck::Application.new(name).print
20
+ end
21
+
22
+ opts.on_tail("-h", "--help", "Show help") do
23
+ puts opts
24
+ exit
25
+ end
26
+ end.parse!
27
+ rescue OptionParser::InvalidOption
28
+ puts "Invalid option"
29
+ rescue OptionParser::MissingArgument
30
+ puts "Missing argument"
31
+ end
@@ -0,0 +1,3 @@
1
+ module Docheck
2
+ VERSION = '1.1.1'
3
+ end
data/lib/docheck.rb CHANGED
@@ -1,70 +1,6 @@
1
- # Domain name availability checker
2
- #
3
- # Author:: Kunto Aji Kristianto (mailto:kunto.aji.kr@gmail.com)
4
- # Copyright:: Copyright (c) 2010 Kunto Aji Kristianto
5
- # License:: Distributes under MIT license
1
+ libdir = File.dirname(__FILE__)
2
+ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
6
3
 
7
- require File.expand_path('../../version.rb', __FILE__)
8
4
  require 'whois'
9
-
10
- module Docheck
11
- class Application
12
-
13
- # DNS name of the generic top-level domain
14
- # http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
15
- TLD = %w[aero asia biz cat com coop edu gov info
16
- int jobs mil mobi museum name net org pro tel travel]
17
-
18
- attr_reader :available_domains, :registered_domains
19
-
20
- # base_name is sld (Second Level Domain) and
21
- # converted to lower case.
22
- def initialize(base_name)
23
- @base_name = base_name.to_s.downcase
24
- @available_domains = []
25
- @registered_domains = []
26
- end
27
-
28
- # Print the fetch result.
29
- def print
30
- result = fetch
31
-
32
- puts "\nDocheck Result\n"
33
- puts "--------------\n"
34
- puts "Available Domains:"
35
- result.first.map{|domain_name| puts "- #{domain_name}"}
36
- puts "\n"
37
- puts "Registered Domains:"
38
- result.last.map{|domain_name| puts "- #{domain_name}"}
39
- end
40
-
41
- # Check domain name availability
42
- # and return the result as array.
43
- #
44
- # The first element of array will return all
45
- # available domains as array.
46
- #
47
- # The last element of array will return all
48
- # registered domains as array.
49
- def fetch
50
- TLD.each do |tld|
51
- domain_name = "#{@base_name}.#{tld}"
52
- begin
53
- whois_domain = Whois.whois(domain_name)
54
-
55
- if whois_domain.available?
56
- @available_domains << domain_name
57
- elsif whois_domain.registered?
58
- @registered_domains << domain_name
59
- end
60
- rescue Timeout::Error
61
- next
62
- rescue
63
- next
64
- end
65
- end
66
-
67
- return [@available_domains, @registered_domains]
68
- end
69
- end
70
- end
5
+ require 'docheck/version'
6
+ require 'docheck/application'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docheck
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kunto Aji Kristianto
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-17 00:00:00 +07:00
18
+ date: 2011-01-24 00:00:00 +07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 11
29
+ hash: 3
30
30
  segments:
31
31
  - 1
32
- - 3
33
- - 8
34
- version: 1.3.8
32
+ - 6
33
+ - 6
34
+ version: 1.6.6
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -59,12 +59,16 @@ extra_rdoc_files:
59
59
  - LICENSE
60
60
  files:
61
61
  - .gitignore
62
- - docheck.gemspec
62
+ - Gemfile
63
63
  - LICENSE
64
64
  - README.rdoc
65
- - version.rb
65
+ - Rakefile
66
66
  - bin/docheck
67
+ - docheck.gemspec
67
68
  - lib/docheck.rb
69
+ - lib/docheck/application.rb
70
+ - lib/docheck/command.rb
71
+ - lib/docheck/version.rb
68
72
  - test/docheck_test.rb
69
73
  - test/helper.rb
70
74
  has_rdoc: true
@@ -98,12 +102,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
102
  - 0
99
103
  version: "0"
100
104
  requirements:
101
- - ruby-whois, v1.3.8 or greater
102
- rubyforge_project:
103
- rubygems_version: 1.3.7
105
+ - ruby-whois, v1.6.6 or greater
106
+ rubyforge_project: docheck
107
+ rubygems_version: 1.4.2
104
108
  signing_key:
105
109
  specification_version: 3
106
- summary: Domain name availability checker.
110
+ summary: Domain name availability checker
107
111
  test_files:
108
112
  - test/docheck_test.rb
109
113
  - test/helper.rb
data/version.rb DELETED
@@ -1,3 +0,0 @@
1
- module Docheck
2
- VERSION = '1.1.0'
3
- end