Skip to content

Instantly share code, notes, and snippets.

@chriseidhof
Last active July 13, 2022 11:41
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriseidhof/725946f0d02b17ced209 to your computer and use it in GitHub Desktop.
Save chriseidhof/725946f0d02b17ced209 to your computer and use it in GitHub Desktop.
CocoaPods webserver
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
@liuzh
Copy link

liuzh commented May 28, 2014

nihao

@mr-v
Copy link

mr-v commented Dec 11, 2014

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

@DanielRakh
Copy link

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!

@rememberlenny
Copy link

You need to change Dir.glob('Specs/*/.podspec.json') do |spec_path|

@tommypeps
Copy link

It seems to have changed the api, anyone can give a new url?

@PurnachandraProgrammer
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment