uri-ni 0.2.1 → 0.2.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/uri/ni/version.rb +1 -1
  3. data/lib/uri/ni.rb +11 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7f97e35f7fc6987d8051e1f09e23cc2cbc29b6e188496b5d1abd5d030a7ec32
4
- data.tar.gz: 3a66e3863206978a52e1281318808f043de2b7e4409b09d8bdff37a589bfb3fd
3
+ metadata.gz: 0210a945c627b9ec4a14f96b5beac95ca2084e5a873643ed963d37f939f81796
4
+ data.tar.gz: d3c7a53b7c0dfb92e64e2989114863838dbf2b895a9fb0a4375f86213fd61d7d
5
5
  SHA512:
6
- metadata.gz: eac81311c6e7e895c908b0d45db5a7b028ed1e9b2e1b65e35d264c5840837abc589a9c11ac315272bf751f1f326b753f1b5e2f1add14313ae66258eefeee7c88
7
- data.tar.gz: 8456780c695e1ad060546e46bf8cc1fcccbee00c1d535e6a3845f19f2928fd1a13efb720e264f23091fcf24b82bae797365877ca3747d6701502f96df61c65ca
6
+ metadata.gz: e02348cfcdb25c10a8ff83c462bfff0c3720b1488bedc33a3e8735eb1a98f3887afd50ca5d6f6674f30fd2ae92e3f5bf49822dbcc2ee6c1ee51385e55612ea36
7
+ data.tar.gz: 4f6a9d14efab6c9b6fa46c9df390d5222ef8a8a6afe4d06aeba6709284d59f20d35aa12d5da4f8f3dc52cb2a159dd17f97872165278324b0407b20f8e4280bd7
@@ -3,7 +3,7 @@ require 'uri/generic'
3
3
 
4
4
  module URI
5
5
  class NI < Generic
6
- VERSION = "0.2.1"
6
+ VERSION = "0.2.2"
7
7
  end
8
8
 
9
9
  # might as well put this here
data/lib/uri/ni.rb CHANGED
@@ -58,7 +58,9 @@ class URI::NI < URI::Generic
58
58
  end
59
59
 
60
60
  [k, v]
61
- end.to_h
61
+ end.to_h.freeze
62
+
63
+ TRUNCATED = [32, 64, 96, 120, 128].map { |i| "sha-256-#{i}".to_sym }.freeze
62
64
 
63
65
  # resolve first against digest length and then class
64
66
  DIGEST_REV = {
@@ -324,6 +326,14 @@ class URI::NI < URI::Generic
324
326
  LENGTHS[algorithm] and LENGTHS[algorithm] == digest.length
325
327
  end
326
328
 
329
+ # Returns true if the algorithm is a truncated one.
330
+ #
331
+ # @return [false, true]
332
+ #
333
+ def truncated?
334
+ TRUNCATED.include? algorithm
335
+ end
336
+
327
337
  # Display the available algorithms.
328
338
  #
329
339
  # @return [Array] containing the symbols representing the available
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri-ni
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Taylor