Skip to content

Instantly share code, notes, and snippets.

@strzibny
Last active August 29, 2015 14:04
Show Gist options
  • Save strzibny/6505c3408e995f1e380f to your computer and use it in GitHub Desktop.
Save strzibny/6505c3408e995f1e380f to your computer and use it in GitHub Desktop.
Check what kind of spec data are saved in Marshal.4.8.Z
#!/usr/bin/ruby
# Check what kind of spec data are saved in http://rubygems.org/Marshal.4.8.Z
require 'rubygems'
require 'pp'
# wget http://rubygems.org/Marshal.4.8.Z if needed
gems = Marshal.load(Gem.inflate(File.read("./Marshal.4.8.Z")))
SPEC_PARAMS = %w[ author authors name platform require_paths rubygems_version summary
license licenses bindir cert_chain description email executables
extensions homepage metadata post_install_message rdoc_options
required_ruby_version required_rubygems_version requirements
signing_key has_rdoc date version ].sort
SPEC_FILES_PARAMS = %w[ files test_files extra_rdoc_files ]
DEPENDENCY_PARAMS = %w[ dependencies ]
PARAMS = SPEC_PARAMS + SPEC_FILES_PARAMS + DEPENDENCY_PARAMS
included = []
PARAMS.each do |param|
gems.each do |gem|
name = gem[0]
spec = gem[1]
if spec.respond_to? :"#{param}"
value = spec.send(:"#{param}")
if value
if value.respond_to? :'empty?'
next if value.empty?
end
included << param
break
end
end
end
end
puts 'Included:'
pp included
puts 'Not included:'
pp (PARAMS - included)
#=======================================================
# Results
#=======================================================
Included:
["author",
"authors",
"bindir",
"date",
"description",
"has_rdoc",
"name",
"platform",
"require_paths",
"required_ruby_version",
"required_rubygems_version",
"rubygems_version",
"summary",
"version",
"dependencies"]
Not included:
["cert_chain",
"email",
"executables",
"extensions",
"homepage",
"license",
"licenses",
"metadata",
"post_install_message",
"rdoc_options",
"requirements",
"signing_key",
"files",
"test_files",
"extra_rdoc_files"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment