Class: Debtective::Comments::Comment::Base
- Inherits:
-
Object
- Object
- Debtective::Comments::Comment::Base
show all
- Defined in:
- lib/debtective/comments/comment/base.rb
Overview
Constant Summary
collapse
/^\s*#\s(?!@)/
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(pathname:, index:) ⇒ Base
Returns a new instance of Base.
17
18
19
20
|
# File 'lib/debtective/comments/comment/base.rb', line 17
def initialize(pathname:, index:)
@pathname = pathname
@index = index
end
|
Instance Attribute Details
#pathname ⇒ Object
Returns the value of attribute pathname.
13
14
15
|
# File 'lib/debtective/comments/comment/base.rb', line 13
def pathname
@pathname
end
|
Instance Method Details
33
34
35
|
# File 'lib/debtective/comments/comment/base.rb', line 33
def
@comment_end ||= ||
end
|
28
29
30
|
# File 'lib/debtective/comments/comment/base.rb', line 28
def
@index
end
|
Return commit that introduced the todo
55
56
57
|
# File 'lib/debtective/comments/comment/base.rb', line 55
def commit
@commit ||= FindCommit.new(pathname: @pathname, line: lines[@index]).call
end
|
#days ⇒ Integer
60
61
62
63
64
|
# File 'lib/debtective/comments/comment/base.rb', line 60
def days
return if commit.time.nil?
((Time.now - commit.time) / (24 * 60 * 60)).round
end
|
#location ⇒ String
Location in the codebase (for clickable link)
49
50
51
|
# File 'lib/debtective/comments/comment/base.rb', line 49
def location
"#{@pathname.to_s.gsub(%r{^./}, "")}:#{ + 1}"
end
|
#statement_end ⇒ Integer
43
44
45
|
# File 'lib/debtective/comments/comment/base.rb', line 43
def statement_end
statement_start
end
|
#statement_start ⇒ Integer
38
39
40
|
# File 'lib/debtective/comments/comment/base.rb', line 38
def statement_start
@statement_start ||= inline? ? @index : .next
end
|
#to_h ⇒ Hash
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/debtective/comments/comment/base.rb', line 67
def to_h
{
pathname: @pathname,
location: location,
type: type,
comment_boundaries: [, ],
statement_boundaries: [statement_start, statement_end],
commit: commit.sha,
author: commit.author.to_h,
time: commit.time
}
end
|
#type ⇒ String
23
24
25
|
# File 'lib/debtective/comments/comment/base.rb', line 23
def type
self.class.name.split("::").last.downcase
end
|