dns_adapter 0.0.5 → 0.0.6

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: 3d8dfc76014b9bfd17a92150ac19f3846adad58e
4
- data.tar.gz: 6aea0dfbb4a549a6304243cc7a777944027fea83
3
+ metadata.gz: 7ebb8290a9ed4fb59e1d7b4672c7293482102b29
4
+ data.tar.gz: fd4919453ea2a37c820150183762693ac972a5b4
5
5
  SHA512:
6
- metadata.gz: 32bd75b2bdb092278b03737d27d3fefb4e1a5a1401b241e5507c1f710e870a314ff0cee804a0da547f46c20feac077d6a406e356fe23fe6fed0d408fba55012e
7
- data.tar.gz: c027ec4d89fb7b870c823ff8f0dd80e6239fde10c2089cd23524d09938e610fa834c803e64ed07ac7707e760da85002e4348cfa062674775501f6fc109449525
6
+ metadata.gz: 11213627f86949e648a426f65db6eb5ec08a05ecf549abcba48b9c52a0496f9c914b6d49e156503af4d2c67567ec0a6e9a9ed727d7e7b6c228a47e8fd2074ab8
7
+ data.tar.gz: cb7b62d7c1973b490d36320ada3c074353c8303790a3cdc95eb85f001af4a9c7113a67b4bae8577011f77323470bda6850e167e842cc40a8988474c134ac5cdd
data/.codeclimate.yml ADDED
@@ -0,0 +1,9 @@
1
+ ---
2
+ engines:
3
+ duplication:
4
+ enabled: true
5
+ config:
6
+ languages:
7
+ - ruby
8
+ - javascript
9
+
data/.travis.yml CHANGED
@@ -1,9 +1,11 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  env:
3
- - CODECLIMATE_REPO_TOKEN=9881d1116b64b55a16845046a4a2dc43f12203d7201a33ce92fec4b7732e3c93
4
+ - CODECLIMATE_REPO_TOKEN=230883de63c3f82afe4a809f5a488bd849ddfbbaa2c10dae95b57aaf2e60c1e9
4
5
  rvm:
5
- - 2.0.0
6
+ - 2.0
6
7
  - 2.1
7
- - 2.2
8
- - jruby-19mode
8
+ - 2.2.5
9
+ - 2.3.1
10
+ - jruby-9.0.4.0
9
11
 
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # DNSAdapter
2
2
 
