Class: Chaplin::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Chaplin::Generators::InstallGenerator
show all
- Includes:
- Helpers
- Defined in:
- lib/generators/chaplin/install/install_generator.rb
Instance Method Summary
collapse
Methods included from Helpers
#app_filename, #app_name, #asset_path, #base_path, #collection_namespace, #controller_path, #display, #javascript_path, #layout_path, #lib_path, #model_namespace, #model_path, #plural_file_name, #rails_app_name, #router_file_name, #router_namespace, #singular_file_name, #template_namespace, #template_path, #view_file_name, #view_namespace, #view_path
Instance Method Details
#apply_requirejs ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/generators/chaplin/install/install_generator.rb', line 37
def apply_requirejs
copy_file 'requirejs.yml', 'config/requirejs.yml'
if layout_path
unless gsub_file(layout_path, /javascript_include_tag/, 'requirejs_include_tag')
display "Can't find a javascript_include_tag in '#{layout_path}'!"
display "You must add 'requirejs_include_tag' instead of 'javascript_include_tag'"
display "in your layout(s)."
end
else
display "Can't find a layout to inject requirejs tag!"
display "You must add 'requirejs_include_tag' instead of 'javascript_include_tag'"
display "in your layout(s)."
end
end
|
#copy_app_boilerplate ⇒ Object
type: :boolean, aliases: “-j”, default: false, desc: “Generate JavaScript”
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/generators/chaplin/install/install_generator.rb', line 19
def copy_app_boilerplate
%w(controllers lib models views).each do |dir_name|
empty_directory File.join(javascript_path, dir_name)
end
directory 'javascripts', javascript_path
empty_directory template_path
end
|
#generate_app_files ⇒ Object
32
33
34
35
|
# File 'lib/generators/chaplin/install/install_generator.rb', line 32
def generate_app_files
template "application.js.coffee", "#{javascript_path}/application.js.coffee"
template "app_template.js.coffee", "#{javascript_path}/#{app_filename}.js.coffee"
end
|
#post_install_messages ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/generators/chaplin/install/install_generator.rb', line 58
def post_install_messages
if File.exists?("#{javascript_path}/application.js")
display "You have 'application.js' file in your 'assets/' folder."
display "You should migrate all dependencies to the 'requirejs.yml' config file"
display "and remove 'application.js file."
end
end
|