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|vendor}
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#raw_content ⇒ Object
readonly
Returns the value of attribute raw_content.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(filename, line_number, raw_content) ⇒ TodoLine
constructor
A new instance of TodoLine.
- #pretty_time ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(filename, line_number, raw_content) ⇒ TodoLine
Returns a new instance of TodoLine.
25 26 27 28 29 |
# File 'lib/todidnt/todo_line.rb', line 25 def initialize(filename, line_number, raw_content) @filename = filename @line_number = line_number @raw_content = raw_content end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
6 7 8 |
# File 'lib/todidnt/todo_line.rb', line 6 def 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 |
#raw_content ⇒ Object (readonly)
Returns the value of attribute raw_content.
5 6 7 |
# File 'lib/todidnt/todo_line.rb', line 5 def raw_content @raw_content end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
6 7 8 |
# File 'lib/todidnt/todo_line.rb', line 6 def end |
Class Method Details
.all(expressions) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/todidnt/todo_line.rb', line 8 def self.all(expressions) = [['-n']] expressions.each { |e| << ['-e', e] } lines = [] command = GitCommand.new(:grep, ) command.execute! do |line| filename, line_number, content = line.split(/:/, 3) unless filename =~ IGNORE lines << self.new(filename, line_number.to_i, content) end end lines end |
Instance Method Details
#content ⇒ Object
35 36 37 |
# File 'lib/todidnt/todo_line.rb', line 35 def content raw_content.strip[0..100] end |
#pretty_time ⇒ Object
31 32 33 |
# File 'lib/todidnt/todo_line.rb', line 31 def pretty_time Time.at().strftime('%F') end |
#to_hash ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/todidnt/todo_line.rb', line 39 def to_hash { :time => pretty_time, :author => , :filename => filename, :line_number => line_number, :content => content } end |