uri-ni 0.1.2 → 0.1.5
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/exe/ni-uri +40 -0
- data/lib/uri/ni/version.rb +6 -2
- data/lib/uri/ni.rb +13 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee2d458c5f63ebc9a63552bc94b0141052952a2729b4647a0d5d5b43859288a4
|
4
|
+
data.tar.gz: 21201a539b63b90db525760e20087b37c77167fd054b75bc38d1625dfd0fedd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78679d956ad359ca94076ed41d148708c1fe4e8b79afe3cbaf144e3e874b20ae0d90d390414a58ab17b9152944b1ae3147e3e3478f9bc07e111a198ed7039ea5
|
7
|
+
data.tar.gz: 832ac38552ef80eccad02eb739da1471ad23c9c0aaa01b570ad2ffd829649ec93c02ee7b961d220e29ce06ad9858af322f829601e9a62da6a36d46bff8966eab
|
data/exe/ni-uri
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- mode: enh-ruby -*-
|
3
|
+
|
4
|
+
require 'uri/ni'
|
5
|
+
require 'pathname'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
op = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: ni-uri [options] FILES"
|
11
|
+
|
12
|
+
opts.on("-a", "--algorithm STRING", "algorithm") do |a|
|
13
|
+
options[:algorithm] = a.to_sym
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
op.parse!
|
18
|
+
|
19
|
+
options[:algorithm] ||= :"sha-256"
|
20
|
+
unless URI::NI.valid_algo? options[:algorithm]
|
21
|
+
$stderr.puts "#{options[:algorithm]} is not a valid algorithm"
|
22
|
+
exit 1
|
23
|
+
end
|
24
|
+
|
25
|
+
if ARGV.empty?
|
26
|
+
puts op.to_s
|
27
|
+
exit 1
|
28
|
+
end
|
29
|
+
|
30
|
+
ARGV.each do |fn|
|
31
|
+
fn = Pathname(fn).expand_path
|
32
|
+
begin
|
33
|
+
fh = fn.open
|
34
|
+
ni = URI::NI.compute fh, algorithm: options[:algorithm]
|
35
|
+
puts ni.to_s
|
36
|
+
rescue SystemCallError => e
|
37
|
+
$stderr.puts "Could not compute digest for #{fn}: #{e.message}"
|
38
|
+
next
|
39
|
+
end
|
40
|
+
end
|
data/lib/uri/ni/version.rb
CHANGED
@@ -3,9 +3,13 @@ require 'uri/generic'
|
|
3
3
|
|
4
4
|
module URI
|
5
5
|
class NI < Generic
|
6
|
-
VERSION = "0.1.
|
6
|
+
VERSION = "0.1.5"
|
7
7
|
end
|
8
8
|
|
9
9
|
# might as well put this here
|
10
|
-
|
10
|
+
if self.respond_to? :register_scheme
|
11
|
+
register_scheme 'NI', NI
|
12
|
+
else
|
13
|
+
@@schemes['NI'] = NI
|
14
|
+
end
|
11
15
|
end
|
data/lib/uri/ni.rb
CHANGED
@@ -186,7 +186,7 @@ class URI::NI < URI::Generic
|
|
186
186
|
# @raise [ArgumentError] if the algorithm is unrecognized
|
187
187
|
def self.context algorithm
|
188
188
|
raise ArgumentError, "Cannot coerce #{algorithm} to a symbol" unless
|
189
|
-
algorithm.respond_to
|
189
|
+
algorithm.respond_to? :to_s # cheat: symbols respond to to_s
|
190
190
|
algorithm = algorithm.to_s.to_sym unless algorithm.is_a? Symbol
|
191
191
|
raise ArgumentError, "Unsupported digest algorithm #{algorithm}" unless
|
192
192
|
ctx = DIGESTS[algorithm]
|
@@ -475,4 +475,16 @@ class URI::NI < URI::Generic
|
|
475
475
|
to_www https: false, authority: authority
|
476
476
|
end
|
477
477
|
|
478
|
+
# Returns the set of supported algorithms.
|
479
|
+
# @return [Array] the algorithms
|
480
|
+
def self.algorithms
|
481
|
+
DIGESTS.keys
|
482
|
+
end
|
483
|
+
|
484
|
+
# Returns true if the algorithm is supported.
|
485
|
+
# @param algorithm [Symbol,String] the algorithm identifier to test
|
486
|
+
# @return [true, false] whether it is supported
|
487
|
+
def self.valid_algo? algorithm
|
488
|
+
DIGESTS.has_key? algorithm.to_s.downcase.to_sym
|
489
|
+
end
|
478
490
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uri-ni
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Taylor
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -41,7 +41,8 @@ dependencies:
|
|
41
41
|
description: ''
|
42
42
|
email:
|
43
43
|
- code@doriantaylor.com
|
44
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- ni-uri
|
45
46
|
extensions: []
|
46
47
|
extra_rdoc_files: []
|
47
48
|
files:
|
@@ -54,6 +55,7 @@ files:
|
|
54
55
|
- Rakefile
|
55
56
|
- bin/console
|
56
57
|
- bin/setup
|
58
|
+
- exe/ni-uri
|
57
59
|
- lib/uri-ni.rb
|
58
60
|
- lib/uri/ni.rb
|
59
61
|
- lib/uri/ni/version.rb
|
@@ -63,7 +65,7 @@ licenses:
|
|
63
65
|
- Apache-2.0
|
64
66
|
metadata:
|
65
67
|
homepage_uri: https://github.com/doriantaylor/rb-uri-ni
|
66
|
-
post_install_message:
|
68
|
+
post_install_message:
|
67
69
|
rdoc_options: []
|
68
70
|
require_paths:
|
69
71
|
- lib
|
@@ -78,8 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
80
|
- !ruby/object:Gem::Version
|
79
81
|
version: '0'
|
80
82
|
requirements: []
|
81
|
-
rubygems_version: 3.
|
82
|
-
signing_key:
|
83
|
+
rubygems_version: 3.3.15
|
84
|
+
signing_key:
|
83
85
|
specification_version: 4
|
84
86
|
summary: URI handler for RFC6920 ni:/// URIs
|
85
87
|
test_files: []
|