Class: Spine::Generators::NewGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Spine::Generators::NewGenerator
- Defined in:
- lib/generators/spine/new/new_generator.rb
Instance Method Summary collapse
- #add_spine_app_to_application ⇒ Object
- #app_class ⇒ Object
- #app_name ⇒ Object
- #create_app_file ⇒ Object
- #create_dir_layout ⇒ Object
- #create_lib_file ⇒ Object
Instance Method Details
#add_spine_app_to_application ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/spine/new/new_generator.rb', line 35 def add_spine_app_to_application source = "app/assets/javascripts/application.js" content = File.read(source) if content.include?("//= require_tree .") inject_into_file source, :before => "//= require_tree ." do "//= require #{app_name}\n" end else append_file source, "\n//= require #{app_name}" end end |
#app_class ⇒ Object
16 17 18 |
# File 'lib/generators/spine/new/new_generator.rb', line 16 def app_class app_name.camelize end |
#app_name ⇒ Object
12 13 14 |
# File 'lib/generators/spine/new/new_generator.rb', line 12 def app_name [:app] end |
#create_app_file ⇒ Object
27 28 29 |
# File 'lib/generators/spine/new/new_generator.rb', line 27 def create_app_file template "index.coffee.erb", "app/assets/javascripts/#{app_name}/index.js.coffee" end |
#create_dir_layout ⇒ Object
20 21 22 23 24 25 |
# File 'lib/generators/spine/new/new_generator.rb', line 20 def create_dir_layout %W{models views controllers lib}.each do |dir| empty_directory "app/assets/javascripts/#{app_name}/#{dir}" create_file "app/assets/javascripts/#{app_name}/#{dir}/.keep" end end |
#create_lib_file ⇒ Object
31 32 33 |
# File 'lib/generators/spine/new/new_generator.rb', line 31 def create_lib_file template "view.coffee.erb", "app/assets/javascripts/#{app_name}/lib/view.js.coffee" end |