whos 0.1.1
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.
- data/LICENSE +19 -0
- data/README.md +1 -0
- data/Rakefile +58 -0
- data/bin/whos +84 -0
- data/lib/whos/spam.rb +24 -0
- data/lib/whos.rb +5 -0
- data/whos.gemspec +34 -0
- metadata +56 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Whos
|
|
2
|
+
Copyright (c) 2011 Alex Chaffee <alex@stinky.com>
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to
|
|
6
|
+
deal in the Software without restriction, including without limitation the
|
|
7
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
8
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
18
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wraps `whois` and removes the registrar boilerplate
|
data/Rakefile
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rake/clean'
|
|
3
|
+
require 'rake/testtask'
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
|
+
|
|
6
|
+
task :default => [:spec]
|
|
7
|
+
task :test => :spec
|
|
8
|
+
|
|
9
|
+
desc "Run all specs"
|
|
10
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
|
11
|
+
ENV['ENV'] = "test"
|
|
12
|
+
t.pattern = 'spec/**/*_spec.rb'
|
|
13
|
+
t.ruby_opts = ['-rubygems'] if defined? Gem
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
$spec =
|
|
17
|
+
begin
|
|
18
|
+
require 'rubygems/specification'
|
|
19
|
+
data = File.read('whos.gemspec')
|
|
20
|
+
spec = nil
|
|
21
|
+
Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
|
|
22
|
+
spec
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def package(ext='')
|
|
26
|
+
"pkg/#{$spec.name}-#{$spec.version}" + ext
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
desc 'Build packages'
|
|
30
|
+
task :package => %w[.gem .tar.gz].map { |e| package(e) }
|
|
31
|
+
|
|
32
|
+
desc 'Build and install as local gem'
|
|
33
|
+
task :install => package('.gem') do
|
|
34
|
+
sh "gem install #{package('.gem')}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
directory 'pkg/'
|
|
38
|
+
CLOBBER.include('pkg')
|
|
39
|
+
|
|
40
|
+
file package('.gem') => %W[pkg/ #{$spec.name}.gemspec] + $spec.files do |f|
|
|
41
|
+
sh "gem build #{$spec.name}.gemspec"
|
|
42
|
+
mv File.basename(f.name), f.name
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
file package('.tar.gz') => %w[pkg/] + $spec.files do |f|
|
|
46
|
+
cmd = <<-SH
|
|
47
|
+
git archive \
|
|
48
|
+
--prefix=#{$spec.name}-#{$spec.version}/ \
|
|
49
|
+
--format=tar \
|
|
50
|
+
HEAD | gzip > #{f.name}
|
|
51
|
+
SH
|
|
52
|
+
sh cmd.gsub(/ +/, ' ')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
desc 'Publish gem and tarball to rubyforge'
|
|
56
|
+
task 'release' => [package('.gem'), package('.tar.gz')] do |t|
|
|
57
|
+
sh "gem push #{package('.gem')}"
|
|
58
|
+
end
|
data/bin/whos
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
|
|
5
|
+
libdir = "#{File.expand_path(File.dirname(File.dirname(__FILE__)))}/lib"
|
|
6
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
|
|
7
|
+
|
|
8
|
+
load "#{libdir}/../whos.gemspec" # defines "$spec" variable, which we read the version from
|
|
9
|
+
|
|
10
|
+
require 'whos'
|
|
11
|
+
|
|
12
|
+
require 'optparse'
|
|
13
|
+
|
|
14
|
+
options = {}
|
|
15
|
+
|
|
16
|
+
opts = OptionParser.new("", 24, ' ') { |opts|
|
|
17
|
+
opts.banner = "Usage: whos domain..."
|
|
18
|
+
|
|
19
|
+
opts.separator ""
|
|
20
|
+
opts.separator "Runs 'whois domain' and then strips the registrar bullshit."
|
|
21
|
+
opts.separator "See http://github.com/alexch/whos for more info."
|
|
22
|
+
opts.separator ""
|
|
23
|
+
opts.separator "Options:"
|
|
24
|
+
|
|
25
|
+
opts.on("-v", "--verbose", "show all domain info if it exists") do
|
|
26
|
+
$verbose = true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
opts.on("-o", "--open", "open found host in web browser") do
|
|
30
|
+
$open = true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
opts.on_tail("-h", "--help", "--usage", "show this message") do
|
|
34
|
+
puts opts
|
|
35
|
+
exit
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
opts.on_tail("--version", "show version") do
|
|
39
|
+
puts $spec.version
|
|
40
|
+
exit
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
opts.parse! ARGV
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if ARGV.empty?
|
|
47
|
+
puts opts
|
|
48
|
+
exit
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@spam = Whos::Spam.new
|
|
53
|
+
|
|
54
|
+
def check domain
|
|
55
|
+
print "Checking #{domain}..."
|
|
56
|
+
response = `whois #{domain}`
|
|
57
|
+
|
|
58
|
+
if response =~ /^No match for/
|
|
59
|
+
puts " AVAILABLE!"
|
|
60
|
+
true
|
|
61
|
+
else
|
|
62
|
+
puts " exists :-("
|
|
63
|
+
if $verbose
|
|
64
|
+
response.each_line do |line|
|
|
65
|
+
puts line unless @spam.include? line.strip
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
false
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
ARGV.each do |domain|
|
|
73
|
+
if domain =~ /\./
|
|
74
|
+
check domain
|
|
75
|
+
else
|
|
76
|
+
puts "no dot in #{domain}"
|
|
77
|
+
%w{com net org biz}.each do |tld|
|
|
78
|
+
host = "#{domain}.#{tld}"
|
|
79
|
+
available = check(host)
|
|
80
|
+
`open http://#{host}` if !available and $open
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
data/lib/whos/spam.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Whos
|
|
2
|
+
class Spam
|
|
3
|
+
def initialize
|
|
4
|
+
@lines = []
|
|
5
|
+
here = File.expand_path(File.dirname(__FILE__))
|
|
6
|
+
spam_dir = "#{here}/../../spam"
|
|
7
|
+
Dir.glob("#{spam_dir}/*").each do |file|
|
|
8
|
+
puts "reading spam: #{file}"
|
|
9
|
+
read file
|
|
10
|
+
end
|
|
11
|
+
puts
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def read file
|
|
15
|
+
File.read(file).each_line do |line|
|
|
16
|
+
@lines << line.strip
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def include? s
|
|
21
|
+
@lines.include? s
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/whos.rb
ADDED
data/whos.gemspec
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
$spec = Gem::Specification.new do |s|
|
|
2
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
|
3
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
4
|
+
|
|
5
|
+
s.name = 'whos'
|
|
6
|
+
s.version = '0.1.1'
|
|
7
|
+
|
|
8
|
+
s.description = "Wraps whois and removes the BS"
|
|
9
|
+
s.summary = "Wraps whois and removes the BS."
|
|
10
|
+
|
|
11
|
+
s.authors = ["Alex Chaffee"]
|
|
12
|
+
s.email = "alex@stinky.com"
|
|
13
|
+
|
|
14
|
+
s.files = %w[
|
|
15
|
+
README.md
|
|
16
|
+
LICENSE
|
|
17
|
+
Rakefile
|
|
18
|
+
whos.gemspec
|
|
19
|
+
bin/whos
|
|
20
|
+
lib/whos.rb
|
|
21
|
+
lib/whos/spam.rb
|
|
22
|
+
]
|
|
23
|
+
s.executables = ['whos']
|
|
24
|
+
s.test_files = s.files.select {|path| path =~ /^spec\/.*_spec.rb/}
|
|
25
|
+
|
|
26
|
+
s.extra_rdoc_files = %w[README.md]
|
|
27
|
+
#s.add_dependency 'rack', '>= 0.9.1'
|
|
28
|
+
#s.add_dependency 'launchy', '>= 0.3.3', '< 1.0'
|
|
29
|
+
|
|
30
|
+
s.homepage = "http://github.com/alexch/whos/"
|
|
31
|
+
s.require_paths = %w[lib]
|
|
32
|
+
s.rubyforge_project = 'pivotalrb'
|
|
33
|
+
s.rubygems_version = '1.1.1'
|
|
34
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: whos
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Alex Chaffee
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2011-08-07 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: Wraps whois and removes the BS
|
|
15
|
+
email: alex@stinky.com
|
|
16
|
+
executables:
|
|
17
|
+
- whos
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files:
|
|
20
|
+
- README.md
|
|
21
|
+
files:
|
|
22
|
+
- README.md
|
|
23
|
+
- LICENSE
|
|
24
|
+
- Rakefile
|
|
25
|
+
- whos.gemspec
|
|
26
|
+
- bin/whos
|
|
27
|
+
- lib/whos.rb
|
|
28
|
+
- lib/whos/spam.rb
|
|
29
|
+
homepage: http://github.com/alexch/whos/
|
|
30
|
+
licenses: []
|
|
31
|
+
post_install_message:
|
|
32
|
+
rdoc_options: []
|
|
33
|
+
require_paths:
|
|
34
|
+
- lib
|
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
|
+
none: false
|
|
37
|
+
requirements:
|
|
38
|
+
- - ! '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
segments:
|
|
42
|
+
- 0
|
|
43
|
+
hash: -4463681893974033648
|
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
|
+
none: false
|
|
46
|
+
requirements:
|
|
47
|
+
- - ! '>='
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
requirements: []
|
|
51
|
+
rubyforge_project: pivotalrb
|
|
52
|
+
rubygems_version: 1.8.5
|
|
53
|
+
signing_key:
|
|
54
|
+
specification_version: 2
|
|
55
|
+
summary: Wraps whois and removes the BS.
|
|
56
|
+
test_files: []
|