Last active
December 12, 2015 09:49
-
-
Save coffeeaddict/4754723 to your computer and use it in GitHub Desktop.
manifesto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A sample Gemfile | |
source "https://rubygems.org" | |
gem "nokogiri" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GEM | |
remote: https://rubygems.org/ | |
specs: | |
nokogiri (1.5.6) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
nokogiri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# create a manifest file | |
# | |
# usage manifest.rb /path/to/root/ name_of_xml.xml | |
require 'bundler/setup' | |
require 'find' | |
require 'nokogiri' | |
require 'digest/sha2' | |
root = ARGV.shift || raise("Need a root") | |
xml_file = ARGV.shift || raise("Need an xml file") | |
builder = Nokogiri::XML::Builder.new do |xml| | |
xml.files do | |
Find::find(root) do |inode| | |
next if FileTest.directory?(inode) | |
xml.file(size: FileTest.size(inode), sha256: Digest::SHA256.hexdigest(File.read(inode)), name: inode) | |
end | |
end | |
end | |
File.open(xml_file, File::CREAT|File::TRUNC|File::WRONLY) do |f| | |
f.puts builder.to_xml | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment