Class: Backbonify::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Backbonify::Generators::InstallGenerator
show all
- Includes:
- ResourceHelpers
- Defined in:
- lib/generators/backbonify/install/install_generator.rb
Instance Method Summary
collapse
#application_name, #backbone_path, #collection_namespace, #js_app_name, #jst, #model_namespace, #plural_model_name, #router_namespace, #singular_model_name, #uncapitalize, #view_namespace
Instance Method Details
#copy_javascripts_libs_to_vendor ⇒ Object
15
16
17
|
# File 'lib/generators/backbonify/install/install_generator.rb', line 15
def copy_javascripts_libs_to_vendor
directory("../../../../../lib/assets/javascripts/", "vendor/assets/javascripts/", :recursive => true)
end
|
#create_app_file ⇒ Object
51
52
53
|
# File 'lib/generators/backbonify/install/install_generator.rb', line 51
def create_app_file
template "app.js", "app/assets/javascripts/#{application_name.underscore}.js"
end
|
#create_dir_layout ⇒ Object
44
45
46
47
48
49
|
# File 'lib/generators/backbonify/install/install_generator.rb', line 44
def create_dir_layout
%W{routers models views templates}.each do |dir|
empty_directory "app/assets/javascripts/#{dir}"
create_file "app/assets/javascripts/#{dir}/.gitkeep" unless options[:skip_git]
end
end
|
#inject_backbone ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/generators/backbonify/install/install_generator.rb', line 20
def inject_backbone
return if options[:skip_requires]
inject_into_file "app/assets/javascripts/application.js", :before => "//= require_tree" do
a = %{
//= require json2
//= require jquery
//= require jquery-ui
//= require jquery.notice
//= require handlebars.runtime
//= require underscore
//= require backbone
// require backbone_rails_sync
//= require backbone_datalink
//= require backbone.grid
//= require #{application_name.underscore}
$(function(){
window.app = #{application_name}.init()
});
}
end
end
|