dns_incrementor 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4b39ad22297e106c92c4272c859a952132b1ad46
4
+ data.tar.gz: 4b8d66d3c687b5639d6b7a7f5eb168b3dfb6d628
5
+ SHA512:
6
+ metadata.gz: f7a21c4e4950df0b6ee9e9c599d4fe60bfea5751730b34a8b1cda02a4b745a3a2b1748892cd49eb49cc8cdbf7908339c81584a5df52782dd443138d749c0f938
7
+ data.tar.gz: a52e302fa068270027fdc95a4170ca5ae7043ae16aca6f862fc7dfa8ffa81fdfaa1e9d6b8bbc3e108191638e0abde30cd4f1f31dd36b4518da605079bedc4fbf
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2014, Dafydd Crosby
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice, this
11
+ list of conditions and the following disclaimer in the documentation and/or
12
+ other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
18
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ dns_incrementor
2
+ ===============
3
+
4
+ I got really sick of incrementing the DNS serial. So I made this.
5
+
6
+ It replaces your zone serial in YYYYmmddxx (xx being the version for the day) with the latest date and resets the version counter if necessary
7
+
8
+ Installation
9
+ ------------
10
+
11
+ `gem install dns_incrementor`
12
+
13
+ Usage
14
+ -----
15
+
16
+ `dns_incrementor example.zone`
17
+
18
+ Bugs
19
+ ----
20
+
21
+ It will overflow the serial if you make more than 100 revisions in a day (eg. 2014123199 -> 20141231100). If you need to make more than 100 revisions a day, then either you're doing something very wrong or you've got enough going on that maybe this script isn't for you.
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright 2014 Dafydd Crosby
3
+ # All rights reserved.
4
+
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+
8
+ # 1. Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
13
+
14
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
18
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+
25
+ require 'time'
26
+
27
+ file_name = ARGV[0]
28
+
29
+ begin
30
+ zone = File.read(file_name)
31
+ rescue
32
+ puts "Could not read #{file_name}"
33
+ exit
34
+ end
35
+ if zone =~ /(?<date>20\d\d(0[1-9]|1[0-2])(0[1-9]|1\d|2\d|30|31))(?<num>\d\d)/
36
+ match = Regexp.last_match(0)
37
+ date = Regexp.last_match[:date]
38
+ num = Regexp.last_match[:num]
39
+ today = Time.now.strftime("%Y%m%d")
40
+ new_num = today.to_i > date.to_i ? 0 : num.to_i + 1
41
+ # BUG - overflow possible after 99 iterations
42
+ new_serial = "%s%.2i" % [today, new_num]
43
+ zone.gsub!(match, new_serial)
44
+ begin
45
+ File.open(file_name, 'w') {|file| file << zone}
46
+ rescue
47
+ puts "Could not write to file #{file_name}"
48
+ end
49
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |gem|
3
+ gem.name = "dns_incrementor"
4
+ gem.authors = ["Dafydd Crosby"]
5
+ gem.description = %q{Increment serial in DNS zone files}
6
+ gem.summary = %q{Finally, a script to save you 2 seconds bumping the serial each time you edit a DNS zone file}
7
+
8
+ gem.email = "dafydd@dafyddcrosby.com"
9
+ gem.homepage = "https://github.com/dafyddcrosby/dns_incrementor"
10
+
11
+ gem.license = 'bsd' # The (two-clause) BSD License
12
+
13
+ gem.files = `git ls-files`.split($\)
14
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.version = '1.0.0'
16
+ gem.required_ruby_version = '>= 1.9'
17
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dns_incrementor
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dafydd Crosby
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Increment serial in DNS zone files
14
+ email: dafydd@dafyddcrosby.com
15
+ executables:
16
+ - dns_incrementor
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE
21
+ - README.md
22
+ - bin/dns_incrementor
23
+ - dns_incrementor.gemspec
24
+ homepage: https://github.com/dafyddcrosby/dns_incrementor
25
+ licenses:
26
+ - bsd
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '1.9'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.0.14
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Finally, a script to save you 2 seconds bumping the serial each time you
48
+ edit a DNS zone file
49
+ test_files: []