Sha256: a024f6602cb9948170bfb37168216a9c46384003bdcec3b03fb224627e5ca3c7

Contents?: true

Size: 862 Bytes

Versions: 1

Compression:

Stored size: 862 Bytes

Contents

module  GitQuickBooks
  class CommitMsgCleaner
    def initialize(msgs)
      @msgs = msgs
    end

    def remove_blanks
      @msgs.reject(&:blank?).compact
    end

    def remove_former_commits
      @msgs.reject { |m| m =~ /Former-commit-id/ }
    end

    def remove_trail_period
      @msgs.map do |msg|
        # [ci-skip]
        msg.strip.chomp('.')
      end
    end

    def remove_square_brackets
      @msgs.map do |msg|
        # [ci-skip]
        msg.gsub(/\[.*\]/, '').strip
      end
    end

    def capitolize_first_word
      @msgs.map do |msg|
        msg[0] = msg[0].to_s.capitalize
        msg
      end
    end

    def call
      @msgs = remove_blanks
      @msgs = remove_trail_period
      @msgs = remove_former_commits
      @msgs = capitolize_first_word
      @msgs = remove_square_brackets
      @msgs.join("\n")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitquickbooks-0.0.1 lib/gitquickbooks/commit_msg_cleaner.rb