Crank

RSS and HTML output from SVN repository logs with Ruby

Crank is a command-line tool to easily generate log output from SVN repositories based on ERB templates. It's best to use Crank in SVN hook scripts to generate the output everytime you've done a commit.

You should be familiar command-line and SVN hook scripts in order to run this in hook scripts.

No ERB templates are included with the gem, download them from below. In the below examples
the "--template" parameter is pointing to a folder I created and placed the templates inside of.

If you're on linux, please read the RSCM on Linux Fix section at the bottom of this page


Installation


Download the Gem
sudo gem install crank --include-dependencies --source=http://www.svn2rss.com/crank-1.2.gem

crank is waiting for a spot on RubyForge. If the "gem install" doesn't work it will once it's on rubyforge. Hang tight.


Usage Examples

#html output
crank --scm=svn --url=svn://some_repo_url --out=/var/www/myhtmloutput.html \
--template=/crank_templates/myhtmltemplate.html

#rss output
crank --scm=svn --url=some_repository_url --out=/var/www/my_svn_feed.rss \
--template=/crank_templates/rsstemplate.xml

#with authentication
crank --scm=svn --url=some_repository_url --out=/var/www/my_svn_feed.rss \
--username=warhero --pasword=hasselhoff --template=rsstemplate.xml
SVN "post-commit" hook example
#myrepo/hooks/post-commit

REPO = "$1"
REVISION = "$2"
export PATH = usr/bin:/usr/local/bin:/usr/local:/usr/local/bin:/usr/sbin

#generate RSS output
crank --scm=svn --repo=file:///repos/myrepository --template=/crank_templates/rss_template.xml \
--out=/var/www/vhosts/mysubdomain/crankrss.xml >> /tmp/myrepository

#generate HTML output
crank --scm=svn --repo=file:///repos/myrepository --template=/crank_templates/rss_template.xml \
--out=/var/www/vhosts/mysubdomain/crankhtml.html >> /tmp/myrepository

#

Example Outputs


HTML output
RSS output


Example ERB Templates


HTML output template
RSS output template (right click -> save as)


Commandline Arguments

-s, --scm=svn                    Which SCM to use (svn,cvs,perforce,starteam).
-l, --url=url                    The repository URL. (svn://, http://, file:///)
-x, --path=/trunk/core           A path internal to the respository.
-u, --username=developer         The username for the repository.
-p, --password=2398dslk          The user password for the repository.
-r, --revision=0                 The repository revision (number,HEAD,PREV,BASE).
-t, --template=mytemplate.*      An ERB template file.
-o, --out=myfile.*            	 The file to write the output to.
-h, --help                       Show this usage statement.

Variables at ERB time

-> see http://rscm.rubyforge.org/
-> see the above ERB template examples for usage example

"repo" #this is an instance of RSCM::{SCM_TYPE}

"revisions" #this is an instance of RSCM::Revisions

"options" #this is the options that were used in the "crank" command. (options[:key])

    Available Keys in options:
    options[:scm] #the scm type
    options[:repo] #the address (http://, svn://, etc)
    options[:path] #the internal svn path used
    options[:username]
    options[:password]
    options[:revision] #repo revision to start output from
    options[:template_file] #the ERB template file to render
    options[:output_file] #the file that the ERB result gets written to

RSCM on Linux Fix

RSCM is a ruby source control management gem. If you're running crank or RSCM on linux, you need to update the RSCM gem source in order to run correctly. Here's how:

1. Open [path-to-ruby-gems]/1.8/gems/rscm-0.5.1/lib/rscm/platform.rb
2. in the method definition for "family" Change it to this:

def family 
  #snip
  return "linux" if true #this is a temporary hack until I can get the RSCM devs to update this
  raise "Unsupported OS: #{target_os}"
end


If you didn't find the programming knowledge you were looking for, compare cash advance loans online so that you can finance your erb template knowledge.