dnsimple-ruby 0.9.3 → 0.9.4

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.3
1
+ 0.9.4
@@ -0,0 +1,10 @@
1
+ Feature: create a contact with the CLI
2
+ As a user
3
+ In order to add a contact to my list of contacts
4
+ I should be able to use the CLI to create a contact
5
+
6
+ @announce-cmd
7
+ Scenario:
8
+ Given I have set up my credentials
9
+ When I run `dnsimple contact:create first:John last:Smith address1:"Example Road" city:Anytown state:Florida postal_code:12345 country:US email:john.smith@example.com phone:12225051122 label:test-contact`
10
+ Then the output should contain "Created contact John Smith"
@@ -6,5 +6,5 @@ Feature: check a domain with the CLI
6
6
  @announce-cmd
7
7
  Scenario:
8
8
  Given I have set up my credentials
9
- When I run "dnsimple check domain.com"
9
+ When I run `dnsimple check domain.com`
10
10
  Then the output should contain "Check domain result for domain.com: registered"
@@ -0,0 +1,11 @@
1
+ Feature: apply a template to a domain
2
+ As a user
3
+ In order to apply a set of records to a domain at once
4
+ I should be able to use the CLI to apply a template
5
+
6
+ Scenario:
7
+ Given I have set up my credentials
8
+ When I run `dnsimple create` with a new domain
9
+ And I run `dnsimple apply` with the domain and the template named "googleapps"
10
+ Then the output should show that the template was applied
11
+ And I the domain should have 13 records
@@ -30,3 +30,9 @@ Then /^the output should show that the record was deleted$/ do
30
30
  steps %Q(Then the output should contain "Deleted #{@record_id} from #{@domain_name}")
31
31
  end
32
32
 
33
+ Then /^I the domain should have (\d+) records$/ do |n|
34
+ steps %Q(
35
+ When I run `dnsimple record:list #{@domain_name}`
36
+ Then the output should contain "Found #{n} records for #{@domain_name}"
37
+ )
38
+ end
@@ -0,0 +1,9 @@
1
+ When /^I run `(.*)` with the domain and the template named "([^\"]*)"$/ do |cmd, template|
2
+ @template_name = template
3
+ steps %Q(When I run `#{cmd} #{@domain_name} #{template}`)
4
+ end
5
+
6
+ Then /^the output should show that the template was applied$/ do
7
+ steps %Q(Then the output should contain "Applied template #{@template_name} to #{@domain_name}")
8
+ end
9
+
@@ -45,7 +45,11 @@ module DNSimple
45
45
  end
46
46
 
47
47
  def self.standard_options
48
- {:basic_auth => credentials, :format => :json, :headers => {'Accept' => 'application/json'}}
48
+ {:format => :json, :headers => {'Accept' => 'application/json'}}
49
+ end
50
+
51
+ def self.standard_options_with_credentials
52
+ standard_options.merge({:basic_auth => credentials})
49
53
  end
50
54
  end
51
55
  end
@@ -14,7 +14,7 @@ module DNSimple
14
14
  end
15
15
 
16
16
  contact = Contact.create(attributes, options)
17
- puts "Created #{contact.name} (id: #{contact.id})"
17
+ puts "Created contact #{contact.name} (id: #{contact.id})"
18
18
  end
19
19
  end
20
20
  end
@@ -74,10 +74,10 @@ module DNSimple #:nodoc:
74
74
  contact_hash[Contact.resolve(attribute)] = self.send(attribute)
75
75
  end
76
76
 
77
- options.merge!({:basic_auth => Client.credentials})
77
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
78
78
  options.merge!({:body => {:contact => contact_hash}})
79
79
 
80
- response = self.class.put("#{Client.base_uri}/contacts/#{id}.json", options)
80
+ response = self.class.put("#{Client.base_uri}/contacts/#{id}", options)
81
81
 
82
82
  pp response if Client.debug?
83
83
 
@@ -112,11 +112,19 @@ module DNSimple #:nodoc:
112
112
  aliases[name] || name
113
113
  end
114
114
 
115
+ def self.resolve_attributes(attributes)
116
+ resolved_attributes = {}
117
+ attributes.each do |k, v|
118
+ resolved_attributes[resolve(k)] = v
119
+ end
120
+ resolved_attributes
121
+ end
122
+
115
123
  # Create the contact with the given attributes in DNSimple.
116
124
  # This method returns a Contact instance of the contact is created
117
125
  # and raises an error otherwise.
118
126
  def self.create(attributes, options={})
119
- contact_hash = attributes
127
+ contact_hash = resolve_attributes(attributes)
120
128
 
121
129
  options.merge!({:body => {:contact => contact_hash}})
122
130
  options.merge!({:basic_auth => Client.credentials})
@@ -29,7 +29,7 @@ module DNSimple #:nodoc:
29
29
  # Delete the domain from DNSimple. WARNING: this cannot
