Class: AppVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/app-version-git.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ AppVersion

Returns a new instance of AppVersion.



7
8
9
10
# File 'lib/app-version-git.rb', line 7

def initialize path
  path = File.expand_path(File.dirname(path))
  @git = Git.open(path)
end

Instance Method Details

#changelogObject



20
21
22
23
24
# File 'lib/app-version-git.rb', line 20

def changelog
  @git.log.collect{|l|
      { :date => l.date, :author => l.committer.name, :message => l.message  }
    }
end

#versionObject



12
13
14
15
16
17
18
# File 'lib/app-version-git.rb', line 12

def version
  log_count = @git.log.size
  patch = log_count % 10
  minor = log_count/10 % 10
  major = log_count/100 % 10
  "#{major}.#{minor}.#{patch}"
end