splicer 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,66 @@
1
+ module Splicer
2
+
3
+ # The base Provider class. All providers **MUST** inherit from this class.
4
+ # @author Matthew A. Johnston <warmwaffles@gmail.com>
5
+ class Provider
6
+
7
+ # Creates the zone in the DNS provider. If the zone exists, then nothing
8
+ # will happen.
9
+ #
10
+ # @param [Splicer::Zone] zone
11
+ def create_zone(zone)
12
+ false
13
+ end
14
+
15
+ # Updates a zone in the DNS provider. This will take any current changes
16
+ # that are made to the {Splicer::Zone} object and push them to the DNS. If
17
+ # the zone does not exist, then nothing will be done.
18
+ #
19
+ # @param [Splicer::Zone] zone
20
+ def update_zone(zone)
21
+ false
22
+ end
23
+
24
+ # Rewrites a zone in the DNS provider. If the zone does not exist, then it
25
+ # will be created. It will destroy all of the records in the DNS and rewrite
26
+ # all of them.
27
+ #
28
+ # @param [Splicer::Zone] zone
29
+ def rewrite_zone(zone)
30
+ false
31
+ end
32
+
33
+ # Will simply delete the zone from the DNS provider.
34
+ #
35
+ # @param [Splicer::Zone] zone
36
+ def delete_zone(zone)
37
+ false
38
+ end
39
+
40
+ # Deletes a single record from a zone in the DNS provider.
41
+ #
42
+ # @param [Splicer::Records::Record] record
43
+ # @param [Splicer::Zone] zone
44
+ def delete_record_in_zone(record, zone)
45
+ false
46
+ end
47
+
48
+ # Updates a single record in a zone.
49
+ #
50
+ # @param [Splicer::Records::Record] record
51
+ # @param [Splicer::Zone] zone
52
+ def update_record_in_zone(record, zone)
53
+ false
54
+ end
55
+
56
+ # Creates a single record for a zone in the DNS provider. If the record
57
+ # exists, then it will not do anything.
58
+ #
59
+ # @param [Splicer::Records::Record] record
60
+ # @param [Splicer::Zone] zone
61
+ def create_record_in_zone(record, zone)
62
+ false
63
+ end
64
+ end
65
+
66
+ end
@@ -10,6 +10,12 @@ module Splicer
10
10
  @name = name
11
11
  @ttl = ttl
12
12
  end
13
+
14
+ # Check to see if the name is nil
15
+ # @return [Boolean]
16
+ def name?
17
+ !!@name
18
+ end
13
19
  end
14
20
 
15
21
  end
@@ -1,3 +1,3 @@
1
1
  module Splicer
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/splicer/zone.rb CHANGED
@@ -13,15 +13,17 @@ module Splicer
13
13
  end
14
14
 
15
15
  # Adds a single record to this zone
16
- # @return [void]
16
+ # @return [Boolean]
17
17
  def add_record(record)
18
+ return false unless record.is_a?(Splicer::Records::Record)
18
19
  @records.push(record)
20
+ true
19
21
  end
20
22
 
21
23
  # Adds a set of records to this zone
22
- # @return [void]
24
+ # @return [Boolean]
23
25
  def add_records(records)
24
- @records.concat(records)
26
+ records.each { |r| add_record(r) }
25
27
  end
26
28
 
27
29
  # @param [Symbol] method the method by which you want to publish
data/lib/splicer.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'splicer/version'
2
2
  require 'splicer/errors'
3
3
  require 'splicer/configuration'
4
+ require 'splicer/provider'
4
5
  require 'splicer/records'
5
6
  require 'splicer/zone'
6
7
 
@@ -23,8 +24,8 @@ require 'splicer/zone'
23
24
  # == Example Configureation
24
25
  #
25
26
  # Splicer.configure do |config|
26
- # config.register Splicer::Dynect::Config.new('company','user','password')
27
- # config.register Splicer::DNSMadeEasy::Config.new('user','password')
27
+ # config.register(Splicer::Dynect::Config.new('company','user','password'))
28
+ # config.register(Splicer::DNSMadeEasy::Config.new('user','password'))
28
29
  # end
29
30
  #
30
31
  # @see Splicer::Provider for more information
@@ -33,14 +34,77 @@ require 'splicer/zone'
33
34
  module Splicer
34
35
  @@configuration = nil
35
36
 
37
+ # Configures the splicer library
38
+ # @return [void]
36
39
  def self.configure &block
37
40
  @@configuration = Configuration.new
38
41
  yield(@@configuration)
39
42
  end
40
43
 
44
+ # Gets a list of providers
45
+ # @return [Array<Splicer::Providers::Base>]
41
46
  def self.providers
42
47
  @@configuration ||= Configuration.new
43
48
  @@configuration.providers
44
49
  end
45
50
 
