Sha256: 8c0e5862df77b13b6c6821f6c03710c896e1e5404dfe090ed8efebbf302505fa
Contents?: true
Size: 1016 Bytes
Versions: 21
Compression:
Stored size: 1016 Bytes
Contents
require "pact_broker/domain/group" module PactBroker module Pacticipants class FindPotentialDuplicatePacticipantNames attr_reader :new_name, :existing_names def initialize new_name, existing_names @new_name = new_name @existing_names = existing_names end def self.call new_name, existing_names new(new_name, existing_names).call end def call return [] if existing_names.include?(new_name) existing_names.select do | existing_name | clean(new_name) == clean(existing_name) end end def clean name self.class.split(name).collect{|w| w.chomp("s") } - ["api", "provider", "service"] end def self.split(string) string.gsub(/\s/, "_") .gsub(/::/, "/") .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr("-", "_") .downcase .split("_") end end end end
Version data entries
21 entries across 21 versions & 1 rubygems