Skip to content

Instantly share code, notes, and snippets.

@maxigs
Created October 1, 2012 09:42
Show Gist options
  • Save maxigs/3810584 to your computer and use it in GitHub Desktop.
Save maxigs/3810584 to your computer and use it in GitHub Desktop.
Script to copy the gem licenses into doc folder
#!/usr/bin/env ruby
#
# Put this file in script/licenses.rb
# and make executeable
# $ chmod +x script/licenses.rb
#
# Call with
# $ script/licenses.rb
ROOT_PATH = File.expand_path('../../', __FILE__)
require 'fileutils'
licenses_output_dir = File.join(ROOT_PATH, 'doc', 'gem_licenses')
gems = {}
gem_paths = `bundle list --paths`.split("\n")
gem_paths.each do |gem_path|
gem_name = gem_path.split('/').last
gems[gem_name] = `ls #{gem_path}/*LICENSE*`.split("\n").first rescue nil
end
FileUtils.mkdir_p(licenses_output_dir)
gems.each do |name, path|
out = File.join(licenses_output_dir, name)
if path
FileUtils.cp(path, out)
else
FileUtils.touch(out)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment