zonesync 0.4.1 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b070a5e3abcb48ba61c4b751babd7e0cd96bce294de28bebdd2a32af9f0e8104
4
- data.tar.gz: 0b947cfa076f5ece8f69d093fc3c8512820369f3df2c85ea505517fb6b8aefb0
3
+ metadata.gz: 9fc9d61a62a3b6c41fc4f1f77d2ce56f4997e66ef3c1803d46e5c7a500472509
4
+ data.tar.gz: 2fbc51c3f1ba373b5562ddaf8bbcca9691ac303d347e0a7b22fdaa77ff8e39ad
5
5
  SHA512:
6
- metadata.gz: bb90f015f8692698c7a922640cdc0b35e67d0e81298201ff4eda130a8c52cde32cabaf86c7bb10e1d92e7c4365079ebaa9d701933e6d73f79aa0350531ee0287
7
- data.tar.gz: 3239bb7f0b41cdbd61a4a0c6b0b73d8452ec732eb34deae66ed16788e96a7d66fd4a780bef79a033fd72634e63005445985222f6babd014565ebb89e30958948
6
+ metadata.gz: 2ebf4960b54b1ae4ef76288d4a1065a88be3310b4b13e3fdc88e78630622e38ed3ea10e36e08a4679d257e7ab5d0bad56366cd310a3bce55a2800862d79f4dcc
7
+ data.tar.gz: 7d153cb83948a650cf0c16b4fa582172b5484325bee65e7edc1228a6716942e46bdee1a168b716f36c117b6f70df786da82b24c12b5d37c86f80216a22ff4d3a
data/README.md CHANGED
@@ -80,7 +80,9 @@ $ bundle exec zonesync
80
80
  ```
81
81
  $ bundle exec zonesync --dry-run # log to STDOUT but don't actually perform the sync
82
82
  ```
83
-
83
+ ```
84
+ $ bundle exec zonesync generate # generate a Zonefile from the configured provider
85
+ ```
84
86
  #### Ruby
85
87
 
86
88
  Assuming your zone file lives in `hostfile.txt` and your DNS provider credentials are configured in `provider.yml`:
data/lib/zonesync/cli.rb CHANGED
@@ -9,6 +9,11 @@ module Zonesync
9
9
  Zonesync.call dry_run: options[:dry_run]
10
10
  end
11
11
 
12
+ desc "generate", "generates a Zonefile from the DNS server configured in Rails.application.credentials.zonesync"
13
+ def generate
14
+ Zonesync.generate
15
+ end
16
+
12
17
  def self.exit_on_failure? = true
13
18
  end
14
19
  end
@@ -4,6 +4,7 @@ require "zonesync/record"
4
4
  module Zonesync
5
5
  class Provider < Struct.new(:credentials)
6
6
  def self.from credentials
7
+ return credentials if credentials.is_a?(Provider)
7
8
  Zonesync.const_get(credentials[:provider]).new(credentials)
8
9
  end
9
10
 
@@ -27,6 +28,10 @@ module Zonesync
27
28
  raise NotImplementedError
28
29
  end
29
30
 
31
+ def write text
32
+ raise NotImplementedError
33
+ end
34
+
30
35
  def remove record
31
36
  raise NotImplementedError
32
37
  end
@@ -46,12 +51,20 @@ module Zonesync
46
51
  def read
47
52
  credentials[:string]
48
53
  end
54
+
55
+ def write string
56
+ credentials[:string] = string
57
+ end
49
58
  end
50
59
 
51
60
  class Filesystem < Provider
52
61
  def read
53
62
  File.read(credentials[:path])
54
63
  end
64
+
65
+ def write string
66
+ File.write(credentials[:path], string)
67
+ end
55
68
  end
56
69
  end
57
70
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zonesync
4
- VERSION = "0.4.1"
4
+ VERSION = "0.5.1"
5
5
  end
data/lib/zonesync.rb CHANGED
@@ -9,7 +9,12 @@ module Zonesync
9
9
  Sync.new({ provider: "Filesystem", path: zonefile }, credentials).call(dry_run: dry_run)
10
10
  end
11
11
 
12
+ def self.generate zonefile: "Zonefile", credentials: default_credentials
13
+ Generate.new({ provider: "Filesystem", path: zonefile }, credentials).call
14
+ end
15
+
12
16
  def self.default_credentials
17
+ require "active_support"
13
18
  require "active_support/encrypted_configuration"
14
19
  require "active_support/core_ext/hash/keys"
15
20
  ActiveSupport::EncryptedConfiguration.new(
@@ -20,6 +25,10 @@ module Zonesync
20
25
  ).zonesync
21
26
  end
22
27
 
28
+ def self.default_provider
29
+ Provider.from(default_credentials)
30
+ end
31
+
23
32
  class Sync < Struct.new(:source, :destination)
24
33
  def call dry_run: false
25
34
  source = Provider.from(self.source)
@@ -31,5 +40,13 @@ module Zonesync
31
40
  end
32
41
  end
33
42
  end
43
+
44
+ class Generate < Struct.new(:source, :destination)
45
+ def call
46
+ source = Provider.from(self.source)
47
+ destination = Provider.from(self.destination)
48
+ source.write(destination.read)
49
+ end
50
+ end
34
51
  end
35
52
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zonesync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-01-31 00:00:00.000000000 Z
12
+ date: 2024-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dns-zonefile