51
+ # @return [void]
52
+ def self.create_zone(zone)
53
+ return false unless zone.is_a?(Splicer::Zone)
54
+ providers.each do |provider|
55
+ provider.create_zone(zone)
56
+ end
57
+ end
58
+
59
+ # @return [void]
60
+ def self.delete_zone(zone)
61
+ return false unless zone.is_a?(Splicer::Zone)
62
+ providers.each do |provider|
63
+ provider.delete_zone(zone)
64
+ end
65
+ end
66
+
67
+ # @return [void]
68
+ def self.rewrite_zone(zone)
69
+ return false unless zone.is_a?(Splicer::Zone)
70
+ providers.each do |provider|
71
+ provider.rewrite_zone(zone)
72
+ end
73
+ end
74
+
75
+ # @return [void]
76
+ def self.update_zone(zone)
77
+ return false unless zone.is_a?(Splicer::Zone)
78
+ providers.each do |provider|
79
+ provider.update_zone(provider)
80
+ end
81
+ end
82
+
83
+ # @return [void]
84
+ def self.create_record_in_zone(record, zone)
85
+ return false unless zone.is_a?(Splicer::Zone)
86
+ return false unless record.is_a?(Splicer::Records::Record)
87
+ providers.each do |provider|
88
+ provider.create_record_in_zone(record, zone)
89
+ end
90
+ end
91
+
92
+ # @return [void]
93
+ def self.update_record_in_zone(record, zone)
94
+ return false unless zone.is_a?(Splicer::Zone)
95
+ return false unless record.is_a?(Splicer::Records::Record)
96
+ providers.each do |provider|
97
+ provider.update_record_in_zone(record, zone)
98
+ end
99
+ end
100
+
101
+ # Deletes a record from a zone
102
+ # @return [void]
103
+ def self.delete_record_in_zone(record, zone)
104
+ return false unless zone.is_a?(Splicer::Zone)
105
+ return false unless record.is_a?(Splicer::Records::Record)
106
+ providers.each do |provider|
107
+ provider.delete_record_in_zone(record, zone)
108
+ end
109
+ end
46
110
  end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe Splicer::Provider do
4
+ let(:provider) { Splicer::Provider.new }
5
+ let(:zone) { Splicer::Zone.new('example.com') }
6
+ let(:record) { Splicer::Records::Record.new('name',123) }
7
+
8
+ describe '#create_zone' do
9
+ subject { provider.create_zone(zone) }
10
+ it { should eq(false) }
11
+ end
12
+
13
+ describe '#update_zone' do
14
+ subject { provider.update_zone(zone) }
15
+ it { should eq(false) }
16
+ end
17
+
18
+ describe '#rewrite_zone' do
19
+ subject { provider.rewrite_zone(zone) }
20
+ it { should eq(false) }
21
+ end
22
+
23
+ describe '#delete_zone' do
24
+ subject { provider.delete_zone(zone) }
25
+ it { should eq(false) }
26
+ end
27
+
28
+ describe '#delete_record_in_zone' do
29
+ subject { provider.delete_record_in_zone(record, zone) }
30
+ it { should eq(false) }
31
+ end
32
+
33
+ describe '#update_record_in_zone' do
34
+ subject { provider.update_record_in_zone(record, zone) }
35
+ it { should eq(false) }
36
+ end
37
+
38
+ describe '#create_record_in_zone' do
39
+ subject { provider.create_record_in_zone(record, zone) }
40
+ it { should eq(false) }
41
+ end
42
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splicer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-10 00:00:00.000000000 Z
12
+ date: 2013-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -77,6 +77,7 @@ files:
77
77
  - lib/splicer.rb
78
78
  - lib/splicer/configuration.rb
79
79
  - lib/splicer/errors.rb
80
+ - lib/splicer/provider.rb
80
81
  - lib/splicer/records.rb
81
82
  - lib/splicer/records/a_record.rb
82
83
  - lib/splicer/records/aaaa_record.rb
@@ -92,6 +93,7 @@ files:
92
93
  - lib/splicer/zone.rb
93
94
  - spec/spec_helper.rb
94
95
  - spec/splicer/configuration_spec.rb
96
+ - spec/splicer/provider_spec.rb
95
97
  - spec/splicer/records/a_record_spec.rb
96
98
  - spec/splicer/records/aaaa_record_spec.rb
97
99
  - spec/splicer/records/cname_record_spec.rb
@@ -120,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
122
  version: '0'
121
123
  segments:
122
124
  - 0
123
- hash: 1920739090551014309
125
+ hash: -162604281930152343
124
126
  required_rubygems_version: !ruby/object:Gem::Requirement
125
127
  none: false
126
128
  requirements:
@@ -129,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
131
  version: '0'
130
132
  segments:
131
133
  - 0
132
- hash: 1920739090551014309
134
+ hash: -162604281930152343
133
135
  requirements: []
134
136
  rubyforge_project:
135
137
  rubygems_version: 1.8.25
@@ -139,6 +141,7 @@ summary: Splicer allows communication with one or more dns providers
139
141
  test_files:
140
142
  - spec/spec_helper.rb
141
143
  - spec/splicer/configuration_spec.rb
144
+ - spec/splicer/provider_spec.rb
142
145
  - spec/splicer/records/a_record_spec.rb
143
146
  - spec/splicer/records/aaaa_record_spec.rb
144
147
  - spec/splicer/records/cname_record_spec.rb