domr 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/domr +12 -12
  2. data/lib/domr.rb +68 -68
  3. metadata +6 -28
data/bin/domr CHANGED
@@ -1,13 +1,13 @@
1
- #!/usr/bin/env ruby
2
- require 'domr'
3
-
4
- # Check for empty query
5
- if !ARGV[0]
6
- puts "Please enter a name".color(:red).bright
7
-
8
- # Exit the program
9
- exit
10
- end
11
-
12
- # Perform the search
1
+ #!/usr/bin/env ruby
2
+ require 'domr'
3
+
4
+ # Check for empty query
5
+ if !ARGV[0]
6
+ puts "Please enter a name".color(:red).bright
7
+
8
+ # Exit the program
9
+ exit
10
+ end
11
+
12
+ # Perform the search
13
13
  Domr.search ARGV[0]
data/lib/domr.rb CHANGED
@@ -1,69 +1,69 @@
1
- # Domr
2
- # By Nick Shvelidze
3
- # Simple search for domain names
4
- # Command-Line usage:
5
- # domr example.com
6
- # => example.com is taken
7
-
8
- require 'rainbow'
9
- require 'uri'
10
- require 'net/http'
11
- require 'json'
12
-
13
- # Simple search for domain names
14
- # The main class
15
- # Usage:
16
- # Domr.search(query)
17
- class Domr
18
-
19
- # Perform a query on domainr API
20
- #
21
- # Example:
22
- # >> Domr.search "exapmle"
23
- # => example.com taken
24
- #
25
- # Arguments:
26
- # query: (String)
27
- def self.search query
28
-
29
- # Output a newline
30
- puts "\n"
31
-
32
- # Form the request string
33
- request = Net::HTTP::Get.new("/api/json/search?q=" << URI.escape(query))
34
-
35
- # Perform the actual query
36
- response = Net::HTTP.start("domai.nr") { |http|
37
- http.request request
38
- }
39
-
40
- # Check for errors
41
- if response.code != "200"
42
- puts "HTTP error".color(:red).bright # Color is red
43
-
44
- # Exit the program
45
- exit
46
- end
47
-
48
- # Output results
49
- JSON.parse(response.body)['results'].each do |result|
50
-
51
- # Determine color to show
52
- if result['availability'] == 'available'
53
- color = :green
54
- elsif result['availability'] == 'taken' || result['availability'] == 'unavailable'
55
- color = :red
56
- elsif result['availability'] == 'maybe'
57
- color = :yellow
58
- else
59
- color = :default
60
- end
61
-
62
- # Construct final output string
63
- string = " " << result['domain'] << " " << result['availability']
64
-
65
- # Output colorized string
66
- puts string.color(color).bright
67
- end
68
- end
1
+ # Domr
2
+ # By Nick Shvelidze
3
+ # Simple search for domain names
4
+ # Command-Line usage:
5
+ # domr example.com
6
+ # => example.com is taken
7
+
8
+ require 'rainbow'
9
+ require 'uri'
10
+ require 'net/http'
11
+ require 'json'
12
+
13
+ # Simple search for domain names
14
+ # The main class
15
+ # Usage:
16
+ # Domr.search(query)
17
+ class Domr
18
+
19
+ # Perform a query on domainr API
20
+ #
21
+ # Example:
22
+ # >> Domr.search "exapmle"
23
+ # => example.com taken
24
+ #
25
+ # Arguments:
26
+ # query: (String)
27
+ def self.search query
28
+
29
+ # Output a newline
30
+ puts "\n"
31
+
32
+ # Form the request string
33
+ request = Net::HTTP::Get.new("/api/json/search?q=" << URI.escape(query))
34
+
35
+ # Perform the actual query
36
+ response = Net::HTTP.start("domai.nr") { |http|
37
+ http.request request
38
+ }
39
+
40
+ # Check for errors
41
+ if response.code != "200"
42
+ puts "HTTP error".color(:red).bright # Color is red
43
+
44
+ # Exit the program
45
+ exit
46
+ end
47
+
48
+ # Output results
49
+ JSON.parse(response.body)['results'].each do |result|
50
+
51
+ # Determine color to show
52
+ if result['availability'] == 'available'
53
+ color = :green
54
+ elsif result['availability'] == 'taken' || result['availability'] == 'unavailable'
55
+ color = :red
56
+ elsif result['availability'] == 'maybe'
57
+ color = :yellow
58
+ else
59
+ color = :default
60
+ end
61
+
62
+ # Construct final output string
63
+ string = " " << result['domain'] << " " << result['availability']
64
+
65
+ # Output colorized string
66
+ puts string.color(color).bright
67
+ end
68
+ end
69
69
  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.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-07-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &2215080 !ruby/object:Gem::Requirement
16
+ requirement: &11229520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2215080
24
+ version_requirements: *11229520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rainbow
27
- requirement: &2214720 !ruby/object:Gem::Requirement
27
+ requirement: &11229060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,29 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2214720
36
- - !ruby/object:Gem::Dependency
37
- name: win32console
38
- requirement: &2214420 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *2214420
47
- - !ruby/object:Gem::Dependency
48
- name: windows-pr
49
- requirement: &2214096 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :runtime
56
- prerelease: false
57
- version_requirements: *2214096
35
+ version_requirements: *11229060
58
36
  description: Quickly search for available domains
59
37
  email: shveloo@gmail.com
60
38
  executables:
@@ -84,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
62
  version: '0'
85
63
  requirements: []
86
64
  rubyforge_project:
87
- rubygems_version: 1.8.16
65
+ rubygems_version: 1.8.11
88
66
  signing_key:
89
67
  specification_version: 3
90
68
  summary: Domainr quick search