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.77.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.76.2 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.76.1 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.76.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.75.4 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.75.3 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.75.1 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.75.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.74.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.73.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.72.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.71.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.70.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.69.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.68.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.67.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.66.1 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.66.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.65.0 lib/pact_broker/client/generate_display_name.rb
pact_broker-client-1.64.0 lib/pact_broker/client/generate_display_name.rb