Class: Underworld::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/underworld/install_generator.rb

Overview

Generator responsible for ‘install` generator

Instance Method Summary collapse

Instance Method Details

#add_gemsObject



76
77
78
79
80
81
82
# File 'lib/generators/underworld/install_generator.rb', line 76

def add_gems
  gem 'jquery-turbolinks'

  inside Rails.root do
    run 'bundle update'
  end
end

#append_assets_to_compileObject



84
85
86
87
88
# File 'lib/generators/underworld/install_generator.rb', line 84

def append_assets_to_compile
  append_to_file 'config/initializers/assets.rb' do
    "Rails.application.config.assets.precompile += %w( dashboard/rtl/application.css dashboard/ltr/application.css)"
  end
end

#assets_manifests_initializerObject



66
67
68
69
70
# File 'lib/generators/underworld/install_generator.rb', line 66

def assets_manifests_initializer
  initializer 'underworld_assets.rb' do
    'Rails.application.config.assets.precompile += %w( underworld/simple.js )'
  end
end

#configure_kaminariObject



42
43
44
# File 'lib/generators/underworld/install_generator.rb', line 42

def configure_kaminari
  generate 'kaminari:config'
end

#copy_init_filesObject



18
19
20
21
22
23
24
# File 'lib/generators/underworld/install_generator.rb', line 18

def copy_init_files
  template 'devise.rb', 'config/initializers/devise.rb'
  template 'underworld.rb', 'config/initializers/underworld.rb'
  template 'api_controller.rb', 'app/controllers/api_controller.rb'
  template 'dashboard_controller.rb', 'app/controllers/dashboard/application_controller.rb'
  template 'policy/application_policy.rb', 'app/policies/application_policy.rb'
end

#copy_js_manifestObject



32
33
34
35
# File 'lib/generators/underworld/install_generator.rb', line 32

def copy_js_manifest
  empty_directory 'app/assets/javascripts/dashboard'
  directory 'javascripts', 'app/assets/javascripts/dashboard'
end

#copy_migrationsObject



10
11
12
# File 'lib/generators/underworld/install_generator.rb', line 10

def copy_migrations
  rake('underworld:install:migrations') unless options[:mongoid]
end

#copy_scss_manifestObject

def grunt_file

template 'i18n/Gruntfile.js.erb', 'lib/tasks/grunt/Gruntfile.js'

end



50
51
52
# File 'lib/generators/underworld/install_generator.rb', line 50

def copy_scss_manifest
  directory 'stylesheets', 'app/assets/stylesheets'
end

#install_formtasticObject



38
39
40
# File 'lib/generators/underworld/install_generator.rb', line 38

def install_formtastic
  generate 'formtastic:install'
end

#install_model_discoveryObject



14
15
16
# File 'lib/generators/underworld/install_generator.rb', line 14

def install_model_discovery
  rake 'model_discovery_engine:install:migrations'
end

#install_routesObject



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/generators/underworld/install_generator.rb', line 54

def install_routes
   route "end\n"
   route '  # Your dashboard routes goes here.'
   route "in_dashboard do"

   route "end\n"
   route '  # Your API routes goes here.'
   route 'api_routes do'

   route "mount Underworld::Engine => '/'\n"
end

#patch_application_controllerObject



72
73
74
# File 'lib/generators/underworld/install_generator.rb', line 72

def patch_application_controller
  inject_into_class "app/controllers/application_controller.rb", ApplicationController, "  extend Underworld::I18n::Locale\n"
end

#patch_formtasticObject



90
91
92
93
94
# File 'lib/generators/underworld/install_generator.rb', line 90

def patch_formtastic
  append_to_file 'config/initializers/formtastic.rb' do
    'Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder'
  end
end

#patch_seedObject



26
27
28
29
30
# File 'lib/generators/underworld/install_generator.rb', line 26

def patch_seed
  prepend_to_file 'db/seeds.rb' do
    "Underworld::Engine.load_seed\n"
  end
end

#show_readmeObject



96
97
98
# File 'lib/generators/underworld/install_generator.rb', line 96

def show_readme
  readme 'README' if behavior == :invoke
end