Last active
March 25, 2020 18:36
-
-
Save MikaelSmith/eaf633fbc377bb6d4d67f03e671e1cdc to your computer and use it in GitHub Desktop.
Collect candidates for Puppet-owned gems published to rubygems.org
This file contains hidden or 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 | |
require 'octokit' | |
token = ENV['GITHUB_TOKEN'] | |
if token.nil? || token.empty? | |
puts "GITHUB_TOKEN required for authentication" | |
exit 1 | |
end | |
client = Octokit::Client.new(access_token: token) | |
client.auto_paginate = true | |
objs = client.search_code('extension:gemspec org:puppetlabs', per_page: 100) | |
puts "Found #{objs.total_count} gemspecs" | |
objs.items.each do |obj| | |
puts obj.name + ',' + obj.repository.full_name | |
end |
This file contains hidden or 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 | |
require 'gems' | |
require 'yaml' | |
gems = [] | |
%w[puppet wash bolt].each do |term| | |
page = 1 | |
until (results = Gems.search(term, page: page)).empty? | |
gems += results | |
page += 1 | |
end | |
STDERR.puts "Queried #{page} pages for '#{term}'" | |
end | |
gems.uniq! | |
STDERR.puts "Found #{gems.size} gems" | |
uri_keys = %w[documentation_uri homepage_uri bug_tracker_uri source_code_uri wiki_uri] | |
ours = gems.select do |gem| | |
matches = uri_keys.select {|key| gem[key]&.match?('puppetlabs') } | |
!matches.empty? | |
end.map do |gem| | |
name = gem['name'] | |
uris = gem.values_at(*uri_keys).compact | |
STDERR.puts "Fetching owners of #{name}: #{uris}" | |
owners = Gems.owners(name) | |
{ | |
'name' => name, | |
'owners' => owners.map {|owner| owner['email']}, | |
'uris' => uris | |
} | |
end | |
puts ours.to_yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment