whos 0.1.1 → 0.1.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.
data/README.md CHANGED
@@ -1 +1,45 @@
1
- wraps `whois` and removes the registrar boilerplate
1
+ # Summary
2
+
3
+ * wraps `whois` and removes the registrar boilerplate legal/marketing spam BS
4
+ * pass in a FQDN and it checks it
5
+ * pass in a base name and it checks for .com,.net,.org,etc.
6
+
7
+ # Install
8
+
9
+ gem install whos
10
+
11
+ ## Optional Install
12
+
13
+ echo "alias whois=whos" >> ~/.bash_profile
14
+
15
+ # Usage
16
+
17
+ `whos foo.com` - runs `whois foo.com`. If it is available, or not, it says so in a single line.
18
+
19
+ `whos -v foo.com` - If `foo.com` is not available, it shows you the whois response, minus the boilerplate legal/marketing registrar text
20
+
21
+ `whos foo` - runs `whos foo.com` then `whos foo.com` then `whos foo.net` then `whos foo.org` etc.
22
+
23
+ `whos -o foo.com` - If `foo.com` is taken, opens `http://foo.com` in a browser
24
+
25
+ Multiple args work as expected.
26
+
27
+ # Got more spam?
28
+
29
+ Fork <http://github.com/alexch/whos> on github, add a file to the spam folder, run `rake install`, then send me a pull request
30
+
31
+ # Credits
32
+
33
+ Written in a fit of pique by Alex Chaffee <http://alexch.github.com>
34
+
35
+ # Possible Improvements
36
+
37
+ * shared spam db _a la_ [cheat](http://cheat.errtheblog.com)
38
+
39
+ # Release History
40
+
41
+ == 0.1.2 2011/08/07
42
+
43
+ First real release
44
+
45
+
data/Rakefile CHANGED
@@ -15,10 +15,10 @@ end
15
15
 
16
16
  $spec =
17
17
  begin
18
- require 'rubygems/specification'
18
+ require 'rubygems/specification'
19
19
  data = File.read('whos.gemspec')
20
20
  spec = nil
21
- Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
21
+ Thread.new { spec = eval("$SAFE = 2\n#{data}") }.join
22
22
  spec
23
23
  end
24
24
 
@@ -52,7 +52,66 @@ file package('.tar.gz') => %w[pkg/] + $spec.files do |f|
52
52
  sh cmd.gsub(/ +/, ' ')
53
53
  end
54
54
 
55
- desc 'Publish gem and tarball to rubyforge'
56
- task 'release' => [package('.gem'), package('.tar.gz')] do |t|
55
+ module System
56
+ def sys(cmd, *flags)
57
+ fail_ok = flags.include? :fail_ok
58
+ quiet = flags.include? :quiet
59
+ puts ">> #{cmd}" unless quiet
60
+ result = `#{cmd}`
61
+ raise "#{cmd} failed with exit status #{$?.exitstatus}" unless $?.success? || fail_ok
62
+ result.chomp
63
+ end
64
+
65
+ def find_git
66
+ dirs = ["", "/opt/local/bin/", "/usr/local/bin/", "/usr/bin/"]
67
+ dirs.each do |dir|
68
+ file = dir + "git"
69
+ if File.exist?(file)
70
+ return file
71
+ end
72
+ end
73
+ raise "Couldn't find git in #{dirs.inspect}"
74
+ end
75
+
76
+ def git(cmd, *flags)
77
+ flags << :fail_ok # why?
78
+ bin = @git_bin || find_git
79
+ sys("#{bin} #{cmd}", *flags)
80
+ end
81
+
82
+ def git_clean?
83
+ out = git("status --porcelain", :quiet)
84
+ out.strip == ""
85
+ end
86
+
87
+ def git_branch
88
+ git("branch").split.last
89
+ end
90
+
91
+ def heroku(cmd)
92
+ sys("heroku #{cmd}")
93
+ end
94
+
95
+ def timed(msg)
96
+ start =Time.now
97
+ puts "#{msg} starting"
98
+ yield
99
+ dur = Time.now - start
100
+ puts "#{msg} took %d:%02d" % [dur / 60, dur % 60]
101
+ end
102
+ end
103
+
104
+ task :tag do
105
+ include System
106
+ unless git_clean?
107
+ warn "Can't tag an unclean git repo."
108
+ puts git( "status --short")
109
+ exit 1
110
+ end
111
+ git "tag --force v#{$spec.version}", false
112
+ end
113
+
114
+ desc 'Tag and publish gem to rubygems'
115
+ task 'release' => [package('.gem'), package('.tar.gz'), :tag] do
57
116
  sh "gem push #{package('.gem')}"
58
117
  end
data/bin/whos CHANGED
@@ -26,7 +26,7 @@ opts = OptionParser.new("", 24, ' ') { |opts|
26
26
  $verbose = true
27
27
  end
28
28
 
29
- opts.on("-o", "--open", "open found host in web browser") do
29
+ opts.on("-o", "--open", "open found host(s) in web browser") do
30
30
  $open = true
31
31
  end
32
32
 
@@ -46,39 +46,6 @@ opts = OptionParser.new("", 24, ' ') { |opts|
46
46
  if ARGV.empty?
47
47
  puts opts
48
48
  exit
49
+ else
50
+ Whos::Check.new.many(ARGV)
49
51
  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/check.rb ADDED
@@ -0,0 +1,42 @@
1
+ module Whos
2
+ class Check
3
+ def initialize
4
+ @spam = Whos::Spam.new
5
+ end
6
+
7
+ def available? domain
8
+ print "Checking #{domain}..."
9
+ response = `whois #{domain}`
10
+
11
+ if response =~ /^No match for/
12
+ puts " AVAILABLE!"
13
+ true
14
+ else
15
+ puts " exists :-("
16
+ if $verbose
17
+ puts @spam.filter(response)
18
+ end
19
+ false
20
+ end
21
+ end
22
+
23
+ def many names
24
+ domains = names.map do |domain|
25
+ if domain =~ /\./
26
+ domain
27
+ else
28
+ %w{com net org biz}.map do |tld|
29
+ "#{domain}.#{tld}"
30
+ end
31
+ end
32
+ end.flatten
33
+
34
+ domains.each do |domain|
35
+ available = available? domain
36
+ `open http://#{host}` if !available and $open
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+
data/lib/whos/spam.rb CHANGED
@@ -5,20 +5,25 @@ module Whos
5
5
  here = File.expand_path(File.dirname(__FILE__))
6
6
  spam_dir = "#{here}/../../spam"
7
7
  Dir.glob("#{spam_dir}/*").each do |file|
8
- puts "reading spam: #{file}"
9
8
  read file
10
9
  end
11
- puts
12
10
  end
13
11
 
14
12
  def read file
15
13
  File.read(file).each_line do |line|
16
- @lines << line.strip
14
+ @lines << line.chomp.strip
17
15
  end
18
16
  end
19
17
 
20
18
  def include? s
21
- @lines.include? s
19
+ @lines.include? s.strip
20
+ end
21
+
22
+ def filter s
23
+ s.each_line.reject do |line|
24
+ line.chomp!
25
+ include? line
26
+ end.join("\n")
22
27
  end
23
28
  end
24
29
  end
data/lib/whos.rb CHANGED
@@ -2,4 +2,4 @@ here = File.expand_path(File.dirname(__FILE__))
2
2
  $: << here unless $:.include?(here)
3
3
 
4
4
  require "whos/spam"
5
-
5
+ require "whos/check"
data/whos.gemspec CHANGED
@@ -3,10 +3,10 @@ $spec = Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'whos'
6
- s.version = '0.1.1'
6
+ s.version = '0.1.2'
7
7
 
8
8
  s.description = "Wraps whois and removes the BS"
9
- s.summary = "Wraps whois and removes the BS."
9
+ s.summary = "Wraps whois and removes the registrar legal/marketing spam from the response."
10
10
 
11
11
  s.authors = ["Alex Chaffee"]
12
12
  s.email = "alex@stinky.com"
@@ -16,10 +16,7 @@ $spec = Gem::Specification.new do |s|
16
16
  LICENSE
17
17
  Rakefile
18
18
  whos.gemspec
19
- bin/whos
20
- lib/whos.rb
21
- lib/whos/spam.rb
22
- ]
19
+ bin/whos] + Dir.glob("lib/**/*.rb")
23
20
  s.executables = ['whos']
24
21
  s.test_files = s.files.select {|path| path =~ /^spec\/.*_spec.rb/}
25
22
 
@@ -29,6 +26,5 @@ $spec = Gem::Specification.new do |s|
29
26
 
30
27
  s.homepage = "http://github.com/alexch/whos/"
31
28
  s.require_paths = %w[lib]
32
- s.rubyforge_project = 'pivotalrb'
33
29
  s.rubygems_version = '1.1.1'
34
30
  end
metadata CHANGED
@@ -1,56 +1,74 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: whos
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 2
10
+ version: 0.1.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Alex Chaffee
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-08-07 00:00:00.000000000 Z
17
+
18
+ date: 2011-08-07 00:00:00 -07:00
19
+ default_executable:
13
20
  dependencies: []
21
+
14
22
  description: Wraps whois and removes the BS
15
23
  email: alex@stinky.com
16
- executables:
24
+ executables:
17
25
  - whos
18
26
  extensions: []
19
- extra_rdoc_files:
27
+
28
+ extra_rdoc_files:
20
29
  - README.md
21
- files:
30
+ files:
22
31
  - README.md
23
32
  - LICENSE
24
33
  - Rakefile
25
34
  - whos.gemspec
26
35
  - bin/whos
27
- - lib/whos.rb
36
+ - lib/whos/check.rb
28
37
  - lib/whos/spam.rb
38
+ - lib/whos.rb
39
+ has_rdoc: true
29
40
  homepage: http://github.com/alexch/whos/
30
41
  licenses: []
42
+
31
43
  post_install_message:
32
44
  rdoc_options: []
33
- require_paths:
45
+
46
+ require_paths:
34
47
  - lib
35
- required_ruby_version: !ruby/object:Gem::Requirement
48
+ required_ruby_version: !ruby/object:Gem::Requirement
36
49
  none: false
37
- requirements:
38
- - - ! '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- segments:
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
42
55
  - 0
43
- hash: -4463681893974033648
44
- required_rubygems_version: !ruby/object:Gem::Requirement
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
58
  none: false
46
- requirements:
47
- - - ! '>='
48
- - !ruby/object:Gem::Version
49
- version: '0'
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
50
66
  requirements: []
51
- rubyforge_project: pivotalrb
52
- rubygems_version: 1.8.5
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.6.2
53
70
  signing_key:
54
71
  specification_version: 2
55
- summary: Wraps whois and removes the BS.
72
+ summary: Wraps whois and removes the registrar legal/marketing spam from the response.
56
73
  test_files: []
74
+