zerigo_dns 1.0.6 → 1.1.0

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/zerigo_dns.rb CHANGED
@@ -43,6 +43,22 @@ module Zerigo
43
43
 
44
44
 
45
45
  class Zone < Base
46
+ def self.find_or_create(domain)
47
+ zones = Zerigo::DNS::Zone.find(:all)
48
+ zone = nil
49
+ zones.each do |z|
50
+ if z.domain == domain
51
+ zone = z
52
+ break;
53
+ end
54
+ end
55
+
56
+ unless zone
57
+ zone = Zerigo::DNS::Zone.create(:domain=> domain, :ns_type=>'pri_sec')
58
+ end
59
+ zone
60
+ end
61
+
46
62
  end
47
63
 
48
64
  class Host < Base
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "Zerigo::DNS::Zone.find_or_create" do
4
+
5
+ it 'should create zone' do
6
+ Zerigo::DNS::Zone.stub!(:find).and_return([])
7
+ Zerigo::DNS::Zone.stub!(:create).and_return(:success => true)
8
+
9
+ Zerigo::DNS::Zone.find_or_create('jackhq.com')[:success].should be_true
10
+ end
11
+
12
+ it 'should find zone' do
13
+ jackhq = mock('Zerigo::DNS::Zone')
14
+ jackhq.stub!(:domain).and_return('example.com')
15
+
16
+ Zerigo::DNS::Zone.stub!(:find).and_return([jackhq])
17
+ Zerigo::DNS::Zone.stub!(:create).and_return(:success => false)
18
+
19
+ Zerigo::DNS::Zone.find_or_create('example.com').domain == 'example.com'
20
+ end
21
+
22
+
23
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/zerigo_dns")
2
+
3
+
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+ require 'spec/interop/test'
7
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zerigo_dns
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Wilson
@@ -77,5 +77,7 @@ signing_key:
77
77
  specification_version: 3
78
78
  summary: Zerigo DNS Gem
79
79
  test_files:
80
+ - spec/lib/zone_spec.rb
81
+ - spec/spec_helper.rb
80
82
  - test/helper.rb
81
83
  - test/test_zerigo_dns.rb