Created
April 10, 2012 16:53
-
-
Save fabiopelosin/2352834 to your computer and use it in GitHub Desktop.
Cocoapods RSS Generation
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
require 'rubygems' | |
require 'cocoapods' | |
require 'rss/maker' | |
class CocoapodsRSS | |
include Pod::Command::SetPresent | |
def run | |
sets = sets_by_time[0..29] | |
puts "\nProcessing #{sets.count} pods" | |
rss = rss_feed(sets) | |
File.open('cocoapodsTest.rss', 'w') {|f| f.write(rss) } | |
puts "\n--> Created cocoapodsTest.rss".green | |
puts | |
end | |
def sets_by_time | |
Pod::Source.all_sets.sort_by {|set| set.creation_date}.reverse | |
end | |
def rss_feed(sets) | |
rss = RSS::Maker.make('2.0') do |m| | |
m.channel.title = "CocoaPods - New Pods" | |
m.channel.link = "http://www.cocoapods.org" | |
m.channel.description = "CocoaPods new libraries" | |
m.items.do_sort = true | |
sets.each {|set| feed_item_from_set(m.items.new_item, set)} | |
end | |
end | |
def feed_item_from_set(item, set) | |
item.title = set.name | |
item.link = set.homepage | |
item.pubDate = set.creation_date | |
item.description = item_description(set) | |
end | |
def item_description(set) | |
<<-EOF.gsub(/ /,'') | |
<p>#{set.description}</p> | |
<ul> | |
<li>Version: #{set.versions.first}</li> | |
<li>Pod source: <a href="#{set.source_url}">#{set.source_url}</a></li> | |
#{"<li>GitHub stats: #{set.github_watchers} watchers and #{set.github_forks} forks.</li>" if set.github_watchers && set.github_forks} | |
<ul> | |
EOF | |
end | |
end | |
CocoapodsRSS.new.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment