lib/generators/effective/menu_generator.rb in effective_developer-0.5.5 vs lib/generators/effective/menu_generator.rb in effective_developer-0.6.0
- old
+ new
@@ -11,20 +11,24 @@
source_root File.expand_path(('../' * 4) + 'lib/scaffolds', __FILE__)
desc 'Adds a menu link to an existing _navbar.html.haml'
+ def validate_resource
+ exit unless resource_valid?
+ end
+
def invoke_menu
say_status :invoke, :menu, :white
end
# layouts/_navbar.html.haml
def create_menu
return unless resource.namespaces.blank?
begin
- Effective::CodeWriter.new('app/views/layouts/_navbar.html.haml') do |w|
+ Effective::CodeWriter.new(resource.menu_file) do |w|
if w.find { |line, _| line == menu_content.second.strip }
say_status :identical, menu_path, :blue
else
if (w.insert_into_first(menu_content) { |line, _| line.include?('.navbar-nav') })
say_status :menu, menu_path, :green
@@ -42,11 +46,11 @@
# layouts/_navbar_admin.html.haml
def create_admin_menu
return unless resource.namespaces == ['admin']
begin
- Effective::CodeWriter.new('app/views/layouts/_navbar_admin.html.haml') do |w|
+ Effective::CodeWriter.new(resource.admin_menu_file) do |w|
if w.find { |line, _| line == menu_content.second.strip }
say_status :identical, menu_path, :blue
else
if (w.insert_into_first(menu_content) { |line, _| line.include?('.navbar-nav') })
say_status :menu, menu_path, :green
@@ -70,10 +74,11 @@
"\n"
]
end
def menu_path
- [resource.namespace, resource.plural_name, 'path'].compact * '_'
+ path = [resource.namespace, resource.plural_name, 'path'].compact * '_'
+ resource.tenant.present? ? "#{resource.tenant}.#{path}" : path
end
end
end
end