pboling/version_gem

View on GitHub
bin/checksum

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'digest/sha2'
gems = Dir['*.gem']
puts "Found: #{gems.inspect}"
raise 'No Gems' if gems.length.zero?
raise 'Too Many Gems' if gems.length > 1

built_gem_path = gems.first
checksum512 = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
checksum512_path = "checksums/#{built_gem_path}.sha512"
File.write(checksum512_path, checksum512)

checksum256 = Digest::SHA256.new.hexdigest(File.read(built_gem_path))
checksum256_path = "checksums/#{built_gem_path}.sha256"
File.write(checksum256_path, checksum256)

puts "You must now git add and commit '#{checksum256_path}' and '#{checksum512_path}'"