Module: AwesomeLoader::Utils

Defined in:
lib/awesome_loader/utils.rb

Overview

Misc utilities.

Constant Summary collapse

SNAKE =

Regex to match "snake name" paths

%r{_([a-z])}
LEADING_SEP =
%r{^/}
TRAILING_SEP =
%r{/$}

Class Method Summary collapse

Class Method Details

.camelize(name) ⇒ String

Converts a snake_case_name to a CamelCaseName.

Parameters:

  • name (String)

    the snake_case version

Returns:

  • (String)

    the CamelCase version



17
18
19
# File 'lib/awesome_loader/utils.rb', line 17

def self.camelize(name)
  name.capitalize.gsub(SNAKE) { |match| match[1].capitalize }
end

.clean_path(path) ⇒ String

Returns the path with any leading or trailing /'s removed.

Parameters:

  • path (String)

Returns:

  • (String)


27
28
29
# File 'lib/awesome_loader/utils.rb', line 27

def self.clean_path(path)
  path.sub(LEADING_SEP, '').sub(TRAILING_SEP, '')
end