30
30
  # be undone.
31
31
  def delete(options={})
32
- options.merge!(DNSimple::Client.standard_options)
32
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
33
33
  self.class.delete("#{Client.base_uri}/domains/#{id}", options)
34
34
  end
35
35
  alias :destroy :delete
@@ -37,7 +37,7 @@ module DNSimple #:nodoc:
37
37
  # Apply the given named template to the domain. This will add
38
38
  # all of the records in the template to the domain.
39
39
  def apply(template, options={})
40
- options.merge!(DNSimple::Client.standard_options)
40
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
41
41
  template = resolve_template(template)
42
42
  self.class.post("#{Client.base_uri}/domains/#{id}/templates/#{template.id}/apply", options)
43
43
  end
@@ -53,7 +53,7 @@ module DNSimple #:nodoc:
53
53
  end
54
54
 
55
55
  def applied_services(options={})
56
- options.merge!(DNSimple::Client.standard_options)
56
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
57
57
  response = self.class.get("#{Client.base_uri}/domains/#{id}/applied_services", options)
58
58
  pp response if Client.debug?
59
59
  case response.code
@@ -67,7 +67,7 @@ module DNSimple #:nodoc:
67
67
  end
68
68
 
69
69
  def available_services(options={})
70
- options.merge!(DNSimple::Client.standard_options)
70
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
71
71
  response = self.class.get("#{Client.base_uri}/domains/#{id}/available_services", options)
72
72
  pp response if Client.debug?
73
73
  case response.code
@@ -81,7 +81,7 @@ module DNSimple #:nodoc:
81
81
  end
82
82
 
83
83
  def add_service(id_or_short_name, options={})
84
- options.merge!(DNSimple::Client.standard_options)
84
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
85
85
  options.merge!(:body => {:service => {:id => id_or_short_name}})
86
86
  response = self.class.post("#{Client.base_uri}/domains/#{name}/applied_services", options)
87
87
  pp response if Client.debug?
@@ -96,7 +96,7 @@ module DNSimple #:nodoc:
96
96
  end
97
97
 
98
98
  def remove_service(id, options={})
99
- options.merge!(DNSimple::Client.standard_options)
99
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
100
100
  response = self.class.delete("#{Client.base_uri}/domains/#{name}/applied_services/#{id}", options)
101
101
  pp response if Client.debug?
102
102
  case response.code
@@ -111,7 +111,7 @@ module DNSimple #:nodoc:
111
111
 
112
112
  # Check the availability of a name
113
113
  def self.check(name, options={})
114
- options.merge!(DNSimple::Client.standard_options)
114
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
115
115
  response = self.get("#{Client.base_uri}/domains/#{name}/check", options)
116
116
  pp response if Client.debug?
117
117
  case response.code
@@ -130,7 +130,7 @@ module DNSimple #:nodoc:
130
130
  # method returns a Domain instance if the name is created
131
131
  # and raises an error otherwise.
132
132
  def self.create(name, options={})
133
- options.merge!(DNSimple::Client.standard_options)
133
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
134
134
 
135
135
  domain_hash = {:name => name}
136
136
  options.merge!({:body => {:domain => domain_hash}})
@@ -150,7 +150,7 @@ module DNSimple #:nodoc:
150
150
  end
151
151
 
152
152
  def self.register(name, registrant={}, extended_attributes={}, options={})
153
- options.merge!(DNSimple::Client.standard_options)
153
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
154
154
 
155
155
  body = {:domain => {:name => name}}
156
156
  if registrant[:id]
@@ -178,7 +178,7 @@ module DNSimple #:nodoc:
178
178
  # Find a specific domain in the account either by the numeric ID
179
179
  # or by the fully-qualified domain name.
180
180
  def self.find(id_or_name, options={})
181
- options.merge!(DNSimple::Client.standard_options)
181
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
182
182
  response = self.get("#{Client.base_uri}/domains/#{id_or_name}", options)
183
183
 
184
184
  pp response if Client.debug?
@@ -197,7 +197,7 @@ module DNSimple #:nodoc:
197
197
 
198
198
  # Get all domains for the account.
199
199
  def self.all(options={})
200
- options.merge!(DNSimple::Client.standard_options)
200
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
201
201
  response = self.get("#{Client.base_uri}/domains", options)
202
202
 
203
203
  pp response if Client.debug?
@@ -34,7 +34,7 @@ module DNSimple
34
34
  record_hash[Record.resolve(attribute)] = self.send(attribute)
35
35
  end
36
36
 
37
- options.merge!(DNSimple::Client.standard_options)
37
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
38
38
  options.merge!(:body => {:record => record_hash})
39
39
 
40
40
  response = self.class.put("#{Client.base_uri}/domains/#{domain.id}/records/#{id}.json", options)
