class Kachikachi::PatchBody

Attributes

content[RW]

Public Class Methods

new(content, options) click to toggle source
# File lib/kachikachi/patch_body.rb, line 5
def initialize(content, options)
  @content = content || ''
  @options = options
end

Public Instance Methods

ignore_added_lines() click to toggle source
# File lib/kachikachi/patch_body.rb, line 24
def ignore_added_lines
  PatchBody.new(@content.gsub(/^\+.*(\n|\r\n|\r)/, ''), @options)
end
ignore_comment_lines(pattern) click to toggle source
# File lib/kachikachi/patch_body.rb, line 32
def ignore_comment_lines(pattern)
  comment_line_regexp = Regexp.new("^[-+]?\s*#{pattern}.*(\n|\r\n|\r)")
  PatchBody.new(@content.gsub(comment_line_regexp, ''), @options)
end
ignore_unmodified_lines() click to toggle source
# File lib/kachikachi/patch_body.rb, line 20
def ignore_unmodified_lines
  PatchBody.new(@content.gsub(/^\s.*(\n|\r\n|\r)/, ''), @options)
end
ignore_white_space() click to toggle source
# File lib/kachikachi/patch_body.rb, line 28
def ignore_white_space
  PatchBody.new(@content.gsub(/^(-|\+)\s*(\n|\r\n|\r)/, ''), @options)
end
only_removed() click to toggle source
# File lib/kachikachi/patch_body.rb, line 10
def only_removed
  patch = ignore_unmodified_lines
            .ignore_added_lines
  patch = patch.ignore_white_space if @options['ignore-white-space']
  pattern = @options['ignore-comment-regexp']
  patch = patch.ignore_comment_lines(pattern) if pattern

  patch
end