Class: Lazylead::Entry
- Inherits:
-
Object
- Object
- Lazylead::Entry
- Defined in:
- lib/lazylead/task/svn/grep.rb
Overview
Single SVN commit details
Instance Method Summary collapse
-
#affected(text) ⇒ Object
Detect affected files with particular text.
- #author ⇒ Object
-
#diff(text) ⇒ Object
Detect SVN diff lines with particular text.
- #header ⇒ Object
-
#includes?(text) ⇒ Boolean
The modified lines contains expected text.
-
#initialize(commit) ⇒ Entry
constructor
A new instance of Entry.
- #lines ⇒ Object
- #msg ⇒ Object
- #rev ⇒ Object
- #time ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(commit) ⇒ Entry
Returns a new instance of Entry.
79 80 81 |
# File 'lib/lazylead/task/svn/grep.rb', line 79 def initialize(commit) @commit = commit end |
Instance Method Details
#affected(text) ⇒ Object
Detect affected files with particular text
130 131 132 133 134 135 136 137 |
# File 'lib/lazylead/task/svn/grep.rb', line 130 def affected(text) occurrences = lines.each_index.select do |i| lines[i].start_with?("+") && text.any? { |t| lines[i].include? t } end occurrences.map do |occ| lines[2..occ].reverse.find { |l| l.start_with? "Index: " }[7..] end end |
#author ⇒ Object
91 92 93 |
# File 'lib/lazylead/task/svn/grep.rb', line 91 def header[1] end |
#diff(text) ⇒ Object
Detect SVN diff lines with particular text
119 120 121 122 123 124 125 126 127 |
# File 'lib/lazylead/task/svn/grep.rb', line 119 def diff(text) @diff ||= begin files = affected(text).uniq @commit.split("Index: ") .select { |i| files.any? { |f| i.start_with? f } } .map { |i| i.split "\n" } .flatten end end |
#header ⇒ Object
114 115 116 |
# File 'lib/lazylead/task/svn/grep.rb', line 114 def header @header ||= lines.first.split(" | ").reject(&:blank?) end |
#includes?(text) ⇒ Boolean
The modified lines contains expected text
104 105 106 107 108 |
# File 'lib/lazylead/task/svn/grep.rb', line 104 def includes?(text) text = [text] unless text.respond_to? :each lines[4..].select { |l| l.start_with? "+" } .any? { |l| text.any? { |t| l.include? t } } end |
#lines ⇒ Object
110 111 112 |
# File 'lib/lazylead/task/svn/grep.rb', line 110 def lines @lines ||= @commit.split("\n").reject(&:blank?) end |
#msg ⇒ Object
99 100 101 |
# File 'lib/lazylead/task/svn/grep.rb', line 99 def msg lines[1] end |
#rev ⇒ Object
87 88 89 |
# File 'lib/lazylead/task/svn/grep.rb', line 87 def rev header.first[1..] end |
#time ⇒ Object
95 96 97 |
# File 'lib/lazylead/task/svn/grep.rb', line 95 def time header[2] end |
#to_s ⇒ Object
83 84 85 |
# File 'lib/lazylead/task/svn/grep.rb', line 83 def to_s "#{rev} #{msg}" end |