malcolmx 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock ADDED
@@ -0,0 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ malcolmx (0.0.2)
5
+ crack
6
+ httparty
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ crack (0.1.8)
12
+ httparty (0.6.1)
13
+ crack (= 0.1.8)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ crack
20
+ httparty
21
+ malcolmx!
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ MalcolmX
2
+ ========
3
+ MalcolmX is a *cli* to [instantdomainsearch.com](http://instantdomainsearch.com),
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
6
+
7
+ malcolmx cosmicvent minhajuddin myfunkyfreakydomain
8
+
9
+ Thats it! Enjoy :)
data/bin/malcolmx CHANGED
@@ -1,5 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.join(File.expand_path(File.dirname(__FILE__)), '../lib/malcolmx')
4
- puts MalcolmX::find(ARGV[0]).inspect
5
4
 
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
@@ -1,3 +1,3 @@
1
1
  module Malcolmx
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/malcolmx.rb CHANGED
@@ -3,8 +3,35 @@ module MalcolmX
3
3
  require 'httparty'
4
4
  require 'crack/json'
5
5
 
6
- def self.find(domain_name)
7
- response = HTTParty.get("http://instantdomainsearch.com/services/quick/?name=vabhub")
6
+ def self.find(domain_names = [], &block)
7
+ if domain_names.empty?
8
+ print_instructions
9
+ return
10
+ end
11
+
12
+ domain_names.collect do |domain|
13
+ response = lookup(domain)
14
+ response.delete("name")
15
+ parsed_response = response.collect do |tld, status|
16
+ {
17
+ :domain => "#{domain}.#{tld}",
18
+ :available => status == "a"
19
+ }
20
+ end
21
+ yield(parsed_response)
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def self.lookup(domain)
28
+ response = HTTParty.get("http://instantdomainsearch.com/services/quick/?name=#{domain}")
8
29
  json_response = Crack::JSON.parse(response.body)
9
30
  end
31
+
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
10
37
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Khaja Minhajuddin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-24 00:00:00 +05:30
17
+ date: 2010-12-25 00:00:00 +05:30
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -55,6 +55,8 @@ extra_rdoc_files: []
55
55
  files:
56
56
  - .gitignore
57
57
  - Gemfile
58
+ - Gemfile.lock
59
+ - README.md
58
60
  - Rakefile
59
61
  - bin/malcolmx
60
62
  - lib/malcolmx.rb