-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add CheckCocoaPodsQualityIndexes.rb, fixes #7
- Loading branch information
1 parent
8f0fe23
commit 6c31409
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,5 @@ script: | |
- if [ $POD_LINT == "YES" ]; then | ||
pod lib lint; | ||
fi | ||
|
||
- CheckCocoaPodsQualityIndexes.rb __PROJECT_NAME__ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/ruby | ||
|
||
# | ||
# CheckCocoaPodsQualityIndexes.rb | ||
# by William Entriken, version 1.0.1 | ||
# Part of https://github.com/fulldecent/swift3-module-template | ||
# | ||
# The validates that all controllable quality metrics receive maximum score | ||
# from CocoaPods's scoring quality algorithm | ||
# | ||
# Usage: ruby CheckCocoaPodsQualityIndexes.rb PODNAME | ||
# | ||
|
||
require "json" | ||
require "uri" | ||
require "net/http" | ||
|
||
pod_name = ARGV.shift | ||
|
||
puts "Reviewing CocoaPods's quality metrics for #{pod_name}" | ||
puts "Metrics documentation: https://guides.cocoapods.org/making/quality-indexes.html" | ||
puts "Modifiers from: https://cocoadocs-api-cocoapods-org.herokuapp.com/pods/#{pod_name}/stats" | ||
puts "Raw data from: http://metrics.cocoapods.org/api/v1/pods/#{pod_name}" | ||
puts "NOTE: You must pust a new version to CocoaPods to get new metrics!" | ||
puts "" | ||
|
||
uri = URI.parse('https://cocoadocs-api-cocoapods-org.herokuapp.com/pods/FDTake/stats') | ||
http = Net::HTTP.new(uri.host, uri.port) | ||
http.use_ssl = true if uri.scheme == 'https' | ||
request = Net::HTTP::Get.new uri | ||
response = http.request(request) | ||
|
||
if !response.is_a? Net::HTTPOK | ||
puts "HTTP fetching error!" | ||
exit 1 | ||
end | ||
|
||
passing = true | ||
for metric in JSON.parse(response.body)['metrics'] | ||
if ['Verified Owner', 'Very Popular', 'Popular'].include? metric['title'] | ||
puts "SKIPPED\tYou cannot control: " + metric['title'] | ||
next | ||
end | ||
if metric['modifier'] >= 0 | ||
if metric['applies_for_pod'] | ||
puts "GOOD\tEarned points for: " + metric['title'] | ||
else | ||
puts "BAD\tMissed points for: " + metric['title'] | ||
passing = false | ||
end | ||
else | ||
if metric['applies_for_pod'] | ||
puts "BAD\tLost points for: " + metric['title'] | ||
passing = false | ||
else | ||
puts "GOOD\tAvoided penalty for: " + metric['title'] | ||
end | ||
end | ||
end | ||
|
||
exit passing ? 0 : 1 |