Class: Rugged::Diff::Patch
- Inherits:
-
Object
- Object
- Rugged::Diff::Patch
- Includes:
- Enumerable
- Defined in:
- lib/rugged/diff/patch.rb,
ext/rugged/rugged_diff_patch.c
Instance Attribute Summary collapse
-
#owner ⇒ Object
(also: #diff)
Returns the value of attribute owner.
Instance Method Summary collapse
-
#additions ⇒ Integer
Returns the number of addition lines in the patch.
-
#changes ⇒ Object
Returns the number of changes in the patch.
-
#context ⇒ Integer
Returns the number of context lines in the patch.
-
#deletions ⇒ Integer
Returns the number of deletion lines in the patch.
-
#delta ⇒ Object
Returns the delta object associated with the patch.
-
#each_hunk ⇒ Object
(also: #each)
If given a block, yields each hunk that is part of the patch.
-
#hunk_count ⇒ Integer
(also: #size, #count)
Returns the number of hunks in the patch.
-
#hunks ⇒ Object
Returns an Array containing all hunks of the patch.
- #inspect ⇒ Object
Instance Attribute Details
#owner ⇒ Object Also known as: diff
Returns the value of attribute owner.
10 11 12 |
# File 'lib/rugged/diff/patch.rb', line 10 def owner @owner end |
Instance Method Details
#additions ⇒ Integer
Returns the number of addition lines in the patch.
112 113 114 115 116 117 118 119 120 121 |
# File 'ext/rugged/rugged_diff_patch.c', line 112
static VALUE rb_git_diff_patch_additions(VALUE self)
{
git_diff_patch *patch;
size_t additions;
Data_Get_Struct(self, git_diff_patch, patch);
git_diff_patch_line_stats(NULL, &additions, NULL, patch);
return INT2FIX(additions);
}
|
#changes ⇒ Object
Returns the number of changes in the patch.
18 19 20 |
# File 'lib/rugged/diff/patch.rb', line 18 def changes additions + deletions end |
#context ⇒ Integer
Returns the number of context lines in the patch.
146 147 148 149 150 151 152 153 154 155 |
# File 'ext/rugged/rugged_diff_patch.c', line 146
static VALUE rb_git_diff_patch_context(VALUE self)
{
git_diff_patch *patch;
size_t context;
Data_Get_Struct(self, git_diff_patch, patch);
git_diff_patch_line_stats(&context, NULL, NULL, patch);
return INT2FIX(context);
}
|
#deletions ⇒ Integer
Returns the number of deletion lines in the patch.
129 130 131 132 133 134 135 136 137 138 |
# File 'ext/rugged/rugged_diff_patch.c', line 129
static VALUE rb_git_diff_patch_deletions(VALUE self)
{
git_diff_patch *patch;
size_t deletions;
Data_Get_Struct(self, git_diff_patch, patch);
git_diff_patch_line_stats(NULL, NULL, &deletions, patch);
return INT2FIX(deletions);
}
|
#delta ⇒ Object
Returns the delta object associated with the patch.
98 99 100 101 102 103 104 |
# File 'ext/rugged/rugged_diff_patch.c', line 98
static VALUE rb_git_diff_patch_delta(VALUE self)
{
git_diff_patch *patch;
Data_Get_Struct(self, git_diff_patch, patch);
return rugged_diff_delta_new(rugged_owner(self), git_diff_patch_delta(patch));
}
|
#each_hunk {|hunk| ... } ⇒ self #each_hunk ⇒ Object Also known as: each
If given a block, yields each hunk that is part of the patch.
If no block is given, an enumerator is returned instead.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'ext/rugged/rugged_diff_patch.c', line 52
static VALUE rb_git_diff_patch_each_hunk(VALUE self)
{
git_diff_patch *patch;
const git_diff_range *range;
const char *header;
size_t header_len, lines_in_hunk;
int error = 0, hooks_count, h;
if (!rb_block_given_p()) {
return rb_funcall(self, rb_intern("to_enum"), 1, CSTR2SYM("each_hunk"), self);
}
Data_Get_Struct(self, git_diff_patch, patch);
hooks_count = git_diff_patch_num_hunks(patch);
for (h = 0; h < hooks_count; ++h) {
error = git_diff_patch_get_hunk(&range, &header, &header_len, &lines_in_hunk, patch, h);
if (error) break;
rb_yield(rugged_diff_hunk_new(self, h, range, header, header_len, lines_in_hunk));
}
rugged_exception_check(error);
return self;
}
|
#hunk_count ⇒ Integer Also known as: size, count
Returns the number of hunks in the patch.
84 85 86 87 88 89 90 |
# File 'ext/rugged/rugged_diff_patch.c', line 84
static VALUE rb_git_diff_patch_hunk_count(VALUE self)
{
git_diff_patch *patch;
Data_Get_Struct(self, git_diff_patch, patch);
return INT2FIX(git_diff_patch_num_hunks(patch));
}
|
#hunks ⇒ Object
Returns an Array containing all hunks of the patch.
23 24 25 |
# File 'lib/rugged/diff/patch.rb', line 23 def hunks each_hunk.to_a end |
#inspect ⇒ Object
13 14 15 |
# File 'lib/rugged/diff/patch.rb', line 13 def inspect "#<#{self.class.name}:#{object_id}>" end |