Class: PactBroker::Versions::AbbreviateNumber

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/versions/abbreviate_number.rb

Class Method Summary collapse

Class Method Details

.call(version_number) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/pact_broker/versions/abbreviate_number.rb', line 5

def self.call version_number
  return version_number unless version_number

  # hard limit of max 50 characters
  version_length = version_number.length
  return version_number[0...39] + "" + version_number[version_length - 10...version_length] if version_length > 50

  version_number.gsub(/[A-Za-z0-9]{40}/) do | val |
    val[0..6]
  end
end