domr 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/domr +12 -12
  2. data/ext/mkrf_conf.rb +21 -21
  3. data/lib/domr.rb +65 -65
  4. metadata +20 -8
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/ext/mkrf_conf.rb CHANGED
@@ -1,22 +1,22 @@
1
- require 'rubygems'
2
- require 'rubygems/command.rb'
3
- require 'rubygems/dependency_installer.rb'
4
-
5
- begin
6
- Gem::Command.build_args = ARGV
7
- rescue NoMethodError
8
- end
9
- inst = Gem::DependencyInstaller.new
10
- begin
11
- if RUBY_PLATFORM == 'mswin32' || RUBY_PLATFORM == 'mingw' || RUBY_PLATFORM == 'cygwin'
12
- inst.install "win32console", "~> 1.3.2"
13
- else
14
- inst.install "windows-pr", "~> 1.2.1"
15
- end
16
- rescue
17
- exit(1)
18
- end
19
-
20
- f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
21
- f.write("task :default\n")
1
+ require 'rubygems'
2
+ require 'rubygems/command.rb'
3
+ require 'rubygems/dependency_installer.rb'
4
+
5
+ begin
6
+ Gem::Command.build_args = ARGV
7
+ rescue NoMethodError
8
+ end
9
+ inst = Gem::DependencyInstaller.new
10
+ begin
11
+ if RUBY_PLATFORM =~ /mswin32/ || RUBY_PLATFORM =~ /mingw/ || RUBY_PLATFORM =~ /cygwin/
12
+ inst.install "win32console", "~> 1.3.2"
13
+ else
14
+ inst.install "windows-pr", "~> 1.2.1"
15
+ end
16
+ rescue
17
+ exit(1)
18
+ end
19
+
20
+ f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
21
+ f.write("task :default\n")
22
22
  f.close
data/lib/domr.rb CHANGED
@@ -1,66 +1,66 @@
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
- # Form the request string
30
- request = Net::HTTP::Get.new("/api/json/search?q=" << URI.escape(query))
31
-
32
- # Perform the actual query
33
- response = Net::HTTP.start("domai.nr") { |http|
34
- http.request request
35
- }
36
-
37
- # Check for errors
38
- if response.code != "200"
39
- puts "HTTP error".color(:red).bright # Color is red
40
-
41
- # Exit the program
42
- exit
43
- end
44
-
45
- # Output results
46
- JSON.parse(response.body)['results'].each do |result|
47
-
48
- # Determine color to show
49
- if result['availability'] == 'available'
50
- color = :green
51
- elsif result['availability'] == 'taken' || result['availability'] == 'unavailable'
52
- color = :red
53
- elsif result['availability'] == 'maybe'
54
- color = :yellow
55
- else
56
- color = :default
57
- end
58
-
59
- # Construct final output string
60
- string = " " << result['domain'] << " " << result['availability']
61
-
62
- # Output colorized string
63
- puts string.color(color).bright
64
- end
65
- 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
+ # Form the request string
30
+ request = Net::HTTP::Get.new("/api/json/search?q=" << URI.escape(query))
31
+
32
+ # Perform the actual query
33
+ response = Net::HTTP.start("domai.nr") { |http|
34
+ http.request request
35
+ }
36
+
37
+ # Check for errors
38
+ if response.code != "200"
39
+ puts "HTTP error".color(:red).bright # Color is red
40
+
41
+ # Exit the program
42
+ exit
43
+ end
44
+
45
+ # Output results
46
+ JSON.parse(response.body)['results'].each do |result|
47
+
48
+ # Determine color to show
49
+ if result['availability'] == 'available'
50
+ color = :green
51
+ elsif result['availability'] == 'taken' || result['availability'] == 'unavailable'
52
+ color = :red
53
+ elsif result['availability'] == 'maybe'
54
+ color = :yellow
55
+ else
56
+ color = :default
57
+ end
58
+
59
+ # Construct final output string
60
+ string = " " << result['domain'] << " " << result['availability']
61
+
62
+ # Output colorized string
63
+ puts string.color(color).bright
64
+ end
65
+ end
66
66
  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.1.0
4
+ version: 0.1.1
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: &12962800 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *12962800
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rainbow
27
- requirement: &12962100 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,13 +37,19 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *12962100
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: ! " Quickly search for available domain names from command line.\n
37
47
  \ Usage: domr <name>\n"
38
48
  email: shveloo@gmail.com
39
49
  executables:
40
50
  - domr
41
- extensions: []
51
+ extensions:
52
+ - ext/mkrf_conf.rb
42
53
  extra_rdoc_files: []
43
54
  files:
44
55
  - lib/domr.rb
@@ -62,9 +73,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
73
  - - ! '>='
63
74
  - !ruby/object:Gem::Version
64
75
  version: '0'
65
- requirements: []
76
+ requirements:
77
+ - Internet connection
66
78
  rubyforge_project:
67
- rubygems_version: 1.8.11
79
+ rubygems_version: 1.8.23
68
80
  signing_key:
69
81
  specification_version: 3
70
82
  summary: Domainr quick search