domr 0.2.3 → 0.3.0
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/Gemfile +10 -10
- data/bin/domr +18 -17
- data/index +8 -8
- data/lib/domr.rb +51 -65
- metadata +2 -2
data/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
gem "rspec"
|
4
|
-
gem "rainbow"
|
5
|
-
gem "
|
6
|
-
|
7
|
-
platforms :mswin, :mingw do
|
8
|
-
gem "windows-pr"
|
9
|
-
gem "win32console"
|
10
|
-
end
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "rspec"
|
4
|
+
gem "rainbow"
|
5
|
+
gem "httparty"
|
6
|
+
|
7
|
+
platforms :mswin, :mingw do
|
8
|
+
gem "windows-pr"
|
9
|
+
gem "win32console"
|
10
|
+
end
|
data/bin/domr
CHANGED
@@ -1,17 +1,18 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), %w[.. lib])
|
4
|
+
require 'domr'
|
5
|
+
|
6
|
+
# Check for empty query
|
7
|
+
if !ARGV[0]
|
8
|
+
arg = ''
|
9
|
+
else
|
10
|
+
arg = ARGV.join " "
|
11
|
+
end
|
12
|
+
|
13
|
+
# Perform the search
|
14
|
+
if domr(arg) == false
|
15
|
+
exit 1 # Exit with code 1 (error)
|
16
|
+
else
|
17
|
+
exit 0 # Exit with code 0 (success)
|
18
|
+
end
|
data/index
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
Simple search for domain names
|
2
|
-
|
3
|
-
Usage:
|
4
|
-
|
5
|
-
$ domr <name>
|
6
|
-
|
7
|
-
Example:
|
8
|
-
|
1
|
+
Simple search for domain names
|
2
|
+
|
3
|
+
Usage:
|
4
|
+
|
5
|
+
$ domr <name>
|
6
|
+
|
7
|
+
Example:
|
8
|
+
|
9
9
|
$ domr example.com
|
data/lib/domr.rb
CHANGED
@@ -1,65 +1,51 @@
|
|
1
|
-
require 'rainbow'
|
2
|
-
require 'uri'
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
else
|
53
|
-
color = :default
|
54
|
-
end
|
55
|
-
|
56
|
-
# Construct final output string
|
57
|
-
string = ' ' << result['domain'] << ' ' << result['availability']
|
58
|
-
|
59
|
-
# Output colorized string
|
60
|
-
puts string.color(color).bright if !silent
|
61
|
-
end
|
62
|
-
|
63
|
-
# Return number of available domain names
|
64
|
-
return results.count { |result| result['availability'] == 'available' }
|
65
|
-
end
|
1
|
+
require 'rainbow'
|
2
|
+
require 'uri'
|
3
|
+
require 'httparty'
|
4
|
+
|
5
|
+
# Perform a query on domainr API
|
6
|
+
|
7
|
+
#
|
8
|
+
# Example:
|
9
|
+
# >> domr "example"
|
10
|
+
# => 1
|
11
|
+
#
|
12
|
+
# Arguments:
|
13
|
+
# query: (String)
|
14
|
+
# flag: (:none or :silent)
|
15
|
+
def domr(query, flag = :none)
|
16
|
+
|
17
|
+
# Activate silent mode if flag is set
|
18
|
+
if flag == :silent
|
19
|
+
silent = true
|
20
|
+
else
|
21
|
+
silent = false
|
22
|
+
end
|
23
|
+
|
24
|
+
# Query the Domainr API
|
25
|
+
results = HTTParty.get('http://domai.nr/api/json/search?q=' << URI.escape(query))['results'];
|
26
|
+
|
27
|
+
# Output results
|
28
|
+
results.each do |result|
|
29
|
+
|
30
|
+
# Determine color to show
|
31
|
+
case result['availability']
|
32
|
+
when 'available'
|
33
|
+
color = :green
|
34
|
+
when 'taken', 'unavailable'
|
35
|
+
color = :red
|
36
|
+
when 'maybe'
|
37
|
+
color = :yellow
|
38
|
+
else
|
39
|
+
color = :default
|
40
|
+
end
|
41
|
+
|
42
|
+
# Construct final output string
|
43
|
+
string = ' ' << result['domain'] << ' ' << result['availability']
|
44
|
+
|
45
|
+
# Output colorized string
|
46
|
+
puts string.color(color).bright if !silent
|
47
|
+
end
|
48
|
+
|
49
|
+
# Return number of available domain names
|
50
|
+
return results.count { |result| result['availability'] == 'available' }
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: domr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ cert_chain: []
|
|
12
12
|
date: 2012-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: httparty
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|