gitfeed 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Scott Wheeler
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,59 @@
1
+ = gitfeed
2
+
3
+ Produces an RSS v2 XML stream for a Git repository. Can be used inline in an
4
+ application or as a stand-alone server.
5
+
6
+ == Usage
7
+
8
+ Gitfeed can be used inline in an application to produce a string with the RSS
9
+ commits:
10
+
11
+ require 'rubygems'
12
+ require 'gitfeed'
13
+
14
+ gf = Gitfeed.new('/home/git/repository')
15
+ puts gf.feed
16
+
17
+ It can also be used as a standalone server inside of an application:
18
+
19
+ require 'rubygems'
20
+ require 'gitfeed'
21
+
22
+ Gitfeed::Server.start('/home/git/repository')
23
+
24
+ Or it can be used on the command line:
25
+
26
+ gitfeed /home/git/repository
27
+
28
+ == Customizing the output
29
+
30
+ You can specify a Haml file to be used for each entry, the default is:
31
+ /
32
+ %p
33
+ %strong Author:
34
+ = entry.author.name
35
+ <
36
+ %a{ :href => "mailto:#{entry.author.email}" }
37
+ = entry.author.email
38
+ >
39
+ %p
40
+ %strong Date:
41
+ = entry.author.date
42
+ %p
43
+ %strong Message:
44
+ = entry.message
45
+ %p
46
+ %strong SHA:
47
+ = entry.objectish
48
+ - if @include_diffs && !entry.parents.empty?
49
+ %pre
50
+ = @git.diff(entry.parents.first.objectish, entry.objectish)
51
+
52
+ This can be passed as a configuration option either to the construtor, server
53
+ or command line:
54
+
55
+ gitfeed --template=template.haml /home/git/repository
56
+
57
+ == Copyright
58
+
59
+ Copyright (c) 2010 Scott Wheeler. See LICENSE for details.
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "gitfeed"
8
+ gem.summary = %Q{Git to RSS converter and optional stand-alone server}
9
+ gem.description = %Q{Ruby gem to create RSS feeds from commits in a Git stream and an optional Sinatra based server}
10
+ gem.email = "wheeler@kde.org"
11
+ gem.homepage = "http://github.com/scotchi/gitfeed"
12
+ gem.authors = ["Scott Wheeler"]
13
+ gem.add_dependency "sinatra"
14
+ gem.add_dependency "haml"
15
+ gem.add_dependency "git"
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/test_*.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ end
36
+ rescue LoadError
37
+ task :rcov do
38
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
+ end
40
+ end
41
+
42
+ task :test => :check_dependencies
43
+
44
+ task :default => :test
45
+
46
+ require 'rake/rdoctask'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "gitfeed #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'gitfeed'
5
+
6
+ unless ARGV.size >= 1
7
+ warn <<END
8
+ Usage: gitfeed [options] /path/to/git/repository
9
+
10
+ Options:
11
+ --title="RSS Feed Title"
12
+ --url=http://base.url.com/
13
+ --description="RSS Feed Descrption"
14
+ --template=/path/to/haml/template/for/entries
15
+ --include-diffs=false
16
+ END
17
+ exit! 1
18
+ end
19
+
20
+ options = {}
21
+
22
+ until ARGV.size <= 1 do
23
+ kv = ARGV.shift.split('=')
24
+ key = kv.first.sub(/^--/, '').gsub('-', '_').to_sym
25
+ value = kv.last
26
+ value = false if value == 'false'
27
+ value = true if value == 'true'
28
+ options[key] = value
29
+ end
30
+
31
+ repository = ARGV.shift
32
+
33
+ Gitfeed::Server.start(repository, options)
34
+
@@ -0,0 +1,19 @@
1
+ %p
2
+ %strong Author:
3
+ = entry.author.name
4
+ &lt;
5
+ %a{ :href => "mailto:#{entry.author.email}" }
6
+ = entry.author.email
7
+ &gt;
8
+ %p
9
+ %strong Date:
10
+ = entry.author.date
11
+ %p
12
+ %strong Message:
13
+ = entry.message
14
+ %p
15
+ %strong SHA:
16
+ = entry.objectish
17
+ - if @include_diffs && !entry.parents.empty?
18
+ %pre
19
+ = @git.diff(entry.parents.first.objectish, entry.objectish)
@@ -0,0 +1,80 @@
1
+ require 'rubygems'
2
+ require 'git'
3
+ require 'haml'
4
+ require 'rss/maker'
5
+ require 'sinatra'
6
+
7
+ # A Git to RSS converter
8
+
9
+ class Gitfeed
10
+
11
+ RSS_VERSION = '2.0'
12
+
13
+ # Creates a Gitfeed instance for a specific Git repository where each change
14
+ # is an RSS entry.
15
+ #
16
+ # @param [String] repository_path Path to a Git repository
17
+ # @param [Hash] options Options for the created RSS feed
18
+ #
19
+ # @option options [String] :title ("Gitfeed for Repository")
20
+ # Title for the RSS feed
21
+ # @option options [String] :url ("http://github.com/scotchi.net/gitfeed")
22
+ # Base URL for the RSS feed and all links
23
+ # @option options [String] :description (repository_path)
24
+ # Description of the RSS feed
25
+ # @option options [String] :template ("entry.haml")
26
+ # Path to a Haml template for the individual entries
27
+ # @option options [Boolean] :include_diffs (true)
28
+ # Include diffs in the RSS output
29
+
30
+ def initialize(repository_path, options = {})
31
+ @git = Git.open(repository_path)
32
+ @title = options[:title] || "Gitfeed for #{repository_path.sub(/.*\//, '')}"
33
+ @url = options[:url] || 'http://github.com/scotchi/gitfeed'
34
+ @description = options[:description] || repository_path
35
+ @template = options[:template] || File.expand_path('../entry.haml', __FILE__)
36
+ @include_diffs = options[:include_diffs].nil? ? true : options[:include_diffs]
37
+ @haml = Haml::Engine.new(File.read(@template))
38
+ end
39
+
40
+ # @return [String] An RSS v2 XML stream of the most recent git commits
41
+
42
+ def feed
43
+ RSS::Maker.make(RSS_VERSION) do |maker|
44
+ maker.channel.title = @title
45
+ maker.channel.link = @url
46
+ maker.channel.description = @description
47
+ maker.items.do_sort = true
48
+ @git.log(20).each do |entry|
49
+ item = maker.items.new_item
50
+ item.title = entry.message.sub(/\n.*/m, '')
51
+ item.link = @url
52
+ item.date = entry.date
53
+ item.description = description(entry)
54
+ end
55
+ end.to_s
56
+ end
57
+
58
+ # A Sinatra-based stand-alone server that serves up an RSS feed of the
59
+ # changes in the specified repository.
60
+
61
+ class Server < Sinatra::Base
62
+
63
+ # Starts a standalone server. The arguments are identical to Gitfeed.new
64
+
65
+ def self.start(*args)
66
+ @@gitfeed = Gitfeed.new(*args)
67
+ get '/' do
68
+ content_type('text/xml')
69
+ @@gitfeed.feed
70
+ end
71
+ self.run!
72
+ end
73
+ end
74
+
75
+ private
76
+
77
+ def description(entry)
78
+ @haml.render(self, :entry => entry)
79
+ end
80
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'gitfeed'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestGitfeed < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitfeed
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Scott Wheeler
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-05-21 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: sinatra
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: haml
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: git
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ description: Ruby gem to create RSS feeds from commits in a Git stream and an optional Sinatra based server
64
+ email: wheeler@kde.org
65
+ executables:
66
+ - gitfeed
67
+ - gitfeed~
68
+ extensions: []
69
+
70
+ extra_rdoc_files:
71
+ - LICENSE
72
+ - README.rdoc
73
+ files:
74
+ - .document
75
+ - .gitignore
76
+ - LICENSE
77
+ - README.rdoc
78
+ - Rakefile
79
+ - VERSION
80
+ - bin/gitfeed
81
+ - lib/entry.haml
82
+ - lib/gitfeed.rb
83
+ - test/helper.rb
84
+ - test/test_gitfeed.rb
85
+ - bin/gitfeed~
86
+ has_rdoc: true
87
+ homepage: http://github.com/scotchi/gitfeed
88
+ licenses: []
89
+
90
+ post_install_message:
91
+ rdoc_options:
92
+ - --charset=UTF-8
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ requirements: []
114
+
115
+ rubyforge_project:
116
+ rubygems_version: 1.3.7
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Git to RSS converter and optional stand-alone server
120
+ test_files:
121
+ - test/helper.rb
122
+ - test/test_gitfeed.rb