Sha256: 1699543154c0710c6da4a845d34eae1f96e1a16901c9d8112c93dedbf70c26a9
Contents?: true
Size: 997 Bytes
Versions: 1
Compression:
Stored size: 997 Bytes
Contents
module Kachikachi class PatchBody attr_accessor :content def initialize(content, options) @content = content || '' @options = options end 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 def ignore_unmodified_lines PatchBody.new(@content.gsub(/^\s.*(\n|\r\n|\r)/, ''), @options) end def ignore_added_lines PatchBody.new(@content.gsub(/^\+.*(\n|\r\n|\r)/, ''), @options) end def ignore_white_space PatchBody.new(@content.gsub(/^(-|\+)\s*(\n|\r\n|\r)/, ''), @options) end 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kachikachi-0.1.0 | lib/kachikachi/patch_body.rb |