Class: MoshGenerator::AppBuilder

Inherits:
Rails::AppBuilder
  • Object
show all
Defined in:
lib/mosh_generator/app_builder.rb

Overview

Override Rails default AppBuilder

Instance Method Summary collapse

Instance Method Details

#configure_gruntObject

Configures Grunt to compile, concat and minify assets.



126
127
128
129
130
131
132
133
# File 'lib/mosh_generator/app_builder.rb', line 126

def configure_grunt
  if options[:skip_sprockets]
    template 'package.json.tt'
    copy_file 'Gruntfile.js'
    copy_file '.jshintrc'
    run 'npm install'
  end
end

#create_editorconfig_fileObject

Creates an .editorconfig.



77
78
79
# File 'lib/mosh_generator/app_builder.rb', line 77

def create_editorconfig_file
  copy_file '.editorconfig'
end

#create_helpersObject

Creates the initial helpers for the application.



105
106
107
# File 'lib/mosh_generator/app_builder.rb', line 105

def create_helpers
  template 'app_directory/helpers/application_helper.rb.tt', 'app/helpers/application_helper.rb', force: true
end

#create_layoutObject

Creates the layout for the application.



112
113
114
# File 'lib/mosh_generator/app_builder.rb', line 112

def create_layout
  template 'app_directory/views/layouts/application.html.erb.tt', 'app/views/layouts/application.html.erb', force: true
end

#create_partial_viewsObject

Creates the partial views directory with some partial for the application.



119
120
121
# File 'lib/mosh_generator/app_builder.rb', line 119

def create_partial_views
  directory 'app_directory/views/application', 'app/views/application'
end

#create_ruby_gemset_fileObject

Creates a .ruby-gemset file to Ruby version managers.



91
92
93
# File 'lib/mosh_generator/app_builder.rb', line 91

def create_ruby_gemset_file
  template '.ruby-gemset'
end

#create_ruby_version_fileObject

Creates a .ruby-version file to Ruby version managers.



84
85
86
# File 'lib/mosh_generator/app_builder.rb', line 84

def create_ruby_version_file
  template '.ruby-version'
end

#create_staging_environment_fileObject

Creates a staging.rb file on config/environments directory.



98
99
100
# File 'lib/mosh_generator/app_builder.rb', line 98

def create_staging_environment_file
  run 'cp config/environments/production.rb config/environments/staging.rb'
end

#database_ymlObject

Create the database.yml.



32
33
34
# File 'lib/mosh_generator/app_builder.rb', line 32

def database_yml
  copy_file 'config/database.yml'
end

#gemfileObject

Create the Gemfile.



18
19
20
# File 'lib/mosh_generator/app_builder.rb', line 18

def gemfile
  template 'Gemfile.tt'
end

#gitignoreObject

Create the .gitignore.



25
26
27
# File 'lib/mosh_generator/app_builder.rb', line 25

def gitignore
  copy_file '.gitignore'
end

#public_directoryObject

Creates public directory.



39
40
41
42
43
44
45
46
47
# File 'lib/mosh_generator/app_builder.rb', line 39

def public_directory
  super
  directory 'public_directory', 'public', recursive: false, force: true
  if options[:skip_sprockets]
    directory 'public_directory/images', 'public/images'
    directory 'public_directory/javascripts', 'public/javascripts'
    directory 'public_directory/stylesheets', 'public/stylesheets'
  end
end

#readmeObject

Create the README file.



11
12
13
# File 'lib/mosh_generator/app_builder.rb', line 11

def readme
  template 'README.md.tt'
end

#remove_assets_directoriesObject

Removes the assets directories on app, lib and vendor directories.



59
60
61
62
63
64
65
# File 'lib/mosh_generator/app_builder.rb', line 59

def remove_assets_directories
  if options[:skip_sprockets]
    remove_dir 'app/assets'
    remove_dir 'lib/assets'
    remove_dir 'vendor/assets'
  end
end

#remove_doc_directoryObject

Removes the doc directory.



70
71
72
# File 'lib/mosh_generator/app_builder.rb', line 70

def remove_doc_directory
  remove_dir 'doc'
end

#remove_public_indexObject

Removes the index.html file on the public directory.



52
53
54
# File 'lib/mosh_generator/app_builder.rb', line 52

def remove_public_index
  remove_file 'public/index.html'
end