Module: PactBroker::Client::GenerateDisplayName

Included in:
DescribeTextFormatter
Defined in:
lib/pact_broker/client/generate_display_name.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pact_broker/client/generate_display_name.rb', line 8

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

Instance Method Details

#generate_display_name(name) ⇒ Object



22
23
24
# File 'lib/pact_broker/client/generate_display_name.rb', line 22

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