davail 1.0.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.
- checksums.yaml +7 -0
- data/LICENSE.md +21 -0
- data/README.md +45 -0
- data/bin/davail +142 -0
- data/lib/davail.rb +54 -0
- data/lib/davail/version.rb +5 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9cfa44a4492aae8ce9caf7f10c9823db00af7964
|
4
|
+
data.tar.gz: 33fc8544ee8f6526f6785c049612ff8330da0cdf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ca2556649094cb9f035a88cb886d7ea1525818f05e5f046f860ec4894f533473cd119db66e0f8a43b02c0a188f6294d2d6a0b629e90b70aceab4f85403d31696
|
7
|
+
data.tar.gz: 2464dd14f3da241ddc43da4948c9351c28cb484ad2330d3e297ce1d5b5cfc203426c1d3a3aa3a3c36c5db6902a059725f86cf0933e3c73bd1ca06210a79d9494
|
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Jakob Alminde
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# `davail` 1.0
|
2
|
+
|
3
|
+
**`davail`** is a command line utility for easily determining domain name availability.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Run `gem install davail`.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
```
|
12
|
+
davail [options...] names...
|
13
|
+
|
14
|
+
-h, --help Display this help and exit
|
15
|
+
-v, --version Display version and exit
|
16
|
+
|
17
|
+
-a, --all-tlds Check all TLDs
|
18
|
+
|
19
|
+
-b, --blink-available Blink when available
|
20
|
+
|
21
|
+
-e, --detailed-errors Detailed error messages
|
22
|
+
```
|
23
|
+
|
24
|
+
## Configuration
|
25
|
+
|
26
|
+
Place a YAML file at `~/.davailrc`, e.g.:
|
27
|
+
|
28
|
+
```yaml
|
29
|
+
data_format: '%e %b %Y'
|
30
|
+
queried_tlds: [org com lol codes]
|
31
|
+
result_delimiter: " "
|
32
|
+
```
|
33
|
+
|
34
|
+
## Requirements
|
35
|
+
|
36
|
+
Only tested on Ruby 2.2.3.
|
37
|
+
|
38
|
+
## Known Issues
|
39
|
+
|
40
|
+
* Tests are missing.
|
41
|
+
* Specific domains can’t be looked up like `davail foo.com bar.net`.
|
42
|
+
* Lookups are not asynchronous.
|
43
|
+
* Proper config options documentation is missing.
|
44
|
+
* Everything shouldn’t be in `bin`.
|
45
|
+
* That whole `rescue Interrupt` thing is hopefully superfluous.
|
data/bin/davail
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require_relative '../lib/davail'
|
5
|
+
|
6
|
+
begin
|
7
|
+
module Davail
|
8
|
+
def self.activity! &block
|
9
|
+
return block.call unless !ACTIVITY_STYLE
|
10
|
+
|
11
|
+
begin
|
12
|
+
Thread.new(&block).tap do |thread|
|
13
|
+
thread.priority = 9000
|
14
|
+
indicator = ACTIVITY_INDICATORS[ACTIVITY_STYLE].dup
|
15
|
+
|
16
|
+
while thread.alive?
|
17
|
+
ACTIVITY_INDICATOR.each do |frame|
|
18
|
+
print indicator.first + " "
|
19
|
+
sleep 0.05
|
20
|
+
print ?\b * 2
|
21
|
+
|
22
|
+
indicator.push indicator.shift
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
thread.join
|
27
|
+
end
|
28
|
+
rescue Whois::Error => e
|
29
|
+
puts Rainbow(e.message).yellow
|
30
|
+
abort
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Options = {}
|
35
|
+
|
36
|
+
begin
|
37
|
+
OptionParser.new do |o|
|
38
|
+
o.banner = "#{USAGE}\nDetermine domain name availability."
|
39
|
+
|
40
|
+
o.separator ''
|
41
|
+
o.on '-h', '--help', "Display this help and exit" do puts o; exit end
|
42
|
+
o.on '-v', '--version', "Display version and exit" do puts "davail #{VERSION * ?.}"; exit end
|
43
|
+
|
44
|
+
o.separator ''
|
45
|
+
o.on '-a', '--all-tlds', "Check all TLDs" do Options[:check_all] = true end
|
46
|
+
|
47
|
+
o.separator ''
|
48
|
+
o.on '-b', '--blink-available', "Blink when available" do Options[:blink_available] = true end
|
49
|
+
# o.on '-S', '--activity style', "Activity indicator style" do |value| Options[:activity_style] = value end
|
50
|
+
|
51
|
+
o.separator ''
|
52
|
+
o.on '-e', '--detailed-errors', "Detailed error messages" do Options[:error_details] = true end
|
53
|
+
end.parse! ARGV
|
54
|
+
rescue OptionParser::InvalidOption => e
|
55
|
+
warn "#{File.basename $0}: #{e.message.capitalize}"
|
56
|
+
abort
|
57
|
+
end
|
58
|
+
|
59
|
+
if ARGV.empty?
|
60
|
+
puts USAGE
|
61
|
+
puts "Try davail --help for more information."
|
62
|
+
abort
|
63
|
+
end
|
64
|
+
|
65
|
+
@tlds = QUERIED_TLDS
|
66
|
+
|
67
|
+
if Options[:check_all]
|
68
|
+
# FIXME: Investigate what this lines does, exactly…
|
69
|
+
@tlds = ALL_TLDS.map { |t| t[1..-1] }#.reject { |t| t.length > 4 }
|
70
|
+
end
|
71
|
+
|
72
|
+
@start_time = Time.now
|
73
|
+
|
74
|
+
@client = Whois::Client.new
|
75
|
+
@domains = Hash.new { |h, k| h[k] = [] }
|
76
|
+
|
77
|
+
ARGV.each do |sld|
|
78
|
+
@tlds.each do |tld|
|
79
|
+
@domains[sld] << tld
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
@domains.each_with_index do |(sld, tlds), sld_index|
|
84
|
+
print RESULT_SPARATOR if RESULT_SPARATOR and not sld_index.zero?
|
85
|
+
|
86
|
+
domains = tlds.map { |tld| SimpleIDN.to_unicode %{#{sld}.#{tld}} }
|
87
|
+
column_width = domains.group_by(&:length).max.first + RESULT_DELIMITER.length
|
88
|
+
|
89
|
+
domains.each do |domain|
|
90
|
+
begin
|
91
|
+
print Rainbow(%Q{#{domain}#{RESULT_DELIMITER}}.ljust(column_width)).bright
|
92
|
+
|
93
|
+
# TODO: Async & throbbers
|
94
|
+
# activity! { record = @client.lookup domain }
|
95
|
+
|
96
|
+
record = @client.lookup domain
|
97
|
+
|
98
|
+
if record.available?
|
99
|
+
if Options[:blink_available]
|
100
|
+
print Rainbow("Available").green.blink
|
101
|
+
else
|
102
|
+
print Rainbow("Available").green
|
103
|
+
end
|
104
|
+
else
|
105
|
+
print Rainbow("Unavailable").red
|
106
|
+
print Rainbow(" until #{record.expires_on.strftime DATE_FORMAT}").italic unless record.expires_on.nil?
|
107
|
+
end
|
108
|
+
|
109
|
+
puts
|
110
|
+
rescue Timeout::Error
|
111
|
+
puts Rainbow("Timeout").yellow; next
|
112
|
+
rescue Whois::ResponseIsThrottled
|
113
|
+
puts Rainbow("Throttled").yellow; next
|
114
|
+
rescue Whois::NoInterfaceError
|
115
|
+
puts Rainbow("No interface").yellow; next
|
116
|
+
rescue Whois::WebInterfaceError => e
|
117
|
+
print Rainbow("No interface").yellow
|
118
|
+
print " (see #{e.url} instead)" unless e.url.nil?
|
119
|
+
puts; next
|
120
|
+
rescue StandardError => e
|
121
|
+
message = if Options[:error_details] and e.message.present?
|
122
|
+
e.message.gsub(/\n/, " ").strip
|
123
|
+
else
|
124
|
+
"Error"
|
125
|
+
end
|
126
|
+
print Rainbow(message).yellow
|
127
|
+
puts; next
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
if SHOW_LOOKUP_TIME
|
133
|
+
@domains_count = @domains.values.flatten(1).length
|
134
|
+
puts "\nQueried #@domains_count name#{"s" unless @domains_count == 1} in #{(Time.now - @start_time).round 2} seconds"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
rescue LoadError => e
|
138
|
+
warn "#{File.basename $0}: Missing dependency: #{e.message.gsub /.* -- /, ''}"
|
139
|
+
abort
|
140
|
+
rescue Interrupt
|
141
|
+
puts
|
142
|
+
end
|
data/lib/davail.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative 'davail/version'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'pp'
|
5
|
+
require 'yaml'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
require 'active_support/core_ext/object/blank'
|
9
|
+
require 'active_support/core_ext/hash/keys'
|
10
|
+
|
11
|
+
require 'rainbow'
|
12
|
+
require 'simpleidn'
|
13
|
+
require 'whois'
|
14
|
+
|
15
|
+
module Davail
|
16
|
+
begin
|
17
|
+
ALL_TLDS = Whois::Server.definitions[:tld].reject { |t| t[1].nil? }.map(&:first).freeze
|
18
|
+
rescue Whois::Error => e
|
19
|
+
puts Rainbow(e.message).yellow
|
20
|
+
abort
|
21
|
+
end
|
22
|
+
|
23
|
+
DEFAULT_QUERIED_TLDS = %w[com net org co].freeze
|
24
|
+
|
25
|
+
DEFAULT_RESULT_COLORS = {
|
26
|
+
|
27
|
+
}.freeze
|
28
|
+
|
29
|
+
ACTIVITY_INDICATORS = {
|
30
|
+
slash: %w[ | / - \\ ],
|
31
|
+
circle: %w[ ◐ ◓ ◑ ◒ ],
|
32
|
+
bar: %w[ ▃ ▄ ▅ ▆ ▇ ▆ ▅ ▄ ],
|
33
|
+
dots: %w[ ⣾ ⣽ ⣻ ⢿ ⡿ ⣟ ⣯ ⣷ ],
|
34
|
+
dot: %w[ ⠁ ⠂ ⠄ ⡀ ⢀ ⠠ ⠐ ⠈ ],
|
35
|
+
lines: %w[ ┤ ┘ ┴ └ ├ ┌ ┬ ┐ ]
|
36
|
+
}.freeze
|
37
|
+
|
38
|
+
RC_PATH = File.expand_path(File.join '~', '.davailrc').freeze
|
39
|
+
RC_FILE = (YAML.load_file(RC_PATH).deep_symbolize_keys rescue {}).freeze
|
40
|
+
|
41
|
+
DATE_FORMAT = RC_FILE[:date_format] || '%-d %b %Y'
|
42
|
+
QUERIED_TLDS = RC_FILE[:queried_tlds] || DEFAULT_QUERIED_TLDS
|
43
|
+
RESULT_COLORS = RC_FILE[:result_colors] || DEFAULT_RESULT_COLORS
|
44
|
+
RESULT_SPARATOR = RC_FILE[:result_separator] || "\n"
|
45
|
+
RESULT_DELIMITER = RC_FILE[:result_delimiter] || ": "
|
46
|
+
ACTIVITY_STYLE = RC_FILE[:activity_style] || false
|
47
|
+
SHOW_LOOKUP_TIME = RC_FILE[:show_lookup_time] || false
|
48
|
+
end
|
49
|
+
rescue LoadError => e
|
50
|
+
warn "#{File.basename $0}: Missing dependency: #{e.message.gsub /.* -- /, ''}"
|
51
|
+
abort
|
52
|
+
rescue Interrupt
|
53
|
+
puts
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: davail
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jakob
|
8
|
+
- Alminde
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-10-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '4.2'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '4.2'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rainbow
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '2.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: simpleidn
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.0.5
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.0.5
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: whois
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.4'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.4'
|
70
|
+
description: A command line utility for easily determining domain name availability.
|
71
|
+
email:
|
72
|
+
- jakob@alminde.org
|
73
|
+
executables:
|
74
|
+
- davail
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- LICENSE.md
|
79
|
+
- README.md
|
80
|
+
- bin/davail
|
81
|
+
- lib/davail.rb
|
82
|
+
- lib/davail/version.rb
|
83
|
+
homepage: https://github.com/alminde/davail
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.5.1
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Determine domain name availability.
|
107
|
+
test_files: []
|