Create a gist now

Instantly share code, notes, and snippets.

@drbrain /sha_compare.rb Secret forked from raggi/sha_compare.rb
Last active Dec 12, 2015

What would you like to do?
# to check if you have checksums for unverified gems:
#
# ruby sha_compare.rb unverified.txt new_checksums.txt | wc -l
#
# This will count how many unverified checksums remain and show any mismatches
#
# To generate a new unverified list:
#
# ruby sha_compare.rb unverified.txt new_checksums.txt > new_unverified.txt
cf = open ARGV.shift
cf_list = cf.each_line.map { |l| l.split(/\s+/) }
cf_sums = Hash[cf_list.map! { |sum, n| [File.basename(n), sum] }]
db = open ARGV.shift
db_list = db.each_line.map { |l| l.split(/\s+/) }
db_sums = Hash[db_list.map! { |sum, n| [File.basename(n), sum] }]
cf_sums.each do |name, sum|
db_sum = db_sums[name]
next if db_sum == sum
$stderr.puts "Mismatch: #{name}" unless db_sum.nil?
puts "#{sum} ./#{name}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment