https://github.com/ku1ik/rack-revision-info
Rack middleware showing current git (or svn) revision number of deployed application
https://github.com/ku1ik/rack-revision-info
Last synced: about 2 months ago
JSON representation
Rack middleware showing current git (or svn) revision number of deployed application
- Host: GitHub
- URL: https://github.com/ku1ik/rack-revision-info
- Owner: ku1ik
- Created: 2009-05-27T19:29:26.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2013-04-16T22:01:06.000Z (about 12 years ago)
- Last Synced: 2025-04-09T21:53:17.785Z (about 2 months ago)
- Language: Ruby
- Homepage: http://ku1ik.com/
- Size: 191 KB
- Stars: 20
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
Awesome Lists containing this project
README
h1. Rack::RevisionInfo
h2. About
When you deploy application to a demo server QA (or client) wants to know which revision is currently running. Of course you can handle it in a old-school way putting some helper into your layout(s) which will obtain revision number exec'ing "svnversion" or sth like this. It works but it's not the most elegant solution. First, you are including code related only to demo/staging server in layouts/helpers (production server and your development box don't need it at all). Second, you probably do this for every new project. But all ruby web frameworks now run on Rack so better solution would be to move revision-displaying code from the app itself to the middleware. So here comes RevisionInfo.
h2. Installation
Add it to Gemfile:
gem "rack-revision-info"
Enable in Rails:
config/environment.rb:
config.middleware.use Rack::RevisionInfo, :path => Rails.root (RAILS_ROOT in Rails 2.x)
Enable in Merb:
config/rack.rb (before line with
run Merb::Rack::Application.new
):use Rack::RevisionInfo, :path => Merb.root
h2. Usage
Enabling this middleware for svn managed application you will get
appended to the end of resulting html. For git repository it will be
. It's commented out so in order to see it look into page source.
However if you prefer to see revision number somewhere on the page you can specify CSS selector of page element and method of injection like this:
use Rack::RevisionInfo, :path => Merb.root, :inner_html => ".footer li.revision"
Here are available injection methods:
*
:append => "div.footer"
inserts revision info at the end of footer div content
*:prepend => "div.footer"
inserts revision info at the begining of footer div
*:after => "div.footer"
inserts revision info after footer divRevision 666 (2009-05-28 19:00:25 +00:00)
*:before => "div.footer"
inserts revision info before footer divRevision 666 (2009-05-28 19:00:25 +00:00)
*:inner_html => "div.footer"
replaces footer div content with revision info
*:swap => "div.footer"
replaces whole footer div with revision infoRevision 666 (2009-05-28 19:00:25 +00:00)
*:header => "X-My-Header"
puts revision into HTTP header of your choosing. Or use:header => true
to use the default of X-Revision-Info. Good for XML/JSON API requests.Specified CSS selector can be any selector supported by Nokogiri so you can freely use funky stuff like
#main ul.footer li:last
. You can also use XPath like//div/ul/li
.h2. Contact & Information
Marcin Kulik - http://ku1ik.com/