Sha256: 000f06809bd7edcd306d85a35359fb5ef7006843e3f19603c70b55acb96c7d23

Contents?: true

Size: 646 Bytes

Versions: 44

Compression:

Stored size: 646 Bytes

Contents

require "pact_broker/string_refinements"

module PactBroker
  module Pacticipants
    module GenerateDisplayName
      using PactBroker::StringRefinements

      def self.call(name)
        return nil if name.nil?
        name
          .to_s
          .gsub(/([A-Z])([A-Z])([a-z])/,'\1 \2\3')
          .gsub(/([a-z\d])([A-Z])(\S)/,'\1 \2\3')
          .gsub(/(\S)([\-_\s\.])(\S)/, '\1 \3')
          .gsub(/\s+/, " ")
          .strip
          .split(" ")
          .collect{ |word| word.camelcase(true) }
          .join(" ")
      end

      def generate_display_name(name)
        GenerateDisplayName.call(name)
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
pact_broker-2.112.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.111.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.109.1 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.109.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.108.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.107.1 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.107.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.107.0.beta.1 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.106.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.105.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.104.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.103.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.102.2 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.102.1 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.102.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.101.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.100.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.99.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.98.0 lib/pact_broker/pacticipants/generate_display_name.rb
pact_broker-2.97.0 lib/pact_broker/pacticipants/generate_display_name.rb