Class: Cramp::Generators::Application

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/cramp/generators/application.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Application

Returns a new instance of Application.

Raises:

  • (Thor::Error)


15
16
17
18
19
# File 'lib/cramp/generators/application.rb', line 15

def initialize(*args)
  raise Thor::Error, "No application name supplied. Please run: cramp --help" if args[0].blank?

  super
end

Class Method Details



25
26
27
# File 'lib/cramp/generators/application.rb', line 25

def self.banner
  "cramp new #{self.arguments.map(&:usage).join(' ')} [options]"
end

.source_rootObject



21
22
23
# File 'lib/cramp/generators/application.rb', line 21

def self.source_root
  @_source_root ||= File.join(File.dirname(__FILE__), "templates/application")
end

Instance Method Details

#create_configObject



46
47
48
49
50
51
52
53
# File 'lib/cramp/generators/application.rb', line 46

def create_config
  empty_directory "config"

  inside "config" do
    template "routes.rb"
    template 'database.yml' if active_record?
  end
end

#create_home_actionObject



55
56
57
58
59
60
61
# File 'lib/cramp/generators/application.rb', line 55

def create_home_action
  empty_directory "app/actions"

  inside "app/actions" do
    template "home_action.rb"
  end
end

#create_modelsObject



63
64
65
66
67
# File 'lib/cramp/generators/application.rb', line 63

def create_models
  if active_record?
    empty_directory "app/models"
  end
end

#create_rootObject



29
30
31
32
33
34
35
# File 'lib/cramp/generators/application.rb', line 29

def create_root
  self.destination_root = File.expand_path(application_path, destination_root)
  valid_const?

  empty_directory '.'
  FileUtils.cd(destination_root)
end

#create_root_filesObject



37
38
39
40
41
42
43
44
# File 'lib/cramp/generators/application.rb', line 37

def create_root_files
  template 'config.ru'
  template 'Gemfile'
  template 'application.rb'

  empty_directory "public"
  empty_directory "public/javascripts"
end