Skip to content

Commit d1db2d8

Browse files
committed
Add swift package tracker ruby tool
1 parent 2e59e64 commit d1db2d8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

swift-package-tracker.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'octokit'
2+
3+
# Gets all swift packages and lists them in a nice markdown file.
4+
# Find docs
5+
# - https://developer.github.com/v3/guides/traversing-with-pagination/#consuming-the-information
6+
# - https://help.github.com/en/github/searching-for-information-on-github/searching-code#search-by-filename
7+
# - https://octokit.github.io/rest.js/v17#search-repos
8+
9+
client = Octokit::Client.new :access_token => ENV['GITHUB_TOKEN']
10+
11+
results = client.search_code('filename:Package.swift', :per_page => 100)
12+
total_count = results.total_count
13+
14+
last_response = client.last_response
15+
number_of_pages = last_response.rels[:last].href.match(/page=(\d+).*$/)[1]
16+
17+
puts last_response.rels[:last].href
18+
puts "There are #{total_count} results, on #{number_of_pages} pages!"
19+
20+
21+
# while [ 1 ]
22+
# do
23+
# header=$(curl -s -I "$url" -H "Authorization: token $GITHUB_TOKEN")
24+
# last_page=$(echo $header | grep '^Link:' | sed -e 's/^Link:.*<//g' -e 's/>.*$//g')
25+
# echo $last_page
26+
# echo $header
27+
# # curl -I "https://api.github.com/search/code?q=filename:Package.swift&per_page=60000" -H "Authorization: token $GITHUB_TOKEN" | jq '.items[].repository.name'
28+
# # curl -s "https://api.github.com/search/code?q=filename:Package.swift" -H "Authorization: token $GITHUB_TOKEN" | jq '.items[].repository | {description,full_name,name,html_url}'
29+
# break
30+
# done

0 commit comments

Comments
 (0)