zonefile 1.01 → 1.02

Sign up to get free protection for your applications and to get access to all the features.
@@ -57,6 +57,11 @@
57
57
  # zf.soa[:ttl] = '123123' # Change the SOA ttl
58
58
  # zf.a << { :class => 'IN', :name => 'www', :host => '192.168.100.1', :ttl => 3600 } # add A-Record
59
59
  #
60
+ # # Setting PTR records (deleting existing ones)
61
+ #
62
+ # zf.ptr = [ { :class => 'IN', :name=>'1.100.168.192.in-addr.arpa', :host => 'my.host.com' },
63
+ # { :class => 'IN', :name=>'2.100.168.192.in-addr.arpa', :host => 'me.host.com' } ]
64
+ #
60
65
  # # Increase Serial Number
61
66
  # zf.new_serial
62
67
  #
@@ -79,9 +84,16 @@ class Zonefile
79
84
  # global $TTL option
80
85
  attr :ttl
81
86
 
82
- def method_missing(m)
83
- return super unless RECORDS.include?(m.to_s)
84
- @records[m]
87
+ def method_missing(m, *args)
88
+ mname = m.to_s.sub("=","")
89
+ return super unless RECORDS.include?(mname)
90
+
91
+ if m.to_s[-1].chr == '=' then
92
+ @records[mname.intern] = args.first
93
+ @records[mname.intern]
94
+ else
95
+ @records[m]
96
+ end
85
97
  end
86
98
 
87
99
 
data/tests/zonefile.rb CHANGED
@@ -22,6 +22,18 @@ class TC_Zonefile < Test::Unit::TestCase
22
22
  zf.soa[:refresh] = 1234
23
23
  assert zf.empty?
24
24
  end
25
+
26
+ def test_setter
27
+ data = [ { :class => 'IN', :name => '123', :host => 'test' },
28
+ { :name => '321', :hosts => 'test2' } ]
29
+ @zf.ptr = data
30
+ assert_equal 2, @zf.ptr.size
31
+ assert @zf.ptr[0][:host] == data[0][:host]
32
+ assert @zf.ptr[1][:name] == data[1][:name]
33
+ assert_raise(NoMethodError) do
34
+ @zf.dont_exist(123,123,123)
35
+ end
36
+ end
25
37
 
26
38
 
27
39
  def test_soa
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zonefile
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 1
9
- version: "1.01"
8
+ - 2
9
+ version: "1.02"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Martin Boese
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-24 00:00:00 +01:00
17
+ date: 2011-10-03 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20