Skip to content

Instantly share code, notes, and snippets.

@rkallensee
Last active May 10, 2019 07:59
Show Gist options
  • Save rkallensee/102a08fbae1a38efe10fa0246c92807a to your computer and use it in GitHub Desktop.
Save rkallensee/102a08fbae1a38efe10fa0246c92807a to your computer and use it in GitHub Desktop.
Write all Ruby gem dependencies with their licenses into a CSV file
require 'csv'
csv_path = Rails.root.join("#{Rails.application.class.parent.name.underscore.dasherize}_licenses.csv")
CSV.open(csv_path, 'wb') do |csv|
csv << ['Gem', 'Licenses']
Gem.loaded_specs.each do |gem_name, spec|
csv << [gem_name, spec.licenses.join(', ')]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment