Class: Twigg::Commit
- Inherits:
-
Object
- Object
- Twigg::Commit
- Defined in:
- lib/twigg/commit.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#stat ⇒ Object
readonly
Returns the value of attribute stat.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #author_names ⇒ Object
- #eql?(other) ⇒ Boolean
- #filtered_commit_message ⇒ Object
- #flesch_reading_ease ⇒ Object
-
#initialize(options) ⇒ Commit
constructor
A new instance of Commit.
- #inspect ⇒ Object
- #link ⇒ Object
-
#russianness ⇒ Object
Return the length of the commit message in lines.
Constructor Details
#initialize(options) ⇒ Commit
Returns a new instance of Commit.
5 6 7 8 9 10 11 12 13 |
# File 'lib/twigg/commit.rb', line 5 def initialize() raise ArgumentError unless @repo = [:repo] raise ArgumentError unless @commit = [:commit] raise ArgumentError unless @subject = [:subject] raise ArgumentError unless @body = [:body] raise ArgumentError unless @author = [:author] raise ArgumentError unless @date = [:date] raise ArgumentError unless @stat = [:stat] end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
3 4 5 |
# File 'lib/twigg/commit.rb', line 3 def @author end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/twigg/commit.rb', line 3 def body @body end |
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
3 4 5 |
# File 'lib/twigg/commit.rb', line 3 def commit @commit end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
3 4 5 |
# File 'lib/twigg/commit.rb', line 3 def date @date end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
3 4 5 |
# File 'lib/twigg/commit.rb', line 3 def repo @repo end |
#stat ⇒ Object (readonly)
Returns the value of attribute stat.
3 4 5 |
# File 'lib/twigg/commit.rb', line 3 def stat @stat end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
3 4 5 |
# File 'lib/twigg/commit.rb', line 3 def subject @subject end |
Instance Method Details
#author_names ⇒ Object
21 22 23 |
# File 'lib/twigg/commit.rb', line 21 def @author.split(/\+|&|,|\band\b/).map(&:strip) end |
#eql?(other) ⇒ Boolean
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/twigg/commit.rb', line 25 def eql?(other) other.is_a?(Commit) && other.repo == @repo && other.commit == @commit && other.subject == @subject && other.body == @body && other. == @author && other.date == @date && other.stat == @stat end |
#filtered_commit_message ⇒ Object
36 37 38 39 40 |
# File 'lib/twigg/commit.rb', line 36 def @filtered_commit_message ||= @body.reject do |line| line =~ /^[a-z-]+: /i # filter out Change-Id:, Signed-off-by: etc end.concat([@subject]).join("\n").chomp end |
#flesch_reading_ease ⇒ Object
42 43 44 |
# File 'lib/twigg/commit.rb', line 42 def flesch_reading_ease @flesch_reading_ease ||= Flesch.new().reading_ease end |
#inspect ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/twigg/commit.rb', line 51 def inspect "repo: #{@repo.name}\n" + "commit: #{@commit}\n" + "subject: #{@subject}\n" + "author: #{@author}\n" + "stat: +#{@stat[:additions]}, -#{@stat[:deletions]}" end |
#link ⇒ Object
15 16 17 18 19 |
# File 'lib/twigg/commit.rb', line 15 def link if Config.github.organization "https://github.com/#{Config.github.organization}/#{repo.name}/commit/#{commit}" end end |
#russianness ⇒ Object
Return the length of the commit message in lines.
47 48 49 |
# File 'lib/twigg/commit.rb', line 47 def russianness .lines.count end |