3
- [![Build Status](https://travis-ci.org/petergoldstein/dns_adapter.svg?branch=master)](https://travis-ci.org/petergoldstein/dns_adapter)
4
- [![Test Coverage](https://codeclimate.com/github/petergoldstein/dns_adapter/badges/coverage.svg)](https://codeclimate.com/github/petergoldstein/dns_adapter)
5
- [![Code Climate](https://codeclimate.com/github/petergoldstein/dns_adapter/badges/gpa.svg)](https://codeclimate.com/github/petergoldstein/dns_adapter)
3
+ [![Build Status](https://travis-ci.org/ValiMail/dns_adapter.svg?branch=master)](https://travis-ci.org/ValiMail/dns_adapter)
4
+ [![Test Coverage](https://codeclimate.com/github/ValiMail/dns_adapter/badges/coverage.svg)](https://codeclimate.com/github/ValiMail/dns_adapter)
5
+ [![Code Climate](https://codeclimate.com/github/ValiMail/dns_adapter/badges/gpa.svg)](https://codeclimate.com/github/ValiMail/dns_adapter)
6
6
 
7
7
  An adapter layer for DNS queries that makes it simple to swap in different DNS providers.
8
8
 
@@ -72,10 +72,10 @@ module DNSAdapter
72
72
  end
73
73
  end
74
74
 
75
- TIMEOUT = 'TIMEOUT'
75
+ TIMEOUT = 'TIMEOUT'.freeze
76
76
  def check_for_timeout(record_set)
77
77
  return [] if record_set.select { |r| r == TIMEOUT }.empty?
78
- fail DNSAdapter::TimeoutError
78
+ raise DNSAdapter::TimeoutError
79
79
  end
80
80
 
81
81
  RECORD_TYPE_TO_ATTR_NAME_MAP = {
@@ -87,12 +87,12 @@ module DNSAdapter
87
87
  'CNAME' => :name,
88
88
  'SPF' => :text,
89
89
  'TXT' => :text
90
- }
90
+ }.freeze
91
91
 
92
92
  def formatted_records(records, type)
93
93
  records.map do |r|
94
94
  val = r[type]
95
- fail DNSAdapter::TimeoutError if val == TIMEOUT
95
+ raise DNSAdapter::TimeoutError if val == TIMEOUT
96
96
  val = normalize_value(val, type)
97
97
  {
98
98
  type: type,
@@ -60,7 +60,9 @@ module DNSAdapter
60
60
  type: type,
61
61
  # Use strings.join('') to avoid JRuby issue where
62
62
  # data only returns the first string
63
- text: record.strings.join(''),
63
+ text: record.strings.join('').encode('US-ASCII', invalid: :replace,
64
+ undef: :replace,
65
+ replace: '?'),
64
66
  ttl: record.ttl
65
67
  }
66
68
  end
@@ -91,8 +93,8 @@ module DNSAdapter
91
93
  resources = getresources(domain, rr_type)
92
94
 
93
95
  unless resources
94
- fail DNSAdapter::Error,
95
- "Unknown error on DNS '#{rr_type}' lookup of '#{domain}'"
96
+ raise DNSAdapter::Error,
97
+ "Unknown error on DNS '#{rr_type}' lookup of '#{domain}'"
96
98
  end
97
99
 
98
100
  resources
@@ -108,12 +110,12 @@ module DNSAdapter
108
110
  raise DNSAdapter::Error, "Error on DNS lookup of '#{domain}'"
109
111
  end
110
112
 
111
- SUPPORTED_RR_TYPES = %w(A AAAA MX PTR TXT SPF NS CNAME)
113
+ SUPPORTED_RR_TYPES = %w(A AAAA MX PTR TXT SPF NS CNAME).freeze
112
114
  def self.type_class(rr_type)
113
115
  if SUPPORTED_RR_TYPES.include?(rr_type)
114
116
  Resolv::DNS::Resource::IN.const_get(rr_type)
115
117
  else
116
- fail ArgumentError, "Unknown RR type: #{rr_type}"
118
+ raise ArgumentError, "Unknown RR type: #{rr_type}"
117
119
  end
118
120
  end
119
121
 
@@ -1,3 +1,3 @@
1
1
  module DNSAdapter
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'.freeze
3
3
  end
@@ -20,7 +20,7 @@ describe DNSAdapter::ResolvClient do
20
20
  results = subject.fetch_a_records(domain)
21
21
  expect(results.size).to eq(record_list.length)
22
22
  expect(results.map { |x| x[:type] })
23
- .to eq(record_list.length.times.map { 'A' })
23
+ .to eq(Array.new(record_list.length) { 'A' })
24
24
  expect(results.map { |x| x[:address] })
25
25
  .to eq(record_list.map(&:address).map(&:to_s))
26
26
  end
@@ -32,7 +32,7 @@ describe DNSAdapter::ResolvClient do
32
32
  results = subject.fetch_a_records(domain_with_trailing)
33
33
  expect(results.size).to eq(record_list.length)
34
34
  expect(results.map { |x| x[:type] })
35
- .to eq(record_list.length.times.map { 'A' })
35
+ .to eq(Array.new(record_list.length) { 'A' })
36
36
  expect(results.map { |x| x[:address] })
37
37
  .to eq(record_list.map(&:address).map(&:to_s))
38
38
  end
@@ -92,7 +92,7 @@ describe DNSAdapter::ResolvClient do
92
92
  results = subject.fetch_aaaa_records(domain)
93
93
  expect(results.size).to eq(record_list.length)
94
94
  expect(results.map { |x| x[:type] })
95
- .to eq(record_list.length.times.map { 'AAAA' })
95
+ .to eq(Array.new(record_list.length) { 'AAAA' })
96
96
  expect(results.map { |x| x[:address] })
97
97
  .to eq(record_list.map(&:address).map(&:to_s))
98
98
  end
@@ -104,7 +104,7 @@ describe DNSAdapter::ResolvClient do
104
104
  results = subject.fetch_aaaa_records(domain_with_trailing)
105
105
  expect(results.size).to eq(record_list.length)
106
106
  expect(results.map { |x| x[:type] })
107
- .to eq(record_list.length.times.map { 'AAAA' })
107
+ .to eq(Array.new(record_list.length) { 'AAAA' })
108
108
  expect(results.map { |x| x[:address] })
109
109
  .to eq(record_list.map(&:address).map(&:to_s))
110
110
  end
@@ -152,7 +152,7 @@ describe DNSAdapter::ResolvClient do
152
152
  results = subject.fetch_mx_records(domain)
153
153
  expect(results.size).to eq(record_list.length)
154
154
  expect(results.map { |x| x[:type] })
155
- .to eq(record_list.length.times.map { 'MX' })
155
+ .to eq(Array.new(record_list.length) { 'MX' })
156
156
  expect(results.map { |x| x[:exchange] })
157
157
  .to eq(record_list.map(&:exchange).map(&:to_s))
158
158
  end
@@ -164,7 +164,7 @@ describe DNSAdapter::ResolvClient do
164
164
  results = subject.fetch_mx_records(domain_with_trailing)
165
165
  expect(results.size).to eq(record_list.length)
166
166
  expect(results.map { |x| x[:type] })
167
- .to eq(record_list.length.times.map { 'MX' })
167
+ .to eq(Array.new(record_list.length) { 'MX' })
168
168
  expect(results.map { |x| x[:exchange] })
169
169
  .to eq(record_list.map(&:exchange).map(&:to_s))
170
170
  end
@@ -213,10 +213,11 @@ describe DNSAdapter::ResolvClient do
213
213
  results = subject.fetch_txt_records(domain)
214
214
  expect(results.size).to eq(record_list.length)
215
215
  expect(results.map { |x| x[:type] })
216
- .to eq(record_list.length.times.map { 'TXT' })
216
+ .to eq(Array.new(record_list.length) { 'TXT' })
217
217
  expect(results.map { |x| x[:text] }).to eq(
218
218
  [first_txt_string,
219
- ([second_txt_string] + second_txt_string_array).join('')])
219
+ ([second_txt_string] + second_txt_string_array).join('')]
220
+ )
220
221
  end
221
222
 
222
223
  it 'should map when the domain has a trailing dot' do
@@ -227,10 +228,11 @@ describe DNSAdapter::ResolvClient do
227
228
  results = subject.fetch_txt_records(domain_with_trailing)
228
229
  expect(results.size).to eq(record_list.length)
229
230
  expect(results.map { |x| x[:type] })
230
- .to eq(record_list.length.times.map { 'TXT' })
231
+ .to eq(Array.new(record_list.length) { 'TXT' })
231
232
  expect(results.map { |x| x[:text] }).to eq(
232
233
  [first_txt_string,
233
- ([second_txt_string] + second_txt_string_array).join('')])
234
+ ([second_txt_string] + second_txt_string_array).join('')]
235
+ )
234
236
  end
235
237
 
236
238
  it 'should map the Resolv errors to Coppertone errors' do
@@ -277,10 +279,11 @@ describe DNSAdapter::ResolvClient do
277
279
  results = subject.fetch_spf_records(domain)
278
280
  expect(results.size).to eq(record_list.length)
279
281
  expect(results.map { |x| x[:type] })
280
- .to eq(record_list.length.times.map { 'SPF' })
282
+ .to eq(Array.new(record_list.length) { 'SPF' })
281
283
  expect(results.map { |x| x[:text] }).to eq(
282
284
  [first_spf_string,
283
- ([second_spf_string] + second_spf_string_array).join('')])
285
+ ([second_spf_string] + second_spf_string_array).join('')]
286
+ )
284
287
  end
285
288
 
286
289
  it 'should map when the domain has a trailing dot' do
@@ -291,10 +294,11 @@ describe DNSAdapter::ResolvClient do
291
294
  results = subject.fetch_spf_records(domain_with_trailing)
292
295
  expect(results.size).to eq(record_list.length)
293
296
  expect(results.map { |x| x[:type] })
294
- .to eq(record_list.length.times.map { 'SPF' })
297
+ .to eq(Array.new(record_list.length) { 'SPF' })
295
298
  expect(results.map { |x| x[:text] }).to eq(
296
299
  [first_spf_string,
297
- ([second_spf_string] + second_spf_string_array).join('')])
300
+ ([second_spf_string] + second_spf_string_array).join('')]
301
+ )
298
302
  end
299
303
 
300
304
  it 'should map the Resolv errors to Coppertone errors' do
@@ -333,9 +337,10 @@ describe DNSAdapter::ResolvClient do
333
337
  results = subject.fetch_ptr_records(arpa_domain)
334
338
  expect(results.size).to eq(record_list.length)
335
339
  expect(results.map { |x| x[:type] })
336
- .to eq(record_list.length.times.map { 'PTR' })
340
+ .to eq(Array.new(record_list.length) { 'PTR' })
337
341
  expect(results.map { |x| x[:name] }).to eq(
338
- [first_ptr_name])
342
+ [first_ptr_name]
343
+ )
339
344
  end
340
345
 
341
346
  it 'should map when the domain has a trailing dot' do
@@ -346,9 +351,10 @@ describe DNSAdapter::ResolvClient do
346
351
  results = subject.fetch_ptr_records(arpa_domain_with_trailing)
347
352
  expect(results.size).to eq(record_list.length)
348
353
  expect(results.map { |x| x[:type] })
349
- .to eq(record_list.length.times.map { 'PTR' })
354
+ .to eq(Array.new(record_list.length) { 'PTR' })
350
355
  expect(results.map { |x| x[:name] }).to eq(
351
- [first_ptr_name])
356
+ [first_ptr_name]
357
+ )
352
358
  end
353
359
 
354
360
  it 'should map the Resolv errors to Coppertone errors' do
@@ -387,9 +393,10 @@ describe DNSAdapter::ResolvClient do
387
393
  results = subject.fetch_ns_records(ns_domain)
388
394
  expect(results.size).to eq(record_list.length)
389
395
  expect(results.map { |x| x[:type] })
390
- .to eq(record_list.length.times.map { 'NS' })
396
+ .to eq(Array.new(record_list.length) { 'NS' })
391
397
  expect(results.map { |x| x[:name] }).to eq(
392
- [first_ns_name])
398
+ [first_ns_name]
399
+ )
393
400
  end
