module Pineapples::Helpers

Constants

RESERVED_NAMES

Public Instance Methods

erb?() click to toggle source
# File lib/pineapples/helpers.rb, line 9
def erb?
  template_engine == :erb
end
haml?() click to toggle source
# File lib/pineapples/helpers.rb, line 13
def haml?
  template_engine == :haml
end
needs_user_model?() click to toggle source
# File lib/pineapples/helpers.rb, line 5
def needs_user_model?
  user_role_field? || devise?
end
slim?() click to toggle source
# File lib/pineapples/helpers.rb, line 17
def slim?
  template_engine == :slim
end

Protected Instance Methods

app_const() click to toggle source
# File lib/pineapples/helpers.rb, line 31
def app_const
  @app_const ||= "#{app_const_base}::Application"
end
app_const_base() click to toggle source
# File lib/pineapples/helpers.rb, line 27
def app_const_base
  @app_const_base ||= app_name.gsub(/\W/, '_').squeeze('_').camelize
end
app_secret() click to toggle source
# File lib/pineapples/helpers.rb, line 45
def app_secret
  SecureRandom.hex(64)
end
humanized_application_name() click to toggle source
# File lib/pineapples/helpers.rb, line 23
def humanized_application_name
  app_name.underscore.humanize.gsub(/\S+/, &:capitalize)
end
preexisting_git_repo?() click to toggle source
# File lib/pineapples/helpers.rb, line 49
def preexisting_git_repo?
  git_path = File.expand_path('.git', app_root)
  File.exist?(git_path)
end
rbenv_installed?() click to toggle source
# File lib/pineapples/helpers.rb, line 54
def rbenv_installed?
  @rbenv_installed = `which rbenv`.length > 0 if @rbenv_installed.nil?
  @rbenv_installed
end
rvm_installed?() click to toggle source
# File lib/pineapples/helpers.rb, line 59
def rvm_installed?
  @rvm_installed = `rvm -v`.length > 0 if @rvm_installed.nil?
  @rvm_installed
end
valid_const!() click to toggle source
# File lib/pineapples/helpers.rb, line 35
def valid_const!
  if app_const =~ /^\d/
    raise Error, "Invalid application name #{app_name}. Please give a name which does not start with numbers."
  elsif RESERVED_NAMES.include?(app_name)
    raise Error, "Invalid application name #{app_name}. Please give a name which does not match one of the reserved rails words."
  elsif Object.const_defined?(app_const_base)
    raise Error, "Invalid application name #{app_name}, constant #{app_const_base} is already in use. Please choose another application name."
  end
end