123456789_123456789_123456789_123456789_123456789_

Module: Rails::Generators::AppName

Do not use. This module is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: railties/lib/rails/generators/app_name.rb

Constant Summary

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#valid_const?Boolean (readonly, private)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_name.rb', line 26

def valid_const?
  if /^\d/.match?(app_const)
    raise Error, "Invalid application name #{original_app_name}. Please give a name which does not start with numbers."
  elsif RESERVED_NAMES.include?(original_app_name)
    raise Error, "Invalid application name #{original_app_name}. Please give a " \
                 "name which does not match one of the reserved rails " \
                 "words: #{RESERVED_NAMES.join(", ")}"
  elsif Object.const_defined?(app_const_base)
    raise Error, "Invalid application name #{original_app_name}, constant #{app_const_base} is already in use. Please choose another application name."
  end
end

Instance Method Details

#app_const (private)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_name.rb', line 22

def app_const
  @app_const ||= "#{app_const_base}::Application"
end

#app_const_base (private) Also known as: #camelized

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_name.rb', line 17

def app_const_base
  @app_const_base ||= app_name.gsub(/\W/, "_").squeeze("_").camelize
end

#app_name (private)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_name.rb', line 9

def app_name
  @app_name ||= original_app_name.parameterize(preserve_case: true).underscore
end

#camelized (private)

Alias for #app_const_base.

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_name.rb', line 20

alias :camelized :app_const_base

#original_app_name (private)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_name.rb', line 13

def original_app_name
  @original_app_name ||= (options[:name] || File.basename(destination_root))
end