Class: BackboneHandlebars::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- BackboneHandlebars::Generators::InstallGenerator
show all
- Includes:
- Helpers
- Defined in:
- lib/generators/backbone_handlebars/install/install_generator.rb
Instance Method Summary
collapse
Methods included from Helpers
#app_name, #assets_path, #collections_path, #helpers_path, #javascripts_path, #models_path, #production_config_path, #routers_path, #templates_path, #views_path
Instance Method Details
#create_app_file ⇒ Object
27
28
29
|
# File 'lib/generators/backbone_handlebars/install/install_generator.rb', line 27
def create_app_file
template "app.coffee", "#{javascripts_path}/#{app_name.downcase}.coffee"
end
|
#create_dir_layout ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/generators/backbone_handlebars/install/install_generator.rb', line 18
def create_dir_layout
empty_directory collections_path
empty_directory helpers_path
empty_directory models_path
empty_directory routers_path
empty_directory templates_path
empty_directory views_path
end
|
#inject_files ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/generators/backbone_handlebars/install/install_generator.rb', line 31
def inject_files
manifest = File.join(javascripts_path, options.manifest)
libs = %w[underscore backbone handlebars]
paths = %w(./helpers ./templates ./models ./collections ./views ./routers)
out = []
out << libs.map { |lib| "//= require #{lib}" }
out << "//= require #{app_name.downcase}"
out << paths.map { |path| "//= require_tree #{path}" }
out = out.join("\n") + "\n"
in_root do
return unless File.exists?(manifest)
if File.open(manifest).read().include?('//= require_tree .')
inject_into_file(manifest, out, before: '//= require_tree .')
else
append_file(manifest, out)
end
end
end
|
#inject_production_config ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/generators/backbone_handlebars/install/install_generator.rb', line 53
def inject_production_config
in_root do
return unless File.exists?(production_config_path)
out = []
out << [" # Specify if you want Handlebars precompiled in this environment"]
out << [" config.handlebars.precompile = true"]
out = "\n#{out.join("\n")}\n"
inject_into_file(production_config_path, out, before: "\nend")
end
end
|