splicer 1.1.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTU2MTVhYzkyNDU3MjFkMzA0MWJhNTM4MTJlMDFjNDRjNjQ0OWQ2NA==
4
+ NWExN2U4NmUyMjAxMTNkZTJkOTBiMGE2NzcxOWZlNTFkNGIzZDhlMw==
5
5
  data.tar.gz: !binary |-
6
- Y2E2ZWUwZTUwMDY2ZTYzNjYzMTg1NGM3MzNhZDA4MDQ3ODg2ZjIyMw==
6
+ OTM0OGRiOTBiNDYyZWZhM2ZmNDEwMjkzYzg2NGY1ZGFkNGNjZWNkNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDhmY2E4YmMwY2FkYTFiYWE2ZDc3YTZhODFjNDRkOGZmNmFlZjZlNGQ3OWUz
10
- MDM1NmYxNTM3MTllMGY3NmRlODY2NzA2N2EzYjhiYjRjMTMyYWMyZWJjOWYx
11
- YWY2NDI4NTJiMjExZDRmZTM5MWU4NTgyMDQ0YzY2ZTUzYzEzZTQ=
9
+ YjU1Y2Y5MThkMTg2NTNhZjgzNDdmZDQ5YmM2OWRkNzllYTY0OTg0YWMyYWI3
10
+ OTYyNDM1MDhlYzY4ODk1ZWFkNDQ2MTJjOGRkMDI1NDM1NjI1ZGU1YzE5MWMx
11
+ ZDVjNWQwYzA2OTY0ZDU0MTk5OTZjZjgwOWI1YjI0ZjMxNzVhNzc=
12
12
  data.tar.gz: !binary |-
13
- MGFkYTBiYWFlNTI3NzkzMjM2OTU4ZjQ5YjM2YWJkNDU5YWEzN2QxMTc5M2Jj
14
- MTgxMTU5OTRhNjc5MjI0OGYzOGMyZmRjZWZkNDRiMWIxYjM4MzI1MWZlMjlk
15
- Yjg0OWE1ZmZkODg0MjFhNGM2ZjBiMGNmOWUwOTQ5MWVlZWNkMGM=
13
+ ZmFjYjE1ZDhjY2JiZDhhZGU4NTgzYzk3YmUxYzIxNDVhNjQyNjc2NzRkMTVl
14
+ NGY3OWRkYzU2MzJiYTA0OTcyYzY4YTkwMzYzMTBmNGIyZTkxZTVlZjM0Yjdj
15
+ OWM5ZTk2YzY1NGQwZDRlZWQ3M2FmMzYzZmIxZTMwMjU5ZDhiYTg=
@@ -1,8 +1,11 @@
1
1
  module Splicer
2
2
 
3
3
  class Configuration
4
+ attr_accessor :logger
5
+
4
6
  def initialize
5
7
  @configs = []
8
+ @logger = NullObject.new
6
9
  end
7
10
 
8
11
  # @param [Object] config the configuration for a provider
@@ -0,0 +1,13 @@
1
+ module Splicer
2
+
3
+ class NullObject
4
+ def initialize(*args)
5
+ true
6
+ end
7
+
8
+ def method_missing(*args, &block)
9
+ self
10
+ end
11
+ end
12
+
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Splicer
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.1"
3
3
  end
data/lib/splicer.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'splicer/version'
2
2
  require 'splicer/errors'
3
+ require 'splicer/null_object'
3
4
  require 'splicer/configuration'
4
5
  require 'splicer/provider'
5
6
  require 'splicer/records'
@@ -26,6 +27,7 @@ require 'splicer/zone'
26
27
  # Splicer.configure do |config|
27
28
  # config.register(Splicer::Dynect::Config.new('company','user','password'))
28
29
  # config.register(Splicer::DNSMadeEasy::Config.new('user','password'))
30
+ # config.logger = Logger.new(STDOUT)
29
31
  # end
30
32
  #
31
33
  # @see Splicer::Provider for more information
@@ -33,12 +35,14 @@ require 'splicer/zone'
33
35
  # @author Matthew A. Johnston <warmwaffles@gmail.com>
34
36
  module Splicer
35
37
  @@configuration = nil
38
+ @@logger = nil
36
39
 
37
40
  # Configures the splicer library
38
41
  # @return [void]
39
42
  def self.configure &block
40
43
  @@configuration = Configuration.new
