Class: GitDiffLCS::Shortstat
- Inherits:
-
Object
- Object
- GitDiffLCS::Shortstat
- Defined in:
- lib/git_diff_lcs/shortstat.rb
Overview
Shortstat
Instance Attribute Summary collapse
-
#add ⇒ Object
(also: #insertions)
readonly
Returns the value of attribute add.
-
#del ⇒ Object
(also: #deletions)
readonly
Returns the value of attribute del.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#mod ⇒ Object
(also: #modifications)
readonly
Returns the value of attribute mod.
Instance Method Summary collapse
-
#initialize(git_target, src, dest) ⇒ Shortstat
constructor
initialize GitDiffLCS::Shortstat.
-
#summary ⇒ Object
Get diff summary changed files, insertions, deletions, modifications and total.
Constructor Details
#initialize(git_target, src, dest) ⇒ Shortstat
initialize GitDiffLCS::Shortstat
Arguments:
[String] git_target: git repository address or working directory
[String] src: commit or branch
[String] dest: commit or branch
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/git_diff_lcs/shortstat.rb', line 20 def initialize(git_target, src, dest) @dir = Dir.mktmpdir @add, @del, @mod = *GitDiffLCS::INIT_COUNT @errors = [] @git = GitDiffLCS::LibGit.new(git_target, @dir, src, dest) calculate rescue Git::GitExecuteError, ArgumentError @errors << "[ERROR] wrong arguments" ensure FileUtils.rm_rf(@dir) end |
Instance Attribute Details
#add ⇒ Object (readonly) Also known as: insertions
Returns the value of attribute add.
9 10 11 |
# File 'lib/git_diff_lcs/shortstat.rb', line 9 def add @add end |
#del ⇒ Object (readonly) Also known as: deletions
Returns the value of attribute del.
9 10 11 |
# File 'lib/git_diff_lcs/shortstat.rb', line 9 def del @del end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/git_diff_lcs/shortstat.rb', line 9 def errors @errors end |
#mod ⇒ Object (readonly) Also known as: modifications
Returns the value of attribute mod.
9 10 11 |
# File 'lib/git_diff_lcs/shortstat.rb', line 9 def mod @mod end |
Instance Method Details
#summary ⇒ Object
Get diff summary changed files, insertions, deletions, modifications and total
Return:
[String] diff summary
37 38 39 40 41 |
# File 'lib/git_diff_lcs/shortstat.rb', line 37 def summary " #{@git.diff.name_status.keys.size} files changed, "\ "#{@add} insertions(+), #{@del} deletions(-), #{@mod} modifications(!), "\ "total(#{@add + @del + @mod})" end |