Class: Debtective::Todos::Todo
- Inherits:
-
Object
- Object
- Debtective::Todos::Todo
- Defined in:
- lib/debtective/todos/todo.rb
Overview
Hold todo information
Instance Attribute Summary collapse
-
#pathname ⇒ Object
Returns the value of attribute pathname.
-
#statement_boundaries ⇒ Object
Returns the value of attribute statement_boundaries.
-
#todo_boundaries ⇒ Object
Returns the value of attribute todo_boundaries.
Class Method Summary collapse
Instance Method Summary collapse
-
#commit ⇒ Git::Object::Commit
return commit that introduced the todo.
- #days ⇒ Integer
-
#initialize(pathname, lines, todo_boundaries, statement_boundaries) ⇒ Todo
constructor
A new instance of Todo.
-
#location ⇒ String
location in the codebase.
-
#size ⇒ Integer
size of the todo code.
- #to_h ⇒ Hash
Constructor Details
#initialize(pathname, lines, todo_boundaries, statement_boundaries) ⇒ Todo
Returns a new instance of Todo.
22 23 24 25 26 27 |
# File 'lib/debtective/todos/todo.rb', line 22 def initialize(pathname, lines, todo_boundaries, statement_boundaries) @pathname = pathname @lines = lines @todo_boundaries = todo_boundaries @statement_boundaries = statement_boundaries end |
Instance Attribute Details
#pathname ⇒ Object
Returns the value of attribute pathname.
16 17 18 |
# File 'lib/debtective/todos/todo.rb', line 16 def pathname @pathname end |
#statement_boundaries ⇒ Object
Returns the value of attribute statement_boundaries.
16 17 18 |
# File 'lib/debtective/todos/todo.rb', line 16 def statement_boundaries @statement_boundaries end |
#todo_boundaries ⇒ Object
Returns the value of attribute todo_boundaries.
16 17 18 |
# File 'lib/debtective/todos/todo.rb', line 16 def todo_boundaries @todo_boundaries end |
Class Method Details
.build(pathname, index) ⇒ Debtective::Todos::Todo
11 12 13 |
# File 'lib/debtective/todos/todo.rb', line 11 def build(pathname, index) Build.new(pathname, index).call end |
Instance Method Details
#commit ⇒ Git::Object::Commit
return commit that introduced the todo
43 44 45 |
# File 'lib/debtective/todos/todo.rb', line 43 def commit @commit ||= Debtective::FindCommit.new(@pathname, @lines[@todo_boundaries.min]).call end |
#days ⇒ Integer
48 49 50 51 52 |
# File 'lib/debtective/todos/todo.rb', line 48 def days return if commit.time.nil? ((Time.now - commit.time) / (24 * 60 * 60)).round end |
#location ⇒ String
location in the codebase
31 32 33 |
# File 'lib/debtective/todos/todo.rb', line 31 def location "#{@pathname}:#{@todo_boundaries.min + 1}" end |
#size ⇒ Integer
size of the todo code
37 38 39 |
# File 'lib/debtective/todos/todo.rb', line 37 def size @statement_boundaries.size end |
#to_h ⇒ Hash
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/debtective/todos/todo.rb', line 55 def to_h { pathname: pathname, location: location, todo_boundaries: todo_boundaries.minmax, statement_boundaries: statement_boundaries.minmax, size: size, commit: { sha: commit.sha, author: commit..to_h, time: commit.time } } end |