Class: GitSpelunk::Offset
- Inherits:
-
Object
- Object
- GitSpelunk::Offset
- Defined in:
- lib/git_spelunk/offset.rb
Defined Under Namespace
Classes: Chunk
Constant Summary collapse
- STATS_PATTERN =
/@@ \-(\d+),(\d+) \+(\d+),(\d+) @@/
Instance Attribute Summary collapse
-
#chunks ⇒ Object
readonly
Returns the value of attribute chunks.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
Instance Method Summary collapse
- #at_beginning_of_time? ⇒ Boolean
-
#initialize(repo, file_name, sha, line_number) ⇒ Offset
constructor
A new instance of Offset.
- #line_number_to_parent ⇒ Object
- #unable_to_trace_lineage? ⇒ Boolean
Constructor Details
#initialize(repo, file_name, sha, line_number) ⇒ Offset
Returns a new instance of Offset.
41 42 43 44 45 46 47 48 |
# File 'lib/git_spelunk/offset.rb', line 41 def initialize(repo, file_name, sha, line_number) @repo = repo @file_name = file_name @sha = sha @line_number = line_number @parent = @repo.commits(@sha)[0].parents[0] true end |
Instance Attribute Details
#chunks ⇒ Object (readonly)
Returns the value of attribute chunks.
39 40 41 |
# File 'lib/git_spelunk/offset.rb', line 39 def chunks @chunks end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
39 40 41 |
# File 'lib/git_spelunk/offset.rb', line 39 def file_name @file_name end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
39 40 41 |
# File 'lib/git_spelunk/offset.rb', line 39 def repo @repo end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
39 40 41 |
# File 'lib/git_spelunk/offset.rb', line 39 def sha @sha end |
Instance Method Details
#at_beginning_of_time? ⇒ Boolean
157 158 159 |
# File 'lib/git_spelunk/offset.rb', line 157 def at_beginning_of_time? @parent.nil? end |
#line_number_to_parent ⇒ Object
165 166 167 168 169 170 171 172 173 |
# File 'lib/git_spelunk/offset.rb', line 165 def line_number_to_parent return :at_beginning_of_time unless @parent && chunks chunk = target_chunk(@line_number) return :unable_to_trace unless chunk return :first_commit_for_file if chunk.minus_offset == 0 && chunk.minus_length == 0 chunk.find_parent_line_number(@line_number) end |
#unable_to_trace_lineage? ⇒ Boolean
161 162 163 |
# File 'lib/git_spelunk/offset.rb', line 161 def unable_to_trace_lineage? @parent && (@chunks.nil? || target_chunk.nil?) end |