Class: Faalis::Generators::InstallGenerator

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

Overview

Generator responsible for `install` generator

Instance Method Summary collapse

Instance Method Details

#add_gemsObject



95
96
97
98
99
100
101
# File 'lib/generators/faalis/install_generator.rb', line 95

def add_gems
  gem 'jquery-turbolinks'

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

#append_assets_to_compileObject



103
104
105
106
107
# File 'lib/generators/faalis/install_generator.rb', line 103

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



85
86
87
88
89
# File 'lib/generators/faalis/install_generator.rb', line 85

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

#configure_kaminariObject



61
62
63
# File 'lib/generators/faalis/install_generator.rb', line 61

def configure_kaminari
  generate 'kaminari:config'
end

#copy_init_filesObject



37
38
39
40
41
42
43
# File 'lib/generators/faalis/install_generator.rb', line 37

def copy_init_files
  template 'devise.rb', 'config/initializers/devise.rb'
  template 'faalis.rb', 'config/initializers/faalis.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



51
52
53
54
# File 'lib/generators/faalis/install_generator.rb', line 51

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

#copy_migrationsObject



29
30
31
# File 'lib/generators/faalis/install_generator.rb', line 29

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

#copy_scss_manifestObject

def grunt_file

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

end



69
70
71
# File 'lib/generators/faalis/install_generator.rb', line 69

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

#install_formtasticObject



57
58
59
# File 'lib/generators/faalis/install_generator.rb', line 57

def install_formtastic
  generate 'formtastic:install'
end

#install_model_discoveryObject



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

def install_model_discovery
  rake 'model_discovery_engine:install:migrations'
end

#install_routesObject



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/generators/faalis/install_generator.rb', line 73

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 Faalis::Engine => '/'\n"
end

#patch_application_controllerObject



91
92
93
# File 'lib/generators/faalis/install_generator.rb', line 91

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

#patch_formtasticObject



109
110
111
112
113
# File 'lib/generators/faalis/install_generator.rb', line 109

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

#patch_seedObject



45
46
47
48
49
# File 'lib/generators/faalis/install_generator.rb', line 45

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

#show_readmeObject



115
116
117
# File 'lib/generators/faalis/install_generator.rb', line 115

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