dps 0.0.2 → 0.0.3

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: 5f49a40f255bb096899ff67412d4764bc9a14f496877128a3df44c0288800b36
4
- data.tar.gz: 21b09284b7c311c89596e37bbcc73cd016de755697c04838cdc47ff0ebb6080b
3
+ metadata.gz: f6bcfbdc8e0ef48e5c38505ca0d5e08ad4976f78e0cd242f1a57215ceae46da6
4
+ data.tar.gz: '0568d8eebea462377ad1ce3ba3c8a41e079308f5620bcb2855f9750d9d3c0c0b'
5
5
  SHA512:
6
- metadata.gz: 55e2cd04730bc83b32ffc4debd33089cd2475bb67cc02f009e32ded6ab0a1743dcdda7621817965720dbea26365bc744caf97ecc73fee19fba04a0e898848380
7
- data.tar.gz: 0a65ee7ec9648db6437de52912dbcdc475262a31d250516fb1ba96befb35b32666f98f7568336afe6635f8d7938808816eaec14126c94a53fab8d370d386cde8
6
+ metadata.gz: 9a3c88359398b5f95436eb103691496b13844177d16d4864dd226e1ad0f3b06cbca493f4a9646cd26c7ff4727bc31a93f11562ed130923a2dfc3276f2bcac948
7
+ data.tar.gz: 5b4fa1290ed2a10a79ab8717076d92425709342f26dd3275fa64346948cbfb4f800165e375bd66a7d34da255848d7963038149323c9809587717e2b632ea0af1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dps (0.0.1)
4
+ dps (0.0.2)
5
5
  dnsruby (~> 1.61)
6
6
 
7
7
  GEM
@@ -38,4 +38,4 @@ DEPENDENCIES
38
38
  rspec (~> 3.8)
39
39
 
40
40
  BUNDLED WITH
41
- 1.17.0.pre.1
41
+ 1.17.3
data/lib/dps/dns.rb CHANGED
@@ -3,12 +3,9 @@ require 'dnsruby'
3
3
  module DPS
4
4
  class DNS
5
5
 
6
- class NoRecords; end
7
- class TooManyRecords; end
8
-
9
6
  class << self
10
7
  def get_records(domain)
11
- get_dns_txt_records(domain).
8
+ get_txt_records(domain).
12
9
  collect { |value| decode_txt_record(value) }.select(&:valid?)
13
10
  end
14
11
 
@@ -17,12 +14,14 @@ module DPS
17
14
 
18
15
  # Reverse since Ruby #pop starts from end of list.
19
16
  parts.reverse!
17
+ action = parts.pop
18
+ parts.reverse!
20
19
 
21
- case parts.pop
20
+ case action
22
21
  when "dps:endpoint"
23
22
  Endpoint.new(parts)
24
23
  else
25
- InvalidRecord
24
+ InvalidRecord.new("Unexpected action '#{action}'")
26
25
  end
27
26
  end
28
27
 
@@ -30,9 +29,9 @@ module DPS
30
29
  records = get_records(domain).select { |r| r.is_a?(Endpoint) }
31
30
 
32
31
  if records.length > 1
33
- TooManyRecords
32
+ TooManyRecords.new
34
33
  elsif records.length == 0
35
- NoRecords
34
+ NoRecords.new
36
35
  else
37
36
  records[0]
38
37
  end
@@ -40,7 +39,7 @@ module DPS
40
39
 
41
40
  private
42
41
 
43
- def get_dns_txt_records(domain)
42
+ def get_txt_records(domain)
44
43
  result = []
45
44
 
46
45
  ::Dnsruby::DNS.open do |dns|
@@ -52,7 +51,9 @@ module DPS
52
51
  end
53
52
  end
54
53
 
55
- class InvalidRecord
54
+ class NoRecords < StandardError; end
55
+ class TooManyRecords < StandardError; end
56
+ class InvalidRecord < StandardError
56
57
  def self.valid?
57
58
  false
58
59
  end
data/lib/dps/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DPS
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Holroyd
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-24 00:00:00.000000000 Z
11
+ date: 2019-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dnsruby