Sha256: fc689680e8262dea1c115ddbe609f8c4dd726cd0aa88e988de5e4abf3a4d2a43

Contents?: true

Size: 474 Bytes

Versions: 6

Compression:

Stored size: 474 Bytes

Contents

module Cp8Cli
  class PullRequestTitle
    def initialize(title, prefixes: [])
      @title = title
      @prefixes = Array(prefixes)
    end

    def run
      title_with_prefixes.presence
    end

    private

      attr_reader :title, :prefixes

      def title_with_prefixes
        "#{prefixes_to_text} #{title}".strip
      end


      def prefixes_to_text
        prefixes.map do |prefix|
          "[#{prefix.to_s.upcase}]"
        end.join(" ")
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cp8_cli-9.1.1 lib/cp8_cli/pull_request_title.rb
cp8_cli-9.1.0 lib/cp8_cli/pull_request_title.rb
cp8_cli-9.0.3 lib/cp8_cli/pull_request_title.rb
cp8_cli-9.0.2 lib/cp8_cli/pull_request_title.rb
cp8_cli-9.0.1 lib/cp8_cli/pull_request_title.rb
cp8_cli-9.0.0 lib/cp8_cli/pull_request_title.rb