enom 0.9.1 → 0.9.2

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.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'httparty'
2
2
 
3
- require 'enom/client'
4
- require 'enom/domain'
5
- require 'enom/account'
6
- require 'enom/error'
3
+ require File.expand_path('../enom/client', __FILE__)
4
+ require File.expand_path('../enom/domain', __FILE__)
5
+ require File.expand_path('../enom/account', __FILE__)
6
+ require File.expand_path('../enom/error', __FILE__)
7
7
 
8
8
  module Enom; end
data/lib/enom/cli.rb CHANGED
@@ -39,7 +39,8 @@ module Enom
39
39
  {
40
40
  'list' => Enom::Commands::ListDomains,
41
41
  'check' => Enom::Commands::CheckDomain,
42
- 'register' => Enom::Commands::RegisterDomain
42
+ 'register' => Enom::Commands::RegisterDomain,
43
+ 'renew' => Enom::Commands::RenewDomain
43
44
  }
44
45
  end
45
46
 
@@ -48,3 +49,4 @@ end
48
49
  require 'enom/commands/list_domains'
49
50
  require 'enom/commands/check_domain'
50
51
  require 'enom/commands/register_domain'
52
+ require 'enom/commands/renew_domain'
data/lib/enom/client.rb CHANGED
@@ -30,7 +30,8 @@ module Enom
30
30
  if response['interface_response']['ErrCount'] == '0'
31
31
  return response
32
32
  else
33
- p response if test?
33
+ # Output the entire response if we're running in test mode
34
+ # p response if test?
34
35
  raise InterfaceError, response['interface_response']['errors'].values.join(", ")
35
36
  end
36
37
  end
@@ -0,0 +1,11 @@
1
+ module Enom
2
+ module Commands
3
+ class RegisterDomain
4
+ def execute(args, options={})
5
+ name = args.shift
6
+ domain = Domain.renew!(name)
7
+ puts "Renewed #{domain.name}"
8
+ end
9
+ end
10
+ end
11
+ end
data/lib/enom/domain.rb CHANGED
@@ -17,7 +17,7 @@ module Enom
17
17
  @name = attributes["DomainName"] || attributes["domainname"]
18
18
  @sld, @tld = @name.split('.')
19
19
  expiration_string = attributes["expiration_date"] || attributes["status"]["expiration"]
20
- @expiration_date = Date.parse(expiration_string.split(' ').first)
20
+ @expiration_date = Date.strptime(expiration_string.split(' ').first, "%m/%d/%Y")
21
21
 
22
22
  # If we have more attributes for the domain from running GetDomainInfo
23
23
  # (as opposed to GetAllDomains), we should save it to the instance to
@@ -78,6 +78,15 @@ module Enom
78
78
  Domain.find(name)
79
79
  end
80
80
 
81
+ # Renew the domain
82
+ def self.renew!(name, options = {})
83
+ sld, tld = name.split('.')
84
+ opts = {}
85
+ opts.merge!('NumYears' => options[:years]) if options[:years]
86
+ response = Client.request({'Command' => 'Extend', 'SLD' => sld, 'TLD' => tld}.merge(opts))
87
+ Domain.find(name)
88
+ end
89
+
81
90
  # Lock the domain at the registrar so it can't be transferred
82
91
  def lock
83
92
  Client.request('Command' => 'SetRegLock', 'SLD' => sld, 'TLD' => tld, 'UnlockRegistrar' => '0')
@@ -142,9 +151,8 @@ module Enom
142
151
  registration_status == "Expired"
143
152
  end
144
153
 
145
- def renew!(years = 1)
146
- # get('Command' => 'Renew', 'SLD' => sld, 'TLD' => tld)
147
- raise NotImplementedError
154
+ def renew!(options = {})
155
+ Domain.renew!(name, options)
148
156
  end
149
157
 
150
158
  private
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enom
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 9
9
- - 1
10
- version: 0.9.1
8
+ - 2
9
+ version: 0.9.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - James Miller
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-11-16 00:00:00 -08:00
17
+ date: 2011-01-29 00:00:00 -08:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 5
30
28
  segments:
31
29
  - 0
32
30
  - 6
@@ -42,7 +40,6 @@ dependencies:
42
40
  requirements:
43
41
  - - ">="
44
42
  - !ruby/object:Gem::Version
45
- hash: 3
46
43
  segments:
47
44
  - 0
48
45
  version: "0"
@@ -69,6 +66,7 @@ files:
69
66
  - lib/enom/commands/check_domain.rb
70
67
  - lib/enom/commands/list_domains.rb
71
68
  - lib/enom/commands/register_domain.rb
69
+ - lib/enom/commands/renew_domain.rb
72
70
  - test/enom_test.rb
73
71
  - test/test_helper.rb
74
72
  has_rdoc: true
@@ -85,7 +83,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
83
  requirements:
86
84
  - - ">="
87
85
  - !ruby/object:Gem::Version
88
- hash: 3
89
86
  segments:
90
87
  - 0
91
88
  version: "0"
@@ -94,7 +91,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
91
  requirements:
95
92
  - - ">="
96
93
  - !ruby/object:Gem::Version
97
- hash: 3
98
94
  segments:
99
95
  - 0
100
96
  version: "0"