dnsdeploy 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a4ae4f829fdc82326a2e44f9b362f275be9c01c
4
- data.tar.gz: 5c472326105c0af70106b2edfd04b64b6e8ba314
3
+ metadata.gz: 89afc9a9226e090ea829e459864fba671877d802
4
+ data.tar.gz: c8aced6f7821513d1e266cbb2abde902c0267451
5
5
  SHA512:
6
- metadata.gz: 06004f94f75ec6a4771a3e541c17c38d829ae2235f7ba722659bad1cc8ec1df4379de9508be987ad2e69f800030376d6b30698d9a0abdacf658fac57cb679d41
7
- data.tar.gz: 68130b644cf28a340c3077cd0e91ca9fe481a99c8abbc650209f7fac99330b932f2a38a429eab424b8e52db285be66fd0dec1a865dc0ffd94318fe9ce12f679d
6
+ metadata.gz: a6500cf2cdbc51c9efd8605a8c11e40b242f09092b50b1f9d0c9cbd4956e2343f8d943a1d7375aab50fe3c0bd8dabec4eb117eac6b2a50be99c381142f36ba23
7
+ data.tar.gz: 39ce7a281d4d616751c2f1099e4dffd6863b658ae35973d8422d4ffee1a1146a6afdaef0479841947e017a625e09f888b0ecfd93b13771949836dca554cf611d
@@ -18,21 +18,25 @@ module Dnsdeploy
18
18
  end
19
19
 
20
20
  def update_records
21
- local.domains.each do |domain|
22
- puts "[Processing] Domain #{domain.name}"
21
+ local.domains.each_pair do |domain, dnsimple_domain|
22
+ if dnsimple_domain.nil?
23
+ puts "[ERROR] Domain #{domain} does not exists on DNSimple"
24
+ else
25
+ puts "[Processing] Domain #{domain}"
23
26
 
24
- # Delete records on DNSimple
25
- DNSimple::Record.all(domain).collect(&:destroy)
27
+ # Delete records on DNSimple
28
+ DNSimple::Record.all(dnsimple_domain).collect(&:destroy)
26
29
 
27
- # create records
28
- local.records(domain).each do |record|
29
- puts "[CREATE] #{record}".green
30
- begin
31
- DNSimple::Record.create(record.domain, record.name, record.record_type,
32
- record.content, { ttl: record.ttl, prio: record.prio })
33
- rescue DNSimple::RequestError => e
34
- puts "[ERROR] #{e} #{record}".red
35
- @exit = 1
30
+ # create records
31
+ local.records(dnsimple_domain).each do |record|
32
+ puts "[CREATE] #{record}".green
33
+ begin
34
+ DNSimple::Record.create(record.domain, record.name, record.record_type,
35
+ record.content, { ttl: record.ttl, prio: record.prio })
36
+ rescue DNSimple::RequestError => e
37
+ puts "[ERROR] #{e} #{record}".red
38
+ @exit = 1
39
+ end
36
40
  end
37
41
  end
38
42
 
@@ -18,8 +18,9 @@ module Dnsdeploy
18
18
  end
19
19
 
20
20
  def domains
21
- @domains ||= json.map do |record_set|
22
- domain = dnsimple_domain(record_set['zone'])
21
+ @domains ||= json.inject({}) do |memo, record_set|
22
+ memo[record_set['zone']] = dnsimple_domain(record_set['zone'])
23
+ memo
23
24
  end
24
25
  end
25
26
 
@@ -1,3 +1,3 @@
1
1
  module Dnsdeploy
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,13 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Dnsdeploy::Base do
4
- let(:domain) { DNSimple::Domain.new name: random_domain }
5
4
  let(:name) { random_string }
6
5
  let(:record_type) { random_string }
7
6
  let(:content) { random_string }
8
7
  let(:ttl) { random_number }
9
8
  let(:prio) { random_number }
10
- let(:local) { double(:local, domains: [domain], records: [record]) }
9
+ let(:local) { double(:local, domains: { 'example.com' => domain }, records: [record]) }
11
10
  let(:record) { Dnsdeploy::Record.new(domain: domain, name: name, record_type: record_type,
12
11
  content: content, ttl: ttl, prio: prio ) }
13
12
  let(:records_file) { 'spec/assets/records.json' }
@@ -19,8 +18,22 @@ describe Dnsdeploy::Base do
19
18
  allow(Dnsdeploy::Local).to receive(:new).and_return local
20
19
  end
21
20
 
22
- it "should create records" do
23
- expect(DNSimple::Record).to receive(:create).with(domain, name, record_type, content, {ttl: ttl, prio: prio })
24
- base.update_records
21
+ context 'existing domain' do
22
+ let(:domain) { DNSimple::Domain.new name: random_domain }
23
+
24
+ it "should create records" do
25
+ expect(DNSimple::Record).to receive(:create).with(domain, name, record_type, content, {ttl: ttl, prio: prio })
26
+ base.update_records
27
+ end
28
+ end
29
+
30
+ context 'non existent domain' do
31
+ let(:domain) { nil }
32
+
33
+ it "should print an error" do
34
+ expect(DNSimple::Record).to_not receive(:create)
35
+
36
+ expect { base.update_records }.to output("[ERROR] Domain example.com does not exists on DNSimple\n").to_stdout
37
+ end
25
38
  end
26
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnsdeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - beanieboi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-05 00:00:00.000000000 Z
11
+ date: 2014-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dnsimple-ruby