Skip to content

Commit

Permalink
add CheckCocoaPodsQualityIndexes.rb, fixes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
fulldecent committed Sep 17, 2016
1 parent 8f0fe23 commit 6c31409
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions Recipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,4 @@ Complete all these instructions on the same calendar day.
echo '3.0' > .swift-version
# Reference https://github.com/Alamofire/Alamofire/blob/master/.swift-version
# Reference https://github.com/CocoaPods/CocoaPods/pull/5841
curl 'https://raw.githubusercontent.com/fulldecent/swift3-module-template/master/__PROJECT_NAME__/Tests/CheckCocoaPodsQualityIndexes.rb' -o Tests/CheckCocoaPodsQualityIndexes.rb
2 changes: 2 additions & 0 deletions __PROJECT_NAME__/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ script:
- if [ $POD_LINT == "YES" ]; then
pod lib lint;
fi

- CheckCocoaPodsQualityIndexes.rb __PROJECT_NAME__
61 changes: 61 additions & 0 deletions __PROJECT_NAME__/Tests/CheckCocoaPodsQualityIndexes.rb
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

0 comments on commit 6c31409

Please sign in to comment.