Class: FlexaLib::CrudGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- FlexaLib::CrudGenerator
- Defined in:
- lib/generators/flexa_lib/crud/crud_generator.rb
Instance Method Summary collapse
- #copy_views ⇒ Object
- #create_controller_files ⇒ Object
-
#initialize(args, *options) ⇒ CrudGenerator
constructor
A new instance of CrudGenerator.
Constructor Details
#initialize(args, *options) ⇒ CrudGenerator
Returns a new instance of CrudGenerator.
30 31 32 33 34 35 |
# File 'lib/generators/flexa_lib/crud/crud_generator.rb', line 30 def initialize(args, *) #p args.to_yaml super(args, *) initialize_views_variables end |
Instance Method Details
#copy_views ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/generators/flexa_lib/crud/crud_generator.rb', line 45 def copy_views generate_views unless .layout.blank? if .engine =~ /erb/ gsub_file(File.join('app/views/layouts', "#{[:layout]}.html.#{.engine}"), /\<div\s+id=\"main-navigation\">.*\<\/ul\>/mi) do |match| match.gsub!(/\<\/ul\>/, "") %|#{match} <li class="<%= controller.controller_path == '#{@controller_file_path}' ? 'active' : '' %>"><a href="<%= #{controller_routing_path}_path %>">#{plural_model_name}</a></li></ul>| end elsif .engine =~ /haml/ gsub_file(File.join('app/views/layouts', "#{[:layout]}.html.#{.engine}"), /#main-navigation.*#wrapper.wat-cf/mi) do |match| match.gsub!(/ #wrapper.wat-cf/, "") %|#{match}| + " "*6 + %|%li{:class => controller.controller_path == '#{@controller_file_path}' ? 'active' : '' }\n| + " "*7 + %|%a{:href => #{controller_routing_path}_path} #{plural_model_name}\n| + " "*3 + %|#wrapper.wat-cf| end end end end |
#create_controller_files ⇒ Object
38 39 40 41 42 43 |
# File 'lib/generators/flexa_lib/crud/crud_generator.rb', line 38 def create_controller_files if !.no_controller template "controller.rb", File.join('app/controllers', "#{@controller_file_path}_controller.rb") route("resources :#{plural_resource_name}") end end |