Class: Crystalball::SourceDiff::FileDiff
- Inherits:
-
Object
- Object
- Crystalball::SourceDiff::FileDiff
show all
- Defined in:
- lib/crystalball/source_diff/file_diff.rb
Overview
Data object for single file in Git repo diff
Instance Method Summary
collapse
Constructor Details
#initialize(git_diff) ⇒ FileDiff
Returns a new instance of FileDiff.
8
9
10
|
# File 'lib/crystalball/source_diff/file_diff.rb', line 8
def initialize(git_diff)
@git_diff = git_diff
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
40
41
42
|
# File 'lib/crystalball/source_diff/file_diff.rb', line 40
def method_missing(method, *args, &block)
git_diff.public_send(method, *args, &block) || super
end
|
Instance Method Details
#deleted? ⇒ Boolean
20
21
22
|
# File 'lib/crystalball/source_diff/file_diff.rb', line 20
def deleted?
git_diff.type == 'deleted'
end
|
#modified? ⇒ Boolean
16
17
18
|
# File 'lib/crystalball/source_diff/file_diff.rb', line 16
def modified?
!moved? && git_diff.type == 'modified'
end
|
#moved? ⇒ Boolean
12
13
14
|
# File 'lib/crystalball/source_diff/file_diff.rb', line 12
def moved?
!(git_diff.patch =~ /rename from.*\nrename to/).nil?
end
|
#new? ⇒ Boolean
24
25
26
|
# File 'lib/crystalball/source_diff/file_diff.rb', line 24
def new?
git_diff.type == 'new'
end
|
#new_relative_path ⇒ Object
Returns new relative path to file if file was moved.
34
35
36
37
38
|
# File 'lib/crystalball/source_diff/file_diff.rb', line 34
def new_relative_path
return relative_path unless moved?
git_diff.patch.match(/rename from.*\nrename to (.*)/)[1]
end
|
#relative_path ⇒ Object
Returns relative path to file.
29
30
31
|
# File 'lib/crystalball/source_diff/file_diff.rb', line 29
def relative_path
git_diff.path
end
|
#respond_to_missing?(method) ⇒ Boolean
44
45
46
|
# File 'lib/crystalball/source_diff/file_diff.rb', line 44
def respond_to_missing?(method, *)
git_diff.respond_to?(method, false) || super
end
|