-
-
Save chriseidhof/725946f0d02b17ced209 to your computer and use it in GitHub Desktop.
require 'sinatra' | |
require 'pathname' | |
require 'cocoapods' | |
require 'cocoapods-core' | |
require 'colored' | |
require 'active_support/all' | |
# This expects the CocoaPods Specs repository to be in the same directory as the app. | |
PAGE_SIZE = 20 | |
SPECS = [] | |
Dir.glob('Specs/**/*.podspec') do |spec_path| | |
spec = Pod::Spec.from_file(spec_path) | |
SPECS << spec if spec.safe_to_hash? | |
end | |
NUMBER_OF_PAGES = (SPECS.count.to_f / PAGE_SIZE).ceil | |
get '/specs' do | |
page = [params[:page].to_i, 0].max | |
start_range = page * PAGE_SIZE | |
end_range = start_range + PAGE_SIZE | |
{ :result => SPECS[start_range..end_range], | |
:number_of_pages => NUMBER_OF_PAGES | |
}.to_json | |
end |
If anybody reads it now :)
CocoaPods specs filename formatting changed to: 'Specs/*/.podspec.json'
Also I've recreated demo in Swift for exercise, made some changes and added a few tests. Maybe someone will find it useful:
https://github.com/mr-v/swift-objc.io-issue-10-core-data-network-application
mr-v thanks for putting in the work to do that. I was actually going to do it myself but you beat me to it!
You need to change Dir.glob('Specs/*/.podspec.json') do |spec_path|
It seems to have changed the api, anyone can give a new url?
If anybody reads it now :)
CocoaPods specs filename formatting changed to: 'Specs/*/.podspec.json'
Also I've recreated demo in Swift for exercise, made some changes and added a few tests. Maybe someone will find it useful: https://github.com/mr-v/swift-objc.io-issue-10-core-data-network-application
Could you please update the code to the Swift 5 version? Thanks
nihao