module ChefSpec::Util

def camelize(string)

Returns:
  • (String) -

Parameters:
  • string (String) --
def camelize(string)
  string
    .to_s
    .split("_")
    .map(&:capitalize)
    .join
end

def truncate(string, options = {})

Parameters:
  • options (Hash) --
  • string (String) --
def truncate(string, options = {})
  length = options[:length] || 30
  if string.length > length
    string[0..length - 3] + "..."
  else
    string
  end
end

def underscore(string)

Returns:
  • (String) -

Parameters:
  • string (String) --
def underscore(string)
  string
    .to_s
    .gsub(/::/, "/")
    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z\d])([A-Z])/, '\1_\2')
    .tr("-", "_")
    .downcase
end