Class: Git::DiffFilePatchInfo
- Inherits:
-
Data
- Object
- Data
- Git::DiffFilePatchInfo
- Defined in:
- lib/git/diff_file_patch_info.rb
Overview
Immutable value object representing a single file's patch information
DiffFilePatchInfo encapsulates the parsed data from a unified diff for one file, including source and destination file references, the patch text, change type, and line statistics.
Instance Attribute Summary collapse
-
#binary ⇒ Object
readonly
Returns the value of attribute binary.
-
#deletions ⇒ Object
readonly
Returns the value of attribute deletions.
-
#dst ⇒ Object
readonly
Returns the value of attribute dst.
-
#insertions ⇒ Object
readonly
Returns the value of attribute insertions.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
-
#similarity ⇒ Object
readonly
Returns the value of attribute similarity.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#added? ⇒ Boolean
Check if this file was added.
-
#binary? ⇒ Boolean
Check if this is a binary file.
-
#copied? ⇒ Boolean
Check if this file was copied.
-
#deleted? ⇒ Boolean
Check if this file was deleted.
-
#path ⇒ String
Get the primary file path.
-
#renamed? ⇒ Boolean
Check if this file was renamed.
-
#src_path ⇒ String?
Get the source file path.
Instance Attribute Details
#binary ⇒ Object (readonly)
Returns the value of attribute binary
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/git/diff_file_patch_info.rb', line 62 DiffFilePatchInfo = Data.define( :src, :dst, :patch, :status, :similarity, :binary, :insertions, :deletions ) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source file path # # Returns the source path if it exists. Useful for renames/copies to see # where the file came from. # # @return [String, nil] the source file path, or nil if no source (added files) # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#deletions ⇒ Object (readonly)
Returns the value of attribute deletions
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/git/diff_file_patch_info.rb', line 62 DiffFilePatchInfo = Data.define( :src, :dst, :patch, :status, :similarity, :binary, :insertions, :deletions ) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source file path # # Returns the source path if it exists. Useful for renames/copies to see # where the file came from. # # @return [String, nil] the source file path, or nil if no source (added files) # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#dst ⇒ Object (readonly)
Returns the value of attribute dst
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/git/diff_file_patch_info.rb', line 62 DiffFilePatchInfo = Data.define( :src, :dst, :patch, :status, :similarity, :binary, :insertions, :deletions ) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source file path # # Returns the source path if it exists. Useful for renames/copies to see # where the file came from. # # @return [String, nil] the source file path, or nil if no source (added files) # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#insertions ⇒ Object (readonly)
Returns the value of attribute insertions
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/git/diff_file_patch_info.rb', line 62 DiffFilePatchInfo = Data.define( :src, :dst, :patch, :status, :similarity, :binary, :insertions, :deletions ) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source file path # # Returns the source path if it exists. Useful for renames/copies to see # where the file came from. # # @return [String, nil] the source file path, or nil if no source (added files) # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/git/diff_file_patch_info.rb', line 62 DiffFilePatchInfo = Data.define( :src, :dst, :patch, :status, :similarity, :binary, :insertions, :deletions ) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source file path # # Returns the source path if it exists. Useful for renames/copies to see # where the file came from. # # @return [String, nil] the source file path, or nil if no source (added files) # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#similarity ⇒ Object (readonly)
Returns the value of attribute similarity
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/git/diff_file_patch_info.rb', line 62 DiffFilePatchInfo = Data.define( :src, :dst, :patch, :status, :similarity, :binary, :insertions, :deletions ) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source file path # # Returns the source path if it exists. Useful for renames/copies to see # where the file came from. # # @return [String, nil] the source file path, or nil if no source (added files) # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#src ⇒ Object (readonly)
Returns the value of attribute src
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/git/diff_file_patch_info.rb', line 62 DiffFilePatchInfo = Data.define( :src, :dst, :patch, :status, :similarity, :binary, :insertions, :deletions ) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source file path # # Returns the source path if it exists. Useful for renames/copies to see # where the file came from. # # @return [String, nil] the source file path, or nil if no source (added files) # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#status ⇒ Object (readonly)
Returns the value of attribute status
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/git/diff_file_patch_info.rb', line 62 DiffFilePatchInfo = Data.define( :src, :dst, :patch, :status, :similarity, :binary, :insertions, :deletions ) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source file path # # Returns the source path if it exists. Useful for renames/copies to see # where the file came from. # # @return [String, nil] the source file path, or nil if no source (added files) # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
Instance Method Details
#added? ⇒ Boolean
Check if this file was added
122 123 124 |
# File 'lib/git/diff_file_patch_info.rb', line 122 def added? status == :added end |
#binary? ⇒ Boolean
Check if this is a binary file
98 99 100 |
# File 'lib/git/diff_file_patch_info.rb', line 98 def binary? binary end |
#copied? ⇒ Boolean
Check if this file was copied
114 115 116 |
# File 'lib/git/diff_file_patch_info.rb', line 114 def copied? status == :copied end |
#deleted? ⇒ Boolean
Check if this file was deleted
130 131 132 |
# File 'lib/git/diff_file_patch_info.rb', line 130 def deleted? status == :deleted end |
#path ⇒ String
Get the primary file path
Returns the destination path if it exists, otherwise the source path. This is the "current" or "canonical" path for the file.
79 80 81 |
# File 'lib/git/diff_file_patch_info.rb', line 79 def path dst&.path || src&.path end |
#renamed? ⇒ Boolean
Check if this file was renamed
106 107 108 |
# File 'lib/git/diff_file_patch_info.rb', line 106 def renamed? status == :renamed end |
#src_path ⇒ String?
Get the source file path
Returns the source path if it exists. Useful for renames/copies to see where the file came from.
90 91 92 |
# File 'lib/git/diff_file_patch_info.rb', line 90 def src_path src&.path end |