zonesync 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00751af08d69afada768a779c3e2344b3e728e0b3ee9162436f82f936737bcab
4
- data.tar.gz: 772a439ddfd4f9e9cd96bffeade456ba7023732e221a81ef48c39595f0e2328d
3
+ metadata.gz: b070a5e3abcb48ba61c4b751babd7e0cd96bce294de28bebdd2a32af9f0e8104
4
+ data.tar.gz: 0b947cfa076f5ece8f69d093fc3c8512820369f3df2c85ea505517fb6b8aefb0
5
5
  SHA512:
6
- metadata.gz: 896d74bfd34d5f4609c5e4ab9d79bcad73b812b694941ab24f3807f6d3a08f9d25c28b13dc73201a6e6ed318ae475e43f641f7c9376c8b4af612ea0ba0c3d78d
7
- data.tar.gz: a6568612418b311a6c3c89bf8a8e680214336d0075e05373aad7ca7ad32938e000175ed72c198d230dc3d9c7ecfbfcc6ce37b4125c14cf3376d83834ba9e9b4b
6
+ metadata.gz: bb90f015f8692698c7a922640cdc0b35e67d0e81298201ff4eda130a8c52cde32cabaf86c7bb10e1d92e7c4365079ebaa9d701933e6d73f79aa0350531ee0287
7
+ data.tar.gz: 3239bb7f0b41cdbd61a4a0c6b0b73d8452ec732eb34deae66ed16788e96a7d66fd4a780bef79a033fd72634e63005445985222f6babd014565ebb89e30958948
@@ -35,18 +35,31 @@ module Zonesync
35
35
  @records ||= begin
36
36
  response = http.get(nil)
37
37
  response["result"].reduce({}) do |map, attrs|
38
- map.merge attrs["id"] => Record.new(
39
- attrs["name"] + ".", # normalize to trailing period
40
- attrs["type"],
41
- attrs["ttl"].to_i,
42
- attrs["content"],
43
- ).to_h
44
- end.invert
38
+ map.merge to_record(attrs) => attrs["id"]
39
+ end
45
40
  end
46
41
  end
47
42
 
48
43
  private
49
44
 
45
+ def to_record attrs
46
+ rdata = attrs["content"]
47
+ if %w[CNAME MX].include?(attrs["type"])
48
+ rdata = normalize_trailing_period(rdata)
49
+ end
50
+
51
+ Record.new(
52
+ normalize_trailing_period(attrs["name"]),
53
+ attrs["type"],
54
+ attrs["ttl"].to_i,
55
+ rdata,
56
+ ).to_h
57
+ end
58
+
59
+ def normalize_trailing_period value
60
+ value =~ /\.$/ ? value : value + "."
61
+ end
62
+
50
63
  def http
51
64
  return @http if @http
52
65
  @http = HTTP.new("https://api.cloudflare.com/client/v4/zones/#{credentials[:zone_id]}/dns_records")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zonesync
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
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.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel