malcolmx 0.0.3 → 0.0.4

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
@@ -2,8 +2,8 @@ MalcolmX
2
2
  ========
3
3
  MalcolmX is a *cli* to [instantdomainsearch.com](http://instantdomainsearch.com),
4
4
  it allows you to check if a given set of domain names are available. To start
5
- using malcolmx install it via rubygems, and run
5
+ using malcolmx install it via rubygems, and start using it like this:
6
6
 
7
7
  malcolmx cosmicvent minhajuddin myfunkyfreakydomain
8
8
 
9
- Thats it! Enjoy :)
9
+ Enjoy :)
data/bin/malcolmx CHANGED
@@ -1,17 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.join(File.expand_path(File.dirname(__FILE__)), '../lib/malcolmx')
4
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../lib/cli')
4
5
 
5
- def colorize(text, color_code)
6
- "\e[#{color_code}m#{text}\e[0m"
7
- end
8
-
9
- def red(text); colorize(text, 31); end
10
- def green(text); colorize(text, 32); end
11
-
12
- MalcolmX::find(ARGV) do |response|
13
- response.each do |x|
14
- text = "#{x[:domain]} => #{x[:available] ? "available" : "unavailable"}"
15
- puts x[:available] ? green(text) : red(text)
16
- end
17
- end
6
+ Cli.new.execute
data/lib/cli.rb ADDED
@@ -0,0 +1,46 @@
1
+ class Cli
2
+ COLORS = { :green => 32, :red => 31 }
3
+
4
+ def execute
5
+ validate!
6
+ if ARGV[0] == '--help' || ARGV[0] == '-h'
7
+ print_instructions
8
+ exit 0
9
+ end
10
+ MalcolmX::find(ARGV) do |response|
11
+ response.each do |x|
12
+ text = "#{x[:domain]} => #{x[:available] ? "available" : "unavailable"}"
13
+ color = x[:available] ? :green : :red
14
+ puts colorize(text, color)
15
+ end
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def validate!
22
+ if ARGV.empty?
23
+ puts "invalid number of arguments\n"
24
+ print_instructions
25
+ exit 1
26
+ end
27
+ end
28
+
29
+
30
+ def colorize(text, color)
31
+ "\e[#{COLORS[color]}m#{text}\e[0m"
32
+ end
33
+
34
+ def print_instructions
35
+ puts <<EOF
36
+ MalcolmX is a *cli* to [instantdomainsearch.com](http://instantdomainsearch.com),
37
+ it allows you to check if a given set of domain names are available. To start
38
+ using malcolmx install it via rubygems, and start using it like this:
39
+
40
+ malcolmx cosmicvent minhajuddin myfunkyfreakydomain
41
+
42
+ Enjoy :)
43
+ EOF
44
+ end
45
+
46
+ end
@@ -1,3 +1,3 @@
1
1
  module Malcolmx
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/malcolmx.rb CHANGED
@@ -4,11 +4,6 @@ module MalcolmX
4
4
  require 'crack/json'
5
5
 
6
6
  def self.find(domain_names = [], &block)
7
- if domain_names.empty?
8
- print_instructions
9
- return
10
- end
11
-
12
7
  domain_names.collect do |domain|
13
8
  response = lookup(domain)
14
9
  response.delete("name")
@@ -29,9 +24,4 @@ module MalcolmX
29
24
  json_response = Crack::JSON.parse(response.body)
30
25
  end
31
26
 
32
- def self.print_instructions
33
- puts <<EOF
34
- MalcolmX is a cli utility which allows you to check if a domain name is available
35
- EOF
36
- end
37
27
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Khaja Minhajuddin
@@ -59,6 +59,7 @@ files:
59
59
  - README.md
60
60
  - Rakefile
61
61
  - bin/malcolmx
62
+ - lib/cli.rb
62
63
  - lib/malcolmx.rb
63
64
  - lib/malcolmx/version.rb
64
65
  - malcolmx.gemspec