Class: Todidnt::TodoLine
- Inherits:
-
Object
- Object
- Todidnt::TodoLine
- Defined in:
- lib/todidnt/todo_line.rb
Constant Summary collapse
- IGNORE =
%r{assets/js|third_?party|node_modules|jquery|Binary}
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename, line_number, content) ⇒ TodoLine
constructor
A new instance of TodoLine.
-
#populate_blame ⇒ Object
TODO: This logic should probably be moved out somewhere else.
- #pretty ⇒ Object
- #pretty_time ⇒ Object
Constructor Details
#initialize(filename, line_number, content) ⇒ TodoLine
Returns a new instance of TodoLine.
20 21 22 23 24 |
# File 'lib/todidnt/todo_line.rb', line 20 def initialize(filename, line_number, content) @filename = filename @line_number = line_number @content = content end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
5 6 7 |
# File 'lib/todidnt/todo_line.rb', line 5 def @author end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
5 6 7 |
# File 'lib/todidnt/todo_line.rb', line 5 def content @content end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/todidnt/todo_line.rb', line 5 def filename @filename end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
5 6 7 |
# File 'lib/todidnt/todo_line.rb', line 5 def line_number @line_number end |
Class Method Details
.all(expressions) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/todidnt/todo_line.rb', line 7 def self.all(expressions) = [['-n']] expressions.each { |e| << ['-e', e] } grep = GitCommand.new(:grep, ) grep.output_lines.map do |line| filename, line_number, content = line.split(/:/, 3) unless filename =~ IGNORE lines = self.new(filename, line_number.to_i, content.strip[0..100]) end end.compact end |
Instance Method Details
#populate_blame ⇒ Object
TODO: This logic should probably be moved out somewhere else
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/todidnt/todo_line.rb', line 27 def populate_blame = [ ['--line-porcelain'], ['-L', "#{@line_number},#{@line_number}"], [@filename] ] blame = GitCommand.new(:blame, ) blame.output_lines.each do |line| if ( = /author (.*)/.match(line)) @author = [1] elsif ( = /author-time (.*)/.match(line)) @timestamp = [1].to_i end end end |
#pretty ⇒ Object
48 49 50 |
# File 'lib/todidnt/todo_line.rb', line 48 def pretty "#{pretty_time} (#{}, #{filename}:#{line_number}): #{content}" end |
#pretty_time ⇒ Object
44 45 46 |
# File 'lib/todidnt/todo_line.rb', line 44 def pretty_time Time.at(@timestamp).strftime('%F') end |