enom 0.9.0 → 0.9.1
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/lib/enom/cli.rb +19 -19
- data/lib/enom/client.rb +2 -3
- data/lib/enom/commands/check_domain.rb +11 -0
- data/lib/enom/commands/list_domains.rb +13 -0
- data/lib/enom/commands/register_domain.rb +11 -0
- data/lib/enom/domain.rb +16 -10
- data/lib/enom/error.rb +6 -0
- metadata +8 -5
data/lib/enom/cli.rb
CHANGED
@@ -2,12 +2,22 @@ require 'yaml'
|
|
2
2
|
module Enom
|
3
3
|
|
4
4
|
class CommandNotFound < RuntimeError; end
|
5
|
+
class InvalidCredentials < RuntimeError; end
|
5
6
|
|
6
7
|
class CLI
|
7
8
|
|
8
9
|
def initialize
|
9
|
-
|
10
|
-
Client.
|
10
|
+
# If the username and password are set elsewhere, they take precedence
|
11
|
+
unless Enom::Client.username && Enom::Client.password
|
12
|
+
file = File.expand_path("~/.enomconfig")
|
13
|
+
if File.exists?(file)
|
14
|
+
credentials = YAML.load(File.new(file))
|
15
|
+
Enom::Client.username = credentials['username']
|
16
|
+
Enom::Client.password = credentials['password']
|
17
|
+
else
|
18
|
+
raise InvalidCredentials, "Please provide a username/password as arguments create a config file with credentials in ~/.enomconfig"
|
19
|
+
end
|
20
|
+
end
|
11
21
|
end
|
12
22
|
|
13
23
|
def execute(command_name, args, options={})
|
@@ -27,24 +37,14 @@ module Enom
|
|
27
37
|
|
28
38
|
def commands
|
29
39
|
{
|
30
|
-
'
|
31
|
-
'check'
|
32
|
-
'register' => Enom::Commands::RegisterDomain
|
33
|
-
# 'renew' => Enom::Commands::RenewDomain,
|
34
|
-
# 'transfer' => Enom::Commands::TransferDomain,
|
35
|
-
# 'describe' => Enom::Commands::DescribeDomain,
|
36
|
-
'list' => Enom::Commands::ListDomains,
|
37
|
-
# 'lock' => Enom::Commands::LockDomain,
|
38
|
-
# 'unlock' => Enom::Commands::UnlockDomain,
|
39
|
-
# 'nameservers:list' => Enom::Commands::ListNameservers,
|
40
|
-
# 'nameservers:set' => Enom::Commands::SetNameservers
|
40
|
+
'list' => Enom::Commands::ListDomains,
|
41
|
+
'check' => Enom::Commands::CheckDomain,
|
42
|
+
'register' => Enom::Commands::RegisterDomain
|
41
43
|
}
|
42
44
|
end
|
43
45
|
|
44
|
-
require 'enom/commands/describe_account'
|
45
|
-
require 'enom/commands/check_domain'
|
46
|
-
require 'enom/commands/register_domain'
|
47
|
-
require 'enom/commands/list_domains'
|
48
|
-
|
49
46
|
end
|
50
|
-
end
|
47
|
+
end
|
48
|
+
require 'enom/commands/list_domains'
|
49
|
+
require 'enom/commands/check_domain'
|
50
|
+
require 'enom/commands/register_domain'
|
data/lib/enom/client.rb
CHANGED
@@ -30,12 +30,11 @@ module Enom
|
|
30
30
|
if response['interface_response']['ErrCount'] == '0'
|
31
31
|
return response
|
32
32
|
else
|
33
|
-
|
33
|
+
p response if test?
|
34
|
+
raise InterfaceError, response['interface_response']['errors'].values.join(", ")
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
37
|
-
|
38
38
|
end
|
39
|
-
|
40
39
|
end
|
41
40
|
end
|
data/lib/enom/domain.rb
CHANGED
@@ -36,14 +36,18 @@ module Enom
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# Determine if the domain is available for purchase
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
def self.check(name)
|
40
|
+
sld, tld = name.split('.')
|
41
|
+
response = Client.request("Command" => "Check", "SLD" => sld, "TLD" => tld)["interface_response"]["RRPCode"]
|
42
|
+
|
43
|
+
p response if Client.test?
|
44
|
+
|
45
|
+
if response == "210"
|
46
|
+
"available"
|
47
|
+
else
|
48
|
+
"unavailable"
|
49
|
+
end
|
50
|
+
end
|
47
51
|
|
48
52
|
# Find and return all domains in the account
|
49
53
|
def self.all(options = {})
|
@@ -66,10 +70,12 @@ module Enom
|
|
66
70
|
opts.merge!("NS#{count}" => nameserver)
|
67
71
|
count += 1
|
68
72
|
end
|
73
|
+
else
|
74
|
+
opts.merge!("UseDNS" => "default")
|
69
75
|
end
|
70
76
|
opts.merge!('NumYears' => options[:years]) if options[:years]
|
71
|
-
|
72
|
-
|
77
|
+
response = Client.request({'Command' => 'Purchase', 'SLD' => sld, 'TLD' => tld}.merge(opts))
|
78
|
+
Domain.find(name)
|
73
79
|
end
|
74
80
|
|
75
81
|
# Lock the domain at the registrar so it can't be transferred
|
data/lib/enom/error.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 1
|
10
|
+
version: 0.9.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Miller
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-16 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
version: "0"
|
49
49
|
type: :development
|
50
50
|
version_requirements: *id002
|
51
|
-
description: Enom is a
|
51
|
+
description: Enom is a Ruby wrapper and command line interface for portions of the Enom domain reseller API.
|
52
52
|
email: bensie@gmail.com
|
53
53
|
executables: []
|
54
54
|
|
@@ -66,6 +66,9 @@ files:
|
|
66
66
|
- lib/enom/client.rb
|
67
67
|
- lib/enom/domain.rb
|
68
68
|
- lib/enom/error.rb
|
69
|
+
- lib/enom/commands/check_domain.rb
|
70
|
+
- lib/enom/commands/list_domains.rb
|
71
|
+
- lib/enom/commands/register_domain.rb
|
69
72
|
- test/enom_test.rb
|
70
73
|
- test/test_helper.rb
|
71
74
|
has_rdoc: true
|