Sha256: 6831a16b89681ca4fb60d6b2d7ea05d2eac745091bf11612064d2330f1dc2ffe

Contents?: true

Size: 655 Bytes

Versions: 47

Compression:

Stored size: 655 Bytes

Contents

require 'pact_broker/client/string_refinements'

module PactBroker
  module Client
    module GenerateDisplayName
      using PactBroker::Client::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

47 entries across 47 versions & 1 rubygems

Version Path
pact_broker-client-1.63.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.62.1 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.62.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.61.1 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.61.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.60.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.59.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.58.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.57.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.56.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.55.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.54.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.53.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.52.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.51.2 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.51.1 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.51.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.50.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.49.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.48.0 lib/pact_broker/client/generate_display_name.rb