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 +4 -4
 - data/lib/dnsdeploy/base.rb +17 -13
 - data/lib/dnsdeploy/local.rb +3 -2
 - data/lib/dnsdeploy/version.rb +1 -1
 - data/spec/dnsdeploy/base_spec.rb +18 -5
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 89afc9a9226e090ea829e459864fba671877d802
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c8aced6f7821513d1e266cbb2abde902c0267451
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a6500cf2cdbc51c9efd8605a8c11e40b242f09092b50b1f9d0c9cbd4956e2343f8d943a1d7375aab50fe3c0bd8dabec4eb117eac6b2a50be99c381142f36ba23
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 39ce7a281d4d616751c2f1099e4dffd6863b658ae35973d8422d4ffee1a1146a6afdaef0479841947e017a625e09f888b0ecfd93b13771949836dca554cf611d
         
     | 
    
        data/lib/dnsdeploy/base.rb
    CHANGED
    
    | 
         @@ -18,21 +18,25 @@ module Dnsdeploy 
     | 
|
| 
       18 
18 
     | 
    
         
             
                end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                def update_records
         
     | 
| 
       21 
     | 
    
         
            -
                  local.domains. 
     | 
| 
       22 
     | 
    
         
            -
                     
     | 
| 
      
 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 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 27 
     | 
    
         
            +
                      # Delete records on DNSimple
         
     | 
| 
      
 28 
     | 
    
         
            +
                      DNSimple::Record.all(dnsimple_domain).collect(&:destroy)
         
     | 
| 
       26 
29 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         | 
    
        data/lib/dnsdeploy/local.rb
    CHANGED
    
    | 
         @@ -18,8 +18,9 @@ module Dnsdeploy 
     | 
|
| 
       18 
18 
     | 
    
         
             
                end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                def domains
         
     | 
| 
       21 
     | 
    
         
            -
                  @domains ||= json. 
     | 
| 
       22 
     | 
    
         
            -
                     
     | 
| 
      
 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 
     | 
    
         | 
    
        data/lib/dnsdeploy/version.rb
    CHANGED
    
    
    
        data/spec/dnsdeploy/base_spec.rb
    CHANGED
    
    | 
         @@ -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:  
     | 
| 
      
 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 
     | 
    
         
            -
               
     | 
| 
       23 
     | 
    
         
            -
                 
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 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. 
     | 
| 
      
 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 
     | 
    
         
            +
            date: 2014-12-20 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: dnsimple-ruby
         
     |