dynamic_menu 3.0.0.rc1 → 3.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ module DynamicMenu
2
+ module AdvancedHash
3
+ class AdvancedHash
4
+
5
+ def initialize
6
+ @instance = Hash.new
7
+ end
8
+
9
+ def tap! *args, &block
10
+ @instance = @instance.tap(*args, &block)
11
+ end
12
+
13
+ def method_missing method, *args, &block
14
+ super unless @instance.methods.index method
15
+ @instance.send method, *args, &block
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -7,7 +7,7 @@ module DynamicMenu
7
7
  end
8
8
 
9
9
  def get_menu_links
10
- @menuLinks || Hash.new
10
+ @menuLinks || AdvancedHash::AdvancedHash.new
11
11
  end
12
12
 
13
13
  def method_missing(method, *args)
@@ -15,5 +15,17 @@ module DynamicMenu
15
15
  @parent.send(method, *args)
16
16
  end
17
17
 
18
+ def inherit_from menu_name
19
+ #@menuLinks ||= AdvancedHash::AdvancedHash.new
20
+ file = Rails.root.to_s+"/app/menus/#{params[:controller]}/#{menu_name}.rb"
21
+ load file
22
+ links_obj = "#{menu_name}Menu".classify.constantize.new(@parent)
23
+ @menuLinks = @menuLinks.merge(links_obj.get_menu_links)
24
+ end
25
+
26
+ def menu_instance
27
+ @menuLinks ||= AdvancedHash::AdvancedHash.new
28
+ end
29
+
18
30
  end
19
31
  end
@@ -1,3 +1,3 @@
1
1
  module DynamicMenu
2
- VERSION = "3.0.0.rc1"
2
+ VERSION = "3.0.0.rc2"
3
3
  end
data/lib/dynamic_menu.rb CHANGED
@@ -2,5 +2,6 @@ module DynamicMenu
2
2
  #require 'rails'
3
3
  require "dynamic_menu/inheritable_menus.rb"
4
4
  require "dynamic_menu/base.rb"
5
+ require "dynamic_menu/advanced_hash.rb"
5
6
  require "engine.rb"
6
7
  end
data/lib/engine.rb CHANGED
@@ -2,6 +2,8 @@ module DynamicMenu
2
2
  class Engine < ::Rails::Engine
3
3
  initializer "dynamic_menu.inheritable_menus" do |app|
4
4
  ActionView::Base.send :include, DynamicMenu::InheritableMenus
5
+ ActionView::Base.send :include, DynamicMenu::AdvancedHash
6
+ ActionController::Base.send :include, DynamicMenu::AdvancedHash
5
7
  end
6
8
  end
7
9
  end
@@ -0,0 +1,16 @@
1
+ require 'rails/generators'
2
+
3
+ module DynamicMenu
4
+ class MenuGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('../templates',__FILE__)
6
+ def generate_menu
7
+ @args[0] =~ /(.+):.+/i
8
+ file = $1
9
+ dir = "app/menus/#{file}"
10
+ Dir.mkdir(dir) unless File.exists?(dir)
11
+ @args[0] =~ /.+:(.+)/i
12
+ @menu_name = $1
13
+ template "menu.rb", "app/menus/#{file}/#{@menu_name}.rb"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ class <%= @menu_name.capitalize %>Menu < DynamicMenu::Base
2
+ def build_menu
3
+ Hash.new.tap do |menu|
4
+ menu["Change Me"] = "http://example.com/change_the_url"
5
+ end
6
+ end
7
+ end
@@ -4,4 +4,5 @@ class DynamicMenuTest < ActiveSupport::TestCase
4
4
  test "truth" do
5
5
  assert_kind_of Module, DynamicMenu
6
6
  end
7
+
7
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc1
4
+ version: 3.0.0.rc2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-09 00:00:00.000000000 Z
12
+ date: 2013-07-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -50,12 +50,15 @@ executables: []
50
50
  extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
+ - lib/dynamic_menu/advanced_hash.rb
53
54
  - lib/dynamic_menu/base.rb
54
55
  - lib/dynamic_menu/inheritable_menus.rb
55
56
  - lib/dynamic_menu/version.rb
56
57
  - lib/dynamic_menu.rb
57
58
  - lib/engine.rb
58
59
  - lib/generators/dynamic_menu/install_generator.rb
60
+ - lib/generators/dynamic_menu/menu_generator.rb
61
+ - lib/generators/dynamic_menu/templates/menu.rb
59
62
  - lib/tasks/dynamic_menu_tasks.rake
60
63
  - MIT-LICENSE
61
64
  - Rakefile