Sha256: a08d7a9ce73d02baba4a1ff552a4caf4269e4f17fbda4afcd0dc62686f9f6967

Contents?: true

Size: 948 Bytes

Versions: 4

Compression:

Stored size: 948 Bytes

Contents

# Polisher RPM Patch Representation
#
# Licensed under the MIT license
# Copyright (C) 2014 Red Hat, Inc.

module Polisher
  module RPM
    class Patch
      attr_accessor :title
      attr_accessor :content

      def initialize(args={})
        @title   = args[:title]
        @content = args[:content]
      end

      def spec_line(n=0)
        "Patch#{n}: #{title}"
      end

      def self.from(diff)
        return diff.collect { |d| self.from(d) } if diff.is_a?(Array)

        result = {}

        in_diff = nil
        diff.each_line do |line|
          if line =~ /diff -r ([^\s]+)+ ([^\s]+)+$/
            result[in_diff] = diff if in_diff
            in_diff = $1.gsub(/a\//, '')
            diff    = ''
          elsif line =~ /Only in.*$/
            in_diff = nil

          else
             diff += line
          end
        end

        result.collect { |t,c| self.new :title => t, :content => c }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
polisher-0.10.2 lib/polisher/rpm/patch.rb
polisher-0.10.1 lib/polisher/rpm/patch.rb
polisher-0.9.1 lib/polisher/rpm/patch.rb
polisher-0.8.1 lib/polisher/rpm/patch.rb