@@ -52,7 +52,7 @@ module DNSimple
52
52
  end
53
53
 
54
54
  def delete(options={})
55
- options.merge!(DNSimple::Client.standard_options)
55
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
56
56
  self.class.delete("#{Client.base_uri}/domains/#{domain.id}/records/#{id}", options)
57
57
  end
58
58
  alias :destroy :delete
@@ -73,7 +73,7 @@ module DNSimple
73
73
  record_hash[:prio] = options.delete(:priority)
74
74
  record_hash[:prio] = options.delete(:prio) || ''
75
75
 
76
- options.merge!(DNSimple::Client.standard_options)
76
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
77
77
  options.merge!({:query => {:record => record_hash}})
78
78
 
79
79
  response = self.post("#{Client.base_uri}/domains/#{domain.id}/records", options)
@@ -94,7 +94,7 @@ module DNSimple
94
94
 
95
95
  def self.find(domain_name, id, options={})
96
96
  domain = Domain.find(domain_name)
97
- options.merge!(DNSimple::Client.standard_options)
97
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
98
98
  response = self.get("#{Client.base_uri}/domains/#{domain.id}/records/#{id}", options)
99
99
 
100
100
  pp response if Client.debug?
@@ -113,7 +113,7 @@ module DNSimple
113
113
 
114
114
  def self.all(domain_name, options={})
115
115
  domain = Domain.find(domain_name)
116
- options.merge!(DNSimple::Client.standard_options)
116
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
117
117
  response = self.get("#{Client.base_uri}/domains/#{domain.id}/records", options)
118
118
 
119
119
  pp response if Client.debug?
@@ -25,12 +25,13 @@ module DNSimple
25
25
  # Delete the template from DNSimple. WARNING: this cannot
26
26
  # be undone.
27
27
  def delete(options={})
28
- options.merge!({:basic_auth => Client.credentials})
29
- self.class.delete("#{Client.base_uri}/templates/#{id}.json", options)
28
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
29
+ self.class.delete("#{Client.base_uri}/templates/#{id}", options)
30
30
  end
31
31
  alias :destroy :delete
32
32
 
33
33
  def self.create(name, short_name, description=nil, options={})
34
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
34
35
  template_hash = {
35
36
  :name => name,
36
37
  :short_name => short_name,
@@ -38,9 +39,8 @@ module DNSimple
38
39
  }
39
40
 
40
41
  options.merge!(:body => {:dns_template => template_hash})
41
- options.merge!({:basic_auth => Client.credentials})
42
42
 
43
- response = self.post("#{Client.base_uri}/templates.json", options)
43
+ response = self.post("#{Client.base_uri}/templates", options)
44
44
 
45
45
  pp response if Client.debug?
46
46
 
@@ -55,8 +55,8 @@ module DNSimple
55
55
  end
56
56
 
57
57
  def self.find(id_or_short_name, options={})
58
- options.merge!({:basic_auth => Client.credentials})
59
- response = self.get("#{Client.base_uri}/templates/#{id_or_short_name}.json", options)
58
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
59
+ response = self.get("#{Client.base_uri}/templates/#{id_or_short_name}", options)
60
60
 
61
61
  pp response if Client.debug?
62
62
 
@@ -73,8 +73,8 @@ module DNSimple
73
73
  end
74
74
 
75
75
  def self.all(options={})
76
- options.merge!({:basic_auth => Client.credentials})
77
- response = self.get("#{Client.base_uri}/templates.json", options)
76
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
77
+ response = self.get("#{Client.base_uri}/templates", options)
78
78
 
79
79
  pp response if Client.debug?
80
80
 
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: 61
4
+ hash: 51
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 3
10
- version: 0.9.3
9
+ - 4
10
+ version: 0.9.4
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-03-24 00:00:00 +01:00
18
+ date: 2011-03-26 00:00:00 +01:00
19
19
  default_executable: dnsimple
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -171,15 +171,18 @@ files:
171
171
  - bin/dnsimple
172
172
  - bin/dnsimple.rb
173
173
  - dnsimple-ruby.gemspec
174
+ - features/cli/contacts/create_contact.feature
174
175
  - features/cli/domains/check_domain.feature
175
176
  - features/cli/domains/create_domain.feature
176
177
  - features/cli/domains/delete_domain.feature
177
178
  - features/cli/records/create_ptr_record.feature
178
179
  - features/cli/records/create_record.feature
179
180
  - features/cli/records/delete_record.feature
181
+ - features/cli/templates/apply_template.feature
180
182
  - features/step_definitions/cli_steps.rb
181
183
  - features/step_definitions/domain_steps.rb
182
184
  - features/step_definitions/record_steps.rb
185
+ - features/step_definitions/template_steps.rb
183
186
  - features/support/env.rb
184
187
  - lib/dnsimple.rb
185
188
  - lib/dnsimple/cli.rb