Permalink
Browse files

Display app version on 'list' action. Code is a straight copy of Haml.

  • Loading branch information...
thomasn committed Sep 5, 2009
1 parent 70d284d commit 98519fe74199ed4a210e6f7c401bb217e02cc566
Showing with 65 additions and 2 deletions.
  1. +1 −1 MIT-LICENSE
  2. +1 −0 VERSION
  3. +4 −1 app/views/common/list.rhtml
  4. +10 −0 lib/forgetmenot.rb
  5. +49 −0 lib/forgetmenot/version.rb
View
@@ -1,6 +1,6 @@
== Forgetmenot ==
Copyright (c) 2007 Thomas Nichols and Greencuisine Ltd.
Copyright (c) 2007-2009 Thomas Nichols and Greencuisine Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
@@ -0,0 +1 @@
1.5.2
@@ -52,4 +52,7 @@
<%= will_paginate @objects %>
<br />
<div id="footer">
<a href="http://openforgetmenot.com/">Forgetmenot</a> <%= Forgetmenot::VERSION %> Copyright &copy; 2007-2009 Nexus 10 and Greencuisine Ltd.
</div>
View
@@ -0,0 +1,10 @@
require 'forgetmenot/version'
module Forgetmenot
extend Forgetmenot::Version
# A string representing the version of Forgetmenot.
# A more fine-grained representation is available from Forgetmenot.version.
VERSION = version[:string] unless defined?(Forgetmenot::VERSION)
end
View
@@ -0,0 +1,49 @@
# Thanks to: Forgetmenot -- versioning code copied wholesale.
module Forgetmenot
module Version
# Returns a hash representing the version of Forgetmenot.
# The :major, :minor, and :teeny keys have their respective numbers.
# The :string key contains a human-readable string representation of the version.
# If Forgetmenot is checked out from Git,
# the :rev key will have the revision hash.
def version
return @@version if defined?(@@version)
numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i }
@@version = {
:major => numbers[0],
:minor => numbers[1],
:teeny => numbers[2]
}
@@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
if File.exists?(scope('REVISION'))
rev = File.read(scope('REVISION')).strip
rev = nil if rev !~ /^([a-f0-9]+|\(.*\))$/
end
if (rev.nil? || rev == '(unknown)') && File.exists?(scope('.git/HEAD'))
rev = File.read(scope('.git/HEAD')).strip
if rev =~ /^ref: (.*)$/
rev = File.read(scope(".git/#{$1}")).strip
end
end
if rev
@@version[:rev] = rev
unless rev[0] == ?(
@@version[:string] << "."
@@version[:string] << rev[0...7]
end
end
@@version
end
# Returns the path of file relative to the Forgetmenot root.
def scope(file) # :nodoc:
File.expand_path File.join(File.dirname(__FILE__), '..', '..', file)
end
end
end

0 comments on commit 98519fe

Please sign in to comment.