cloudflare-dns-update 0.0.3 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc6cf5b1dd89ee55d1687e17238998aa502ef012
4
- data.tar.gz: f737e3a7f23efb42ede7b9b78d78ae6cc8b47f0e
3
+ metadata.gz: 0914036e0da33020c961cfc4d386c80a23f834ec
4
+ data.tar.gz: 44565d1e878351c742ca76f76980bb0cb17a4300
5
5
  SHA512:
6
- metadata.gz: 4a0700a12dd7208fc4a15851b7253ababcd3110601cbd579021779312f45ac6cbeed39d656876ddf3b61e1c838838f59128d9159b1506644ff4fa13395450dd5
7
- data.tar.gz: a9d64a979cbcc427ec86692e4c3d00aa85d2f9c89a1259c0d87028018e746a156eabbb8233ba525ef079090b20cb49a2ed7c22a3c69f52f7d7b5fe4ec9bff6c4
6
+ metadata.gz: a1c7c8a67573e407d9d9080db16482dec37fe0fe47b227a52a225c335bb155bc0ecbbb1974a21f7e4d590352506c184f9b825ef3cce6a66d57b25e2be2d2d99e
7
+ data.tar.gz: 72a3cf7bd5fb7ab7f3445e77cfc0d95e442224ffc206ee12818a630968c30b52270b380e1db997b51aaf14ffbdea19d96574d5d215c63b2c455bce93c56afaa6
data/README.md CHANGED
@@ -20,6 +20,8 @@ Simply set up configurations for each domain you wish to update, and add to `/et
20
20
 
21
21
  cloudflare-dns-update --configuration /srv/dyndns/hinoki.oriontransfer.co.nz.yml
22
22
 
23
+ Note that in case you want to update more than one domains in a zone with the same IP address, you can have multiple domains in a configuration file. Follow instructions of the configuration process.
24
+
23
25
  ## Contributing
24
26
 
25
27
  1. Fork it
@@ -65,7 +65,7 @@ end
65
65
  cloudflare = nil
66
66
 
67
67
  configuration_store.transaction do |configuration|
68
- cloudflare = CloudFlare.new(configuration[:key], configuration[:email])
68
+ cloudflare = CloudFlare.connection(configuration[:key], configuration[:email])
69
69
  end
70
70
 
71
71
  configuration_store.transaction do |configuration|
@@ -76,22 +76,22 @@ configuration_store.transaction do |configuration|
76
76
  end
77
77
 
78
78
  configuration_store.transaction do |configuration|
79
- unless configuration[:domain]
79
+ unless configuration[:domains]
80
80
  puts "Getting list of domains for #{configuration[:zone]}..."
81
-
81
+
82
82
  result = cloudflare.rec_load_all(configuration[:zone])
83
83
 
84
- check_result(result) do
85
- records = result['response']['recs']['objs']
86
-
87
-
88
- records.each.with_index do |record, index|
89
- puts "(#{index}) #{record['name']} #{record['type']} #{record['content']}"
90
- end
91
-
92
- index = get_input "Which record to update?"
93
-
94
- configuration[:domain] = records[index.to_i]
84
+ records = result['response']['recs']['objs']
85
+
86
+ records.each.with_index do |record, index|
87
+ puts "(#{index}) #{record['name']} #{record['type']} #{record['content']}"
88
+ end
89
+
90
+ input = get_input "Which record to update?\nYou can select more than one record by separating numbers with comma (e.g. 0,2,5):"
91
+ indexes = input.split(',').map(&:strip)
92
+
93
+ configuration[:domains] = indexes.inject([]) do |a, index|
94
+ a << records[index.to_i]
95
95
  end
96
96
  end
97
97
  end
@@ -105,29 +105,29 @@ end
105
105
 
106
106
  configuration_store.transaction do |configuration|
107
107
  content = run(configuration[:content_command])
108
- domain = configuration[:domain]
108
+ domains = configuration[:domains] || [configuration[:domain]]
109
109
 
110
- if domain['content'] != content
111
- puts "Content changed #{content.dump}, updating record..."
112
- # zone, type, zoneid, name, content, ttl, service_mode = nil, prio = nil, service = nil, srvname = nil, protocol = nil, weight = nil, port = nil, target = nil
113
-
114
- arguments = [
115
- configuration[:zone],
116
- domain['type'],
117
- domain['rec_id'],
118
- domain['name'],
119
- content,
120
- domain['ttl']
121
- ]
122
-
123
- result = cloudflare.rec_edit(*arguments)
124
-
125
- check_result(result) do
110
+ domains.each do |domain|
111
+ if domain['content'] != content
112
+ puts "Content changed #{content.dump}, updating record..."
113
+ # zone, type, zoneid, name, content, ttl, service_mode = nil, prio = nil, service = nil, srvname = nil, protocol = nil, weight = nil, port = nil, target = nil
114
+
115
+ arguments = [
116
+ configuration[:zone],
117
+ domain['type'],
118
+ domain['rec_id'],
119
+ domain['name'],
120
+ content,
121
+ domain['ttl']
122
+ ]
123
+
124
+ result = cloudflare.rec_edit(*arguments)
125
+
126
126
  puts "Updating domain content: #{content}"
127
127
  domain['content'] = content
128
128
  configuration[:domain] = domain
129
+ else
130
+ puts "Content hasn't changed."
129
131
  end
130
- else
131
- puts "Content hasn't changed."
132
132
  end
133
133
  end
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "rake"
27
27
 
28
28
  spec.add_dependency "trollop", "~> 2.0.0"
29
- spec.add_dependency "cloudflare", "~> 1.1.3"
29
+ spec.add_dependency "cloudflare", "~> 2.0.0"
30
30
  end
@@ -20,7 +20,7 @@
20
20
 
21
21
  require "cloudflare/dns/update/version"
22
22
 
23
- class CloudFlare
23
+ module CloudFlare
24
24
  module DNS
25
25
  module Update
26
26
  end
@@ -19,10 +19,10 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
 
22
- class CloudFlare
22
+ module CloudFlare
23
23
  module DNS
24
24
  module Update
25
- VERSION = "0.0.3"
25
+ VERSION = "0.1.0"
26
26
  end
27
27
  end
28
28
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudflare-dns-update
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-04 00:00:00.000000000 Z
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: trollop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.0.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: cloudflare
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.1.3
61
+ version: 2.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.1.3
68
+ version: 2.0.0
69
69
  description: "\tProvides a client tool for updating CloudFlare records, with a specific\n\temphasis
70
70
  on updating IP addresses for domain records. This provides\n\tdyndns-like functionality.\n"
71
71
  email:
@@ -75,7 +75,7 @@ executables:
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
- - .gitignore
78
+ - ".gitignore"
79
79
  - Gemfile
80
80
  - README.md
81
81
  - Rakefile
@@ -93,17 +93,17 @@ require_paths:
93
93
  - lib
94
94
  required_ruby_version: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.0.6
106
+ rubygems_version: 2.2.2
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: A dyndns client for CloudFlare.