Sha256: e758d37779fd32db3ccaee2b95ea818e8ea677e2967054bdf7370f15981aaf9a
Contents?: true
Size: 785 Bytes
Versions: 2
Compression:
Stored size: 785 Bytes
Contents
#!/usr/bin/env ruby # -*- mode: enh-ruby -*- require 'uri/ni' require 'pathname' require 'optparse' options = {} op = OptionParser.new do |opts| opts.banner = "Usage: ni-uri [options] FILES" opts.on("-a", "--algorithm STRING", "algorithm") do |a| options[:algorithm] = a.to_sym end end op.parse! options[:algorithm] ||= :"sha-256" unless URI::NI.valid_algo? options[:algorithm] $stderr.puts "#{options[:algorithm]} is not a valid algorithm" exit 1 end if ARGV.empty? puts op.to_s exit 1 end ARGV.each do |fn| fn = Pathname(fn).expand_path begin fh = fn.open ni = URI::NI.compute fh, algorithm: options[:algorithm] puts ni.to_s rescue SystemCallError => e $stderr.puts "Could not compute digest for #{fn}: #{e.message}" next end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
uri-ni-0.1.5 | exe/ni-uri |
uri-ni-0.1.4 | exe/ni-uri |