dnsimple-ruby 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.5
1
+ 0.9.6
@@ -101,6 +101,9 @@ if $0.split("/").last == 'dnsimple'
101
101
  opts.on("-p", "--password [ARG]") do |password|
102
102
  DNSimple::Client.password = password
103
103
  end
104
+ opts.on("-c", "--credentials [ARG]") do |credentials|
105
+ DNSimple::Client.load_credentials(credentials)
106
+ end
104
107
  opts.on("-d") do
105
108
  DNSimple::Client.debug = true
106
109
  end
@@ -0,0 +1,10 @@
1
+ Feature: register a domain with the CLI
2
+ As a user
3
+ In order to register a domain
4
+ I should be able to use the CLI for domain registration
5
+
6
+ @announce-cmd @announce-stdout
7
+ Scenario:
8
+ Given I have set up my credentials
9
+ When I run `dnsimple register` with a new domain
10
+ Then the output should show that the domain was registered
@@ -25,3 +25,8 @@ Then /^the output should show that the domain was deleted$/ do
25
25
  steps %Q(Then the output should contain "Deleted #{@domain_name}")
26
26
  end
27
27
 
28
+ Then /^the output should show that the domain was registered$/ do
29
+ steps %Q(Then the output should contain "Registered #{@domain_name}")
30
+ end
31
+
32
+
@@ -1,7 +1,7 @@
1
1
  require 'aruba/cucumber'
2
2
 
3
3
  Before do
4
- @aruba_timeout_seconds = 10
4
+ @aruba_timeout_seconds = 30
5
5
  end
6
6
 
7
7
  After do |scenario|
@@ -6,13 +6,9 @@ module DNSimple
6
6
  end
7
7
 
8
8
  class CLI
9
- def initialize
10
- credentials = load_credentials
11
- Client.username = credentials['username']
12
- Client.password = credentials['password']
13
- end
14
9
 
15
10
  def execute(command_name, args, options={})
11
+ DNSimple::Client.load_credentials_if_necessary
16
12
  command = commands[command_name]
17
13
  if command
18
14
  begin
@@ -72,11 +68,6 @@ module DNSimple
72
68
  'service:remove' => DNSimple::Commands::RemoveService
73
69
  }
74
70
  end
75
-
76
- private
77
- def load_credentials
78
- YAML.load(File.new(File.expand_path('~/.dnsimple')))
79
- end
80
71
  end
81
72
  end
82
73
 
@@ -37,13 +37,23 @@ module DNSimple
37
37
  @@base_uri = base_uri.gsub(/\/$/, '')
38
38
  end
39
39
 
40
+ def self.load_credentials_if_necessary
41
+ load_credentials unless credentials_loaded?
42
+ end
43
+
40
44
  def self.load_credentials(path='~/.dnsimple')
41
45
  credentials = YAML.load(File.new(File.expand_path(path)))
42
46
  self.username = credentials['username']
43
47
  self.password = credentials['password']
48
+ self.base_uri = credentials['site']
49
+ @@credentials_loaded = true
44
50
  "Credentials loaded from #{path}"
45
51
  end
46
52
 
53
+ def self.credentials_loaded?
54
+ @@credentials_loaded ||= false
55
+ end
56
+
47
57
  def self.standard_options
48
58
  {:format => :json, :headers => {'Accept' => 'application/json'}}
49
59
  end
@@ -3,7 +3,16 @@ module DNSimple
3
3
  class RegisterDomain
4
4
  def execute(args, options={})
5
5
  name = args.shift
6
- registrant = {:id => args.shift}
6
+ registrant = nil
7
+
8
+ registrant_id_or_attribute = args.shift
9
+ if registrant_id_or_attribute
10
+ if registrant_id_or_attribute =~ /^\d+$/
11
+ registrant = {:id => registrant_id_or_attribute}
12
+ else
13
+ args.unshift(registrant_id_or_attribute)
14
+ end
15
+ end
7
16
 
8
17
  extended_attributes = {}
9
18
  args.each do |arg|
@@ -153,10 +153,12 @@ module DNSimple #:nodoc:
153
153
  options.merge!(DNSimple::Client.standard_options_with_credentials)
154
154
 
155
155
  body = {:domain => {:name => name}}
156
- if registrant[:id]
157
- body[:domain][:registrant_id] = registrant[:id]
158
- else
159
- body.merge!(:contact => registrant)
156
+ if registrant
157
+ if registrant[:id]
158
+ body[:domain][:registrant_id] = registrant[:id]
159
+ else
160
+ body.merge!(:contact => registrant)
161
+ end
160
162
  end
161
163
  body.merge!(:extended_attribute => extended_attributes)
162
164
  options.merge!({:body => body})
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnsimple-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 55
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 5
10
- version: 0.9.5
9
+ - 6
10
+ version: 0.9.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Anthony Eden
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-02 00:00:00 +02:00
18
+ date: 2011-04-03 00:00:00 +02:00
19
19
  default_executable: dnsimple
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -175,6 +175,7 @@ files:
175
175
  - features/cli/domains/check_domain.feature
176
176
  - features/cli/domains/create_domain.feature
177
177
  - features/cli/domains/delete_domain.feature
178
+ - features/cli/domains/register_domain.feature
178
179
  - features/cli/records/create_ptr_record.feature
179
180
  - features/cli/records/create_record.feature
180
181
  - features/cli/records/delete_record.feature