394
401
 
395
402
  it 'should map when the domain has a trailing dot' do
@@ -400,9 +407,10 @@ describe DNSAdapter::ResolvClient do
400
407
  results = subject.fetch_ns_records(ns_domain_with_trailing)
401
408
  expect(results.size).to eq(record_list.length)
402
409
  expect(results.map { |x| x[:type] })
403
- .to eq(record_list.length.times.map { 'NS' })
410
+ .to eq(Array.new(record_list.length) { 'NS' })
404
411
  expect(results.map { |x| x[:name] }).to eq(
405
- [first_ns_name])
412
+ [first_ns_name]
413
+ )
406
414
  end
407
415
 
408
416
  it 'should map the Resolv errors to Coppertone errors' do
@@ -441,9 +449,10 @@ describe DNSAdapter::ResolvClient do
441
449
  results = subject.fetch_cname_records(cname_domain)
442
450
  expect(results.size).to eq(record_list.length)
443
451
  expect(results.map { |x| x[:type] })
444
- .to eq(record_list.length.times.map { 'CNAME' })
452
+ .to eq(Array.new(record_list.length) { 'CNAME' })
445
453
  expect(results.map { |x| x[:name] }).to eq(
446
- [first_cname_name])
454
+ [first_cname_name]
455
+ )
447
456
  end
448
457
 
449
458
  it 'should map when the domain has a trailing dot' do
@@ -454,9 +463,10 @@ describe DNSAdapter::ResolvClient do
454
463
  results = subject.fetch_cname_records(cname_domain_with_trailing)
455
464
  expect(results.size).to eq(record_list.length)
456
465
  expect(results.map { |x| x[:type] })
457
- .to eq(record_list.length.times.map { 'CNAME' })
466
+ .to eq(Array.new(record_list.length) { 'CNAME' })
458
467
  expect(results.map { |x| x[:name] }).to eq(
459
- [first_cname_name])
468
+ [first_cname_name]
469
+ )
460
470
  end
461
471
 
462
472
  it 'should map the Resolv errors to Coppertone errors' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dns_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter M. Goldstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-18 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,6 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".codeclimate.yml"
76
77
  - ".gitignore"
77
78
  - ".travis.yml"
78
79
  - Gemfile
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  version: '0'
110
111
  requirements: []
111
112
  rubyforge_project:
112
- rubygems_version: 2.4.8
113
+ rubygems_version: 2.5.1
113
114
  signing_key:
114
115
  specification_version: 4
115
116
  summary: An adapter layer for DNS queries.