Last active
December 12, 2015 01:58
-
-
Save sj26/4695129 to your computer and use it in GitHub Desktop.
YAML symbol grep
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
find . -iname "*.gem" | while read file; do | |
file=$(basename $file) | |
mkdir -p ../metadata/${file:0:1}/${file:1:1} | |
tar -xOf ./$file metadata.gz | gunzip -c > ../metadata/${file:0:1}/${file:1:1}/$file:r.metadata || | |
tar -xOf ./$file metadata > ../metadata/${file:0:1}/${file:1:1}/$file:r.metadata && | |
echo ${file:0:1}/${file:1:1}/$file:r.metadata | |
done |
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
require 'psych' | |
# Already extracted metadata from all gems into g/e/gem-1.0.0.metadata style paths. | |
Dir.glob("?/?/*.metadata") do |file| | |
begin | |
Psych.parse_file(file).each do |node| | |
if node.tag =~ %r{\A!ruby/sym(bol)?(\:.*)?\Z} or (node.is_a? Psych::Nodes::Scalar and node.tag.nil? and not node.quoted and node.value and node.value[/\A:/]) | |
puts "#{file}: #{node.value}" | |
end | |
end | |
rescue Psych::SyntaxError | |
$stderr.write "#{file}: Syntax Error: #{$!}\n" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment