CocoaPods/Core — pull request #43 by irrationalfab (2013-12-02 15:09:36+00:00)
Title: Irrationalfab/github source

This patch adds support for accessing a specs repo via the GitHub API (as an alternate strategy to the file system).

It requires the repo to have the same file structure present in the `yaml_podspecs` branch of the CocoaPods/Specs repo (i.e. specifications stored in the `Specs` folder and only the YAML format is supported).

--

This patch is desirable for the CocoaPods gem as it would allow to drop the required setup phase after the installation and is a more efficient distribution mechanism for the specifications (although git does a great job the history is not needed for the clients).

Some additional notes:

- Is not possible to perform full text search with this strategy, so an API in cocoapods.org would be needed for that.
- It doesn't require us to keep a server running :-)

--

This patch is also desirable for web services which require access to the master repo as currently the requirement of using git to clone the repo makes them very inconvenient. This patch instead makes accessing the master repo very simple:

```ruby
# test.rb
require "cocoapods-core"

provider = Pod::Source::GitHubDataProvider.new('CocoaPods/Specs', 'yaml_podspecs')
source = Pod::Source.new(provider)

puts "Getting the list of the Pods..."
time = Time.new
pods = source.pods
puts "* Time: #{Time.new - time}"
puts "There are #{pods.count} Pods"

puts

puts "Fetching a Spec..."
pod = "AHAlertView"
versions = source.versions(pod)
version = versions.last
time = Time.new
spec = source.specification(pod, version)
puts "* Time: #{Time.new - time}"
puts "Name: #{spec.name}"
puts "Version: #{spec.version}"
puts "Author: #{spec.authors.keys.first}"
```

```ruby
# Gemfile
gem 'cocoapods-core', :git => "https://github.com/CocoaPods/Core.git", :branch => 'irrationalfab/github-source'
```

```console
$ bundle exec ruby test.rb
Getting the list of the Pods...
* Time: 1.656216
There are 1554 Pods

Fetching a Spec...
* Time: 0.749892
Name: AHAlertView
Version: 0.0.2
Author: Warren Moore
```

Note that a service like the feeds app still requires to be notified by the trunks app with the name of the new (or updated) Pods whose details can then be fetched via the `Pod::Source` class. This setup would make that application trivial.

/c @alloy, @orta, @floere