Class: Kachikachi::PullRequest
- Inherits:
-
Object
- Object
- Kachikachi::PullRequest
- Defined in:
- lib/kachikachi/pull_request.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
writeonly
Sets the attribute client.
-
#content ⇒ Object
writeonly
Sets the attribute content.
-
#diff ⇒ Object
writeonly
Sets the attribute diff.
-
#number ⇒ Object
Returns the value of attribute number.
Instance Method Summary collapse
- #base ⇒ Object
-
#initialize(number, options) ⇒ PullRequest
constructor
A new instance of PullRequest.
- #patch_list ⇒ Object
- #target_patch_list ⇒ Object
Constructor Details
#initialize(number, options) ⇒ PullRequest
Returns a new instance of PullRequest.
8 9 10 11 |
# File 'lib/kachikachi/pull_request.rb', line 8 def initialize(number, ) @number = number @options = end |
Instance Attribute Details
#client=(value) ⇒ Object
Sets the attribute client
6 7 8 |
# File 'lib/kachikachi/pull_request.rb', line 6 def client=(value) @client = value end |
#content=(value) ⇒ Object
Sets the attribute content
6 7 8 |
# File 'lib/kachikachi/pull_request.rb', line 6 def content=(value) @content = value end |
#diff=(value) ⇒ Object
Sets the attribute diff
6 7 8 |
# File 'lib/kachikachi/pull_request.rb', line 6 def diff=(value) @diff = value end |
#number ⇒ Object
Returns the value of attribute number.
6 7 8 |
# File 'lib/kachikachi/pull_request.rb', line 6 def number @number end |
Instance Method Details
#base ⇒ Object
50 51 52 |
# File 'lib/kachikachi/pull_request.rb', line 50 def base content.base end |
#patch_list ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/kachikachi/pull_request.rb', line 19 def patch_list patch_body = '' patch_list = [] patch_file_name = '' body = false lines = diff.lines lines.each_with_index do |line, index| case line when /^diff\s--git\sa\/(?<file_name>.*)\sb\// unless patch_body.empty? patch_list << Patch.new(patch_file_name, patch_body, @options) patch_body = '' end patch_file_name = Regexp.last_match[:file_name] body = false when /^@@\s-\d+,\d+\s\+\d+,\d+\s@@/ body = true else next unless body patch_body << line last_line = lines.count == index + 1 patch_list << Patch.new(patch_file_name, patch_body, @options) if last_line && !patch_body.empty? end end patch_list end |
#target_patch_list ⇒ Object
13 14 15 16 17 |
# File 'lib/kachikachi/pull_request.rb', line 13 def target_patch_list patch_list.select do |patch| !@options['file-regexp'] || patch.file_name =~ Regexp.new(@options['file-regexp']) end end |