Class: AppVersion
- Inherits:
-
Object
- Object
- AppVersion
- Defined in:
- lib/app-version-git.rb
Instance Method Summary collapse
- #changelog(count = 40) ⇒ Object
- #get_path(path) ⇒ Object
-
#initialize(path) ⇒ AppVersion
constructor
A new instance of AppVersion.
- #version ⇒ Object
Constructor Details
#initialize(path) ⇒ AppVersion
Returns a new instance of AppVersion.
7 8 9 |
# File 'lib/app-version-git.rb', line 7 def initialize path @git = Git.open(get_path path) end |
Instance Method Details
#changelog(count = 40) ⇒ Object
32 33 34 35 36 |
# File 'lib/app-version-git.rb', line 32 def changelog count = 40 @git.log(count).collect{|l| { :sha => l.sha, :date => l.date, :author => l.committer.name, :message => l. } } end |
#get_path(path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/app-version-git.rb', line 11 def get_path path path = File.(File.dirname(path)) path = path.split("/") while path.size > 0 if File.exists?(File.join(path, ".git")) return File.join(path) else path = path[0..-2] end end raise ArgumentError, "Git repository couldn't be found in your path" end |
#version ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/app-version-git.rb', line 24 def version log_count = @git.log(99999).size patch = log_count % 10 minor = log_count/10 % 10 major = log_count/100 % 10 "#{major}.#{minor}.#{patch}" end |