enom 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/enom/domain.rb +17 -9
- data/test/domain_test.rb +26 -4
- metadata +98 -50
data/lib/enom/domain.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "public_suffix"
|
2
|
+
|
1
3
|
module Enom
|
2
4
|
|
3
5
|
class Domain
|
@@ -16,7 +18,7 @@ module Enom
|
|
16
18
|
|
17
19
|
def initialize(attributes)
|
18
20
|
@name = attributes["DomainName"] || attributes["domainname"]
|
19
|
-
@sld, @tld = @name
|
21
|
+
@sld, @tld = Domain.parse_sld_and_tld(@name)
|
20
22
|
|
21
23
|
expiration_date_string = attributes["expiration_date"] || attributes["status"]["expiration"]
|
22
24
|
@expiration_date = Date.strptime(expiration_date_string.split(" ").first, "%m/%d/%Y")
|
@@ -31,7 +33,7 @@ module Enom
|
|
31
33
|
|
32
34
|
# Find the domain (must be in your account) on Enom
|
33
35
|
def self.find(name)
|
34
|
-
sld, tld = name
|
36
|
+
sld, tld = parse_sld_and_tld(name)
|
35
37
|
response = Client.request("Command" => "GetDomainInfo", "SLD" => sld, "TLD" => tld)["interface_response"]["GetDomainInfo"]
|
36
38
|
Domain.new(response)
|
37
39
|
end
|
@@ -43,7 +45,7 @@ module Enom
|
|
43
45
|
|
44
46
|
# Boolean helper method to determine if the domain is available for purchase
|
45
47
|
def self.available?(name)
|
46
|
-
sld, tld = name
|
48
|
+
sld, tld = parse_sld_and_tld(name)
|
47
49
|
response = Client.request("Command" => "Check", "SLD" => sld, "TLD" => tld)["interface_response"]["RRPCode"]
|
48
50
|
response == "210"
|
49
51
|
end
|
@@ -76,7 +78,7 @@ module Enom
|
|
76
78
|
response["interface_response"].each do |k, v|
|
77
79
|
if v == "210" #&& k[0,6] == "RRPCode"
|
78
80
|
pos = k[7..k.size]
|
79
|
-
result << response["interface_response"]["Domain#{pos}"] unless k.
|
81
|
+
result << response["interface_response"]["Domain#{pos}"] unless k.nil? || k.empty?
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
@@ -94,7 +96,7 @@ module Enom
|
|
94
96
|
|
95
97
|
# Purchase the domain
|
96
98
|
def self.register!(name, options = {})
|
97
|
-
sld, tld = name
|
99
|
+
sld, tld = parse_sld_and_tld(name)
|
98
100
|
opts = {}
|
99
101
|
if options[:nameservers]
|
100
102
|
count = 1
|
@@ -114,7 +116,7 @@ module Enom
|
|
114
116
|
# Transfer domain from another registrar to Enom, charges the account when successful
|
115
117
|
# Returns true if successful, false if failed
|
116
118
|
def self.transfer!(name, auth, options = {})
|
117
|
-
sld, tld = name
|
119
|
+
sld, tld = parse_sld_and_tld(name)
|
118
120
|
|
119
121
|
# Default options
|
120
122
|
opts = {
|
@@ -136,7 +138,7 @@ module Enom
|
|
136
138
|
|
137
139
|
# Renew the domain
|
138
140
|
def self.renew!(name, options = {})
|
139
|
-
sld, tld = name
|
141
|
+
sld, tld = parse_sld_and_tld(name)
|
140
142
|
opts = {}
|
141
143
|
opts.merge!("NumYears" => options[:years]) if options[:years]
|
142
144
|
response = Client.request({"Command" => "Extend", "SLD" => sld, "TLD" => tld}.merge(opts))
|
@@ -146,20 +148,26 @@ module Enom
|
|
146
148
|
# Suggest available domains using the namespinner
|
147
149
|
# Returns an array of available domain names that match
|
148
150
|
def self.suggest(name, options ={})
|
149
|
-
sld, tld = name
|
151
|
+
sld, tld = parse_sld_and_tld(name)
|
150
152
|
opts = {}
|
151
153
|
opts.merge!("MaxResults" => options[:max_results] || 8, "Similar" => options[:similar] || "High")
|
152
154
|
response = Client.request({"Command" => "namespinner", "SLD" => sld, "TLD" => tld}.merge(opts))
|
153
155
|
|
154
156
|
suggestions = []
|
155
157
|
response["interface_response"]["namespin"]["domains"]["domain"].map do |d|
|
156
|
-
%w(com net tv cc).each do |toplevel|
|
158
|
+
(options[:tlds] || %w(com net tv cc)).each do |toplevel|
|
157
159
|
suggestions << [d["name"].downcase, toplevel].join(".") if d[toplevel] == "y"
|
158
160
|
end
|
159
161
|
end
|
160
162
|
return suggestions
|
161
163
|
end
|
162
164
|
|
165
|
+
# Parse out domain name tld and sld from the PublicSuffix lib
|
166
|
+
def self.parse_sld_and_tld(domain_name)
|
167
|
+
d = PublicSuffix.parse(domain_name)
|
168
|
+
[d.sld, d.tld]
|
169
|
+
end
|
170
|
+
|
163
171
|
# Lock the domain at the registrar so it can"t be transferred
|
164
172
|
def lock
|
165
173
|
Client.request("Command" => "SetRegLock", "SLD" => sld, "TLD" => tld, "UnlockRegistrar" => "0")
|
data/test/domain_test.rb
CHANGED
@@ -59,11 +59,13 @@ class DomainTest < Test::Unit::TestCase
|
|
59
59
|
|
60
60
|
context "checking for suggested domains" do
|
61
61
|
setup do
|
62
|
-
|
62
|
+
|
63
63
|
end
|
64
64
|
should "return an array of suggestions matching the supplied term" do
|
65
|
+
@suggestions = Enom::Domain.suggest("hand.com")
|
65
66
|
assert !@suggestions.empty?
|
66
|
-
|
67
|
+
|
68
|
+
results = %w(
|
67
69
|
handsewncurtains.net
|
68
70
|
handsewncurtains.tv
|
69
71
|
handsewncurtains.cc
|
@@ -90,7 +92,27 @@ class DomainTest < Test::Unit::TestCase
|
|
90
92
|
handloser.tv
|
91
93
|
handloser.cc
|
92
94
|
)
|
93
|
-
|
95
|
+
|
96
|
+
assert_equal results, @suggestions
|
97
|
+
end
|
98
|
+
|
99
|
+
should "only return the results matching specified tlds" do
|
100
|
+
@suggestions = Enom::Domain.suggest("hand.com", :tlds => %w(com net))
|
101
|
+
assert !@suggestions.empty?
|
102
|
+
|
103
|
+
results = %w(
|
104
|
+
handsewncurtains.net
|
105
|
+
handicappingclub.net
|
106
|
+
handingok.com
|
107
|
+
handingok.net
|
108
|
+
handoki.net
|
109
|
+
handinghand.com
|
110
|
+
handinghand.net
|
111
|
+
handcrafthouselogs.com
|
112
|
+
handcrafthouselogs.net
|
113
|
+
)
|
114
|
+
|
115
|
+
assert_equal results, @suggestions
|
94
116
|
end
|
95
117
|
end
|
96
118
|
|
@@ -162,7 +184,7 @@ class DomainTest < Test::Unit::TestCase
|
|
162
184
|
should "update nameservers if there are 2 or more provided" do
|
163
185
|
new_nameservers = ["ns1.foo.com", "ns2.foo.com"]
|
164
186
|
@domain.update_nameservers(new_nameservers)
|
165
|
-
assert_equal new_nameservers, @domain.nameservers
|
187
|
+
assert_equal new_nameservers, @domain.nameservers.sort
|
166
188
|
end
|
167
189
|
should "not update nameservers if less than 2 or more than 12 are provided" do
|
168
190
|
not_enough = ["ns1.foo.com"]
|
metadata
CHANGED
@@ -1,68 +1,106 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: enom
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- James Miller
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-02-02 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: httparty
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
25
|
+
requirements:
|
19
26
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 19
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 7
|
32
|
+
- 8
|
21
33
|
version: 0.7.8
|
22
34
|
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: public_suffix
|
23
38
|
prerelease: false
|
24
|
-
|
25
|
-
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 23
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 0
|
48
|
+
- 0
|
49
|
+
version: 1.0.0
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
26
53
|
name: shoulda
|
27
|
-
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
28
56
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
33
64
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
37
67
|
name: fakeweb
|
38
|
-
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
39
70
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
44
78
|
type: :development
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
79
|
+
version_requirements: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
48
81
|
name: rake
|
49
|
-
|
82
|
+
prerelease: false
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
50
84
|
none: false
|
51
|
-
requirements:
|
85
|
+
requirements:
|
52
86
|
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 25
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
- 9
|
92
|
+
version: "0.9"
|
55
93
|
type: :development
|
56
|
-
|
57
|
-
|
58
|
-
description: Enom is a Ruby wrapper and command line interface for portions of the
|
59
|
-
Enom domain reseller API.
|
94
|
+
version_requirements: *id005
|
95
|
+
description: Enom is a Ruby wrapper and command line interface for portions of the Enom domain reseller API.
|
60
96
|
email: bensie@gmail.com
|
61
|
-
executables:
|
97
|
+
executables:
|
62
98
|
- enom
|
63
99
|
extensions: []
|
100
|
+
|
64
101
|
extra_rdoc_files: []
|
65
|
-
|
102
|
+
|
103
|
+
files:
|
66
104
|
- README.md
|
67
105
|
- Rakefile
|
68
106
|
- LICENSE
|
@@ -89,26 +127,36 @@ files:
|
|
89
127
|
- bin/enom.rb
|
90
128
|
homepage: http://github.com/bensie/enom
|
91
129
|
licenses: []
|
130
|
+
|
92
131
|
post_install_message:
|
93
132
|
rdoc_options: []
|
94
|
-
|
133
|
+
|
134
|
+
require_paths:
|
95
135
|
- lib
|
96
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
137
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
hash: 3
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
version: "0"
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
146
|
none: false
|
104
|
-
requirements:
|
105
|
-
- -
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
hash: 3
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
version: "0"
|
108
154
|
requirements: []
|
155
|
+
|
109
156
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.8.
|
157
|
+
rubygems_version: 1.8.10
|
111
158
|
signing_key:
|
112
159
|
specification_version: 3
|
113
160
|
summary: Ruby wrapper for the Enom API
|
114
161
|
test_files: []
|
162
|
+
|