Sha256: ecc57886e9aebd86eb0f26c4115e5dac09e134156af672042b5fdcab9fd57665

Contents?: true

Size: 467 Bytes

Versions: 3

Compression:

Stored size: 467 Bytes

Contents

module Cp8Cli
  class PullRequestTitle
    def initialize(title, prefixes: [])
      @title = title
      @prefixes = 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

3 entries across 3 versions & 1 rubygems

Version Path
cp8_cli-6.0.1 lib/cp8_cli/pull_request_title.rb
cp8_cli-6.0.0 lib/cp8_cli/pull_request_title.rb
cp8_cli-5.0.0 lib/cp8_cli/pull_request_title.rb