# module Camping::CommandsHelpers

### Constants

Route

  `Route` Struct, for making and formatting a route.

RouteCollection

### Public Class Methods

app_name_from_input(app_name) click to toggle source

Helper method that generates an app name from command line input.

    # File lib/camping/commands.rb, line 24
    def self.app_name_from_input(app_name)
      app_name = :Camp if app_name == nil
      app_name = app_name.to_sym if app_name.class == String
      snake_app_name = to_snake_case(app_name)
      camel_app_name = to_camel_case(snake_app_name)

      {app_name: camel_app_name.to_sym, snake_name: snake_app_name, camel_name: camel_app_name}
    end

to_camel_case(string) click to toggle source

transform app_name to camel Case

    # File lib/camping/commands.rb, line 15
    def self.to_camel_case(string)
      cammelled = ""
      to_snake_case(string).split("_").each do |seq|
        cammelled << seq.capitalize
      end
      cammelled
    end

to_snake_case(string) click to toggle source

transform app_name to snake case

    # File lib/camping/commands.rb, line 5
    def self.to_snake_case(string)
      string = string.to_s if string.class == Symbol
      string.gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').
      tr("-", "_").
      downcase
    end