41
44
  yield(@@configuration)
45
+ @@logger = @@configuration.logger
42
46
  end
43
47
 
44
48
  # Gets a list of providers
@@ -107,4 +111,10 @@ module Splicer
107
111
  provider.delete_record_in_zone(record, zone)
108
112
  end
109
113
  end
114
+
115
+ # The logger that splicer will use
116
+ # @return [Logger|Splicer::NullObject]
117
+ def self.logger
118
+ @@logger
119
+ end
110
120
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Splicer::NullObject do
4
+ describe '#initialize' do
5
+ it 'should initialize' do
6
+ expect { Splicer::NullObject.new('a', 1, Object.new ) }.to_not raise_error(StandardError)
7
+ end
8
+ end
9
+
10
+ describe '#method_missing' do
11
+ let(:null) { Splicer::NullObject.new }
12
+ context 'when calling #info' do
13
+ subject { null.info('something') }
14
+ it { should be_a(Splicer::NullObject) }
15
+ end
16
+ context 'when calling #debug' do
17
+ subject { null.debug('something') }
18
+ it { should be_a(Splicer::NullObject) }
19
+ end
20
+ context 'when calling #error' do
21
+ subject { null.error('something') }
22
+ it { should be_a(Splicer::NullObject) }
23
+ end
24
+ context 'when calling #warn' do
25
+ subject { null.warn('something') }
26
+ it { should be_a(Splicer::NullObject) }
27
+ end
28
+ context 'when calling #fatal' do
29
+ subject { null.fatal('something') }
30
+ it { should be_a(Splicer::NullObject) }
31
+ end
32
+ end
33
+ end
@@ -17,7 +17,7 @@ describe Splicer::Zone do
17
17
  end
18
18
 
19
19
  describe '#add_record' do
20
- let(:record) { double('ARecord') }
20
+ let(:record) { Splicer::Records::ARecord.new(nil, '127.0.0.1') }
21
21
 
22
22
  it "should add the record" do
23
23
  expect { zone.add_record(record) }.to change(zone.records, :count).by(1)
@@ -25,8 +25,8 @@ describe Splicer::Zone do
25
25
  end
26
26
 
27
27
  describe '#add_records' do
28
- let(:cname_record) { double('CNAMERecord') }
29
- let(:a_record) { double('ARecord') }
28
+ let(:cname_record) { Splicer::Records::CNAMERecord.new('www', 'example.com') }
29
+ let(:a_record) { Splicer::Records::ARecord.new(nil, '127.0.0.1') }
30
30
 
31
31
  it "should add the records" do
32
32
  expect { zone.add_records([a_record, cname_record]) }.to change(zone.records, :count).by(2)
data/spec/splicer_spec.rb CHANGED
@@ -37,4 +37,9 @@ describe Splicer do
37
37
  end
38
38
  end
39
39
 
40
+ describe '.logger' do
41
+ subject { Splicer.logger }
42
+ it { should be_a(Splicer::NullObject) }
43
+ end
44
+
40
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splicer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Johnston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-13 00:00:00.000000000 Z
11
+ date: 2013-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,6 +70,7 @@ files:
70
70
  - lib/splicer.rb
71
71
  - lib/splicer/configuration.rb
72
72
  - lib/splicer/errors.rb
73
+ - lib/splicer/null_object.rb
73
74
  - lib/splicer/provider.rb
74
75
  - lib/splicer/records.rb
75
76
  - lib/splicer/records/a_record.rb
@@ -86,6 +87,7 @@ files:
86
87
  - lib/splicer/zone.rb
87
88
  - spec/spec_helper.rb
88
89
  - spec/splicer/configuration_spec.rb
90
+ - spec/splicer/null_object_spec.rb
89
91
  - spec/splicer/provider_spec.rb
90
92
  - spec/splicer/records/a_record_spec.rb
91
93
  - spec/splicer/records/aaaa_record_spec.rb
@@ -127,6 +129,7 @@ summary: Splicer allows communication with one or more dns providers
127
129
  test_files:
128
130
  - spec/spec_helper.rb
129
131
  - spec/splicer/configuration_spec.rb
132
+ - spec/splicer/null_object_spec.rb
130
133
  - spec/splicer/provider_spec.rb
131
134
  - spec/splicer/records/a_record_spec.rb
132
135
  - spec/splicer/records/aaaa_record_spec.rb