zonesync 0.4.0 → 0.4.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 +4 -4
- data/lib/zonesync/cloudflare.rb +20 -7
- data/lib/zonesync/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b070a5e3abcb48ba61c4b751babd7e0cd96bce294de28bebdd2a32af9f0e8104
|
|
4
|
+
data.tar.gz: 0b947cfa076f5ece8f69d093fc3c8512820369f3df2c85ea505517fb6b8aefb0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb90f015f8692698c7a922640cdc0b35e67d0e81298201ff4eda130a8c52cde32cabaf86c7bb10e1d92e7c4365079ebaa9d701933e6d73f79aa0350531ee0287
|
|
7
|
+
data.tar.gz: 3239bb7f0b41cdbd61a4a0c6b0b73d8452ec732eb34deae66ed16788e96a7d66fd4a780bef79a033fd72634e63005445985222f6babd014565ebb89e30958948
|
data/lib/zonesync/cloudflare.rb
CHANGED
|
@@ -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"]
|
|
39
|
-
|
|
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")
|
data/lib/zonesync/version.rb
CHANGED