Class: Effective::Generators::MenuGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Effective::Generators::MenuGenerator
- Includes:
- Helpers
- Defined in:
- lib/generators/effective/menu_generator.rb
Instance Method Summary collapse
Instance Method Details
#create_effective_menus ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/generators/effective/menu_generator.rb', line 41 def begin Effective::CodeWriter.new('lib/tasks/generate/effective_menus.rake') do |w| if w.find { |line, _| line == } say_status :identical, resource.index_path, :blue else index = w.first { |line, _| line.start_with?('item') } w.insert(, index) system('rake generate:effective_menus') say_status :effective_menus, resource.plural_name + '_path', :green end end rescue Errno::ENOENT # This will raise an error if the navbar file isn't present say_status :skipped, :effective_menus, :yellow end end |
#create_menu ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/effective/menu_generator.rb', line 19 def begin Effective::CodeWriter.new((['app/views'] + resource.namespaces + ['_navbar.html.haml']).join('/')) do |w| if w.find { |line, _| line == .last.strip } say_status :identical, resource.index_path, :blue else index = w.last { |line, _| line.start_with?('- if can?') } if index.blank? say_status(:skipped, :menu, :yellow) and return end w.insert_raw(, index+1, w.depth_at(index)) say_status :menu, resource.index_path, :green end end rescue Errno::ENOENT # This will raise an error if the navbar file isn't present say_status :skipped, :menu, :yellow end end |
#invoke_menu ⇒ Object
15 16 17 |
# File 'lib/generators/effective/menu_generator.rb', line 15 def say_status :invoke, :menu, :white end |