This repository has been archived by the owner on Oct 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cocoapods_rank.rb
65 lines (52 loc) · 1.47 KB
/
cocoapods_rank.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'cocoapods'
require 'octokit'
require 'pry'
class Pod::Specification
class << self
def github_client
@client ||= Octokit::Client.new(oauth_token: ENV['GITHUB_TOKEN'])
end
end
def git_repo
source[:git]
end
def github?
git_repo && git_repo.start_with?('https://github.com')
end
def github_repo_name
match_data = git_repo.match("https://github.com/(.+?)/(.+?).git")
"#{match_data[1]}/#{match_data[2]}"
end
def github_repo
@repo ||= self.class.github_client.repo(github_repo_name)
end
end
specs = Pod::SourcesManager.all_sets.map(&:specification)
# specs = specs.first(5) # For testing
github_specs = specs.select do |spec|
puts "Checking #{spec.name}"
# sleep 1 # Be nice to GitHub
begin
spec.github? && !!spec.github_repo
rescue Octokit::NotFound
false
end
end
github_specs = github_specs.sort_by { |spec| - spec.github_repo.stargazers_count }
File.open("cocoapods_rank.md", "w+") do |f|
f.puts "# CocoaPods Rank"
f.puts "\n"
f.puts "Sorted by stargazers count of GitHub repo (as of #{Time.now})"
f.puts "\n"
f.puts "[Source code](https://github.com/luvtechno/cocoapods_rank)"
f.puts "\n"
github_specs.each do |spec|
puts "#{spec.name}: #{spec.github_repo.stargazers_count}"
f.puts "* #{spec.github_repo.stargazers_count} [#{spec.name}](#{spec.homepage})"
end
f.puts "\n"
f.puts "Generated by [@luvtechno](https://github.com/luvtechno/)"
end
# stargazers_count
# forks_count
# binding.pry