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
-
#create_admin_menu ⇒ Object
layouts/_navbar_admin.html.haml.
-
#create_menu ⇒ Object
layouts/_navbar.html.haml.
- #invoke_menu ⇒ Object
- #validate_resource ⇒ Object
Instance Method Details
#create_admin_menu ⇒ Object
layouts/_navbar_admin.html.haml
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/generators/effective/menu_generator.rb', line 47 def return unless resource.namespaces == ['admin'] begin Effective::CodeWriter.new(resource.) do |w| if w.find { |line, _| line == .second.strip } say_status :identical, , :blue else if (w.insert_into_first() { |line, _| line.include?('.navbar-nav') }) say_status :menu, , :green else say_status(:skipped, :menu, :yellow) end end end rescue Errno::ENOENT # This will raise an error if the navbar file isn't present say_status :skipped, :menu, :yellow end end |
#create_menu ⇒ Object
layouts/_navbar.html.haml
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/generators/effective/menu_generator.rb', line 25 def return unless resource.namespaces.blank? begin Effective::CodeWriter.new(resource.) do |w| if w.find { |line, _| line == .second.strip } say_status :identical, , :blue else if (w.insert_into_first() { |line, _| line.include?('.navbar-nav') }) say_status :menu, , :green else say_status(:skipped, :menu, :yellow) end 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
20 21 22 |
# File 'lib/generators/effective/menu_generator.rb', line 20 def say_status :invoke, :menu, :white end |
#validate_resource ⇒ Object
16 17 18 |
# File 'lib/generators/effective/menu_generator.rb', line 16 def validate_resource exit unless resource_valid? end |