Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display app version on 'list' action. Code is a straight copy of Haml.
- Loading branch information
Showing
5 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.5.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |