Class: Gitfeed
- Inherits:
-
Object
- Object
- Gitfeed
- Defined in:
- lib/gitfeed.rb
Overview
A Git to RSS converter
Defined Under Namespace
Classes: Server
Constant Summary collapse
- RSS_VERSION =
'2.0'
Instance Method Summary collapse
-
#feed ⇒ String
An RSS v2 XML stream of the most recent git commits.
-
#initialize(repository_path, options = {}) ⇒ Gitfeed
constructor
Creates a Gitfeed instance for a specific Git repository where each change is an RSS entry.
Constructor Details
#initialize(repository_path, options = {}) ⇒ Gitfeed
Creates a Gitfeed instance for a specific Git repository where each change is an RSS entry.
30 31 32 33 34 35 36 37 38 |
# File 'lib/gitfeed.rb', line 30 def initialize(repository_path, = {}) @git = Git.open(repository_path) @title = [:title] || "Gitfeed for #{repository_path.sub(/.*\//, '')}" @url = [:url] || 'http://github.com/scotchi/gitfeed' @description = [:description] || repository_path @template = [:template] || File.('../entry.haml', __FILE__) @include_diffs = [:include_diffs].nil? ? true : [:include_diffs] @haml = Haml::Engine.new(File.read(@template)) end |
Instance Method Details
#feed ⇒ String
Returns An RSS v2 XML stream of the most recent git commits.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/gitfeed.rb', line 42 def feed RSS::Maker.make(RSS_VERSION) do |maker| maker.channel.title = @title maker.channel.link = @url maker.channel.description = @description maker.items.do_sort = true @git.log(20).each do |entry| item = maker.items.new_item item.title = entry..sub(/\n.*/m, '') item.link = @url item.date = entry.date item.description = description(entry) end end.to_s end |