mmmenu 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  group :development do
4
- gem "bundler", "~> 1.0.0"
5
- gem "rspec", "~> 2.8.0"
4
+ gem "bundler"
5
+ gem "rspec"
6
6
  gem "jeweler", "~> 1.6.4"
7
7
  #gem "rcov", ">= 0"
8
8
  end
data/Gemfile.lock CHANGED
@@ -21,6 +21,6 @@ PLATFORMS
21
21
  ruby
22
22
 
23
23
  DEPENDENCIES
24
- bundler (~> 1.0.0)
24
+ bundler
25
25
  jeweler (~> 1.6.4)
26
- rspec (~> 2.8.0)
26
+ rspec
data/README.markdown CHANGED
@@ -36,7 +36,7 @@ As you can see, we specify the paths, so our menu does not depend on the routes.
36
36
  `#mmmenu` method automatically puts your menu into @menu instance variable. If you wish to use another variable,
37
37
  you may use a more explicit syntax:
38
38
 
39
- @my_menu = Mmmenu.new(:request => request) do |l1| { ... }
39
+ @my_menu = Mmmenu.new(:request => request) { |l1| ... }
40
40
 
41
41
  Now let's see what happens in the views:
42
42
 
@@ -56,22 +56,31 @@ Run `rails generate mmmenu`, you'll get your app/helpers/mmmenu_helper.rb file a
56
56
  `level_1.erb` is a wrapper for menu level 1
57
57
  `level_2.erb` is a wrapper for menu level 2 (submenu)
58
58
 
59
- If you wish to customize deeper levels of menus and items in them, you should take a look at the generated `mmmenu_helper.rb` file
59
+ You can also has various templates for various menus on your page. Simply, provide a :templates_path option to #build_mmmenu helper like this:
60
+
61
+ <%= build_mmmenu(@menu, templates_path: 'mmmenu/my_custom_menu') %>
62
+
63
+ Then you can put all the same files mentioned above in this directory and change them. This is useful when you have various types of menus
64
+ requiring different html-markup. If you wish to customize deeper levels of menus and items in them, you should take a look at the generated
65
+ `mmmenu_helper.rb` file.
60
66
 
61
67
  Customizing the Helper
62
68
  ----------------------------
63
69
 
64
70
  Let's take a look at what's inside this helper:
65
71
 
66
- def build_mmmenu(menu)
72
+ def build_mmmenu(menu, options = {})
73
+ return nil unless menu
74
+ options = {templates_path: 'mmmenu' }.merge(options)
75
+ templates_path = options[:templates_path]
67
76
  menu.item_markup(1) do |link, text, options|
68
- render(:partial => "mmmenu/item", :locals => { :link => link, :text => text, :options => options })
77
+ render(:partial => "#{templates_path}/item", :locals => { :link => link, :text => text, :options => options })
69
78
  end
70
79
  menu.current_item_markup(1) do |link, text, options|
71
- render(:partial => "mmmenu/current_item", :locals => { :link => link, :text => text, :options => options })
80
+ render(:partial => "#{templates_path}/current_item", :locals => { :link => link, :text => text, :options => options })
72
81
  end
73
- menu.level_markup(1) { |m| render(:partial => "mmmenu/level_1", :locals => { :menu => m }) }
74
- menu.level_markup(2) { |m| render(:partial => "mmmenu/level_2", :locals => { :menu => m }) }
82
+ menu.level_markup(1) { |m| render(:partial => "#{templates_path}/level_1", :locals => { :menu => m }) }
83
+ menu.level_markup(2) { |m| render(:partial => "#{templates_path}/level_2", :locals => { :menu => m }) }
75
84
  menu.build.html_safe
76
85
  end
77
86
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -1,15 +1,17 @@
1
1
  module MmmenuHelper
2
2
 
3
- def build_mmmenu(menu)
3
+ def build_mmmenu(menu, options = {})
4
4
  return nil unless menu
5
+ options = {templates_path: 'mmmenu' }.merge(options)
6
+ templates_path = options[:templates_path]
5
7
  menu.item_markup(1) do |link, text, options|
6
- render(:partial => "mmmenu/item", :locals => { :link => link, :text => text, :options => options })
8
+ render(:partial => "#{templates_path}/item", :locals => { :link => link, :text => text, :options => options })
7
9
  end
8
10
  menu.current_item_markup(1) do |link, text, options|
9
- render(:partial => "mmmenu/current_item", :locals => { :link => link, :text => text, :options => options })
11
+ render(:partial => "#{templates_path}/current_item", :locals => { :link => link, :text => text, :options => options })
10
12
  end
11
- menu.level_markup(1) { |m| render(:partial => "mmmenu/level_1", :locals => { :menu => m }) }
12
- menu.level_markup(2) { |m| render(:partial => "mmmenu/level_2", :locals => { :menu => m }) }
13
+ menu.level_markup(1) { |m| render(:partial => "#{templates_path}/level_1", :locals => { :menu => m }) }
14
+ menu.level_markup(2) { |m| render(:partial => "#{templates_path}/level_2", :locals => { :menu => m }) }
13
15
  menu.build.html_safe
14
16
  end
15
17
 
data/mmmenu.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mmmenu"
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Roman Snitko"]
12
- s.date = "2012-02-27"
12
+ s.date = "2013-04-04"
13
13
  s.description = "Defines multilevel menu structures, uses custom html templates to render them."
14
14
  s.email = "roman.snitko@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -39,24 +39,24 @@ Gem::Specification.new do |s|
39
39
  s.homepage = "http://github.com/snitko/mmmenu"
40
40
  s.licenses = ["MIT"]
41
41
  s.require_paths = ["lib"]
42
- s.rubygems_version = "1.8.10"
42
+ s.rubygems_version = "1.8.24"
43
43
  s.summary = "Flexible menu generator for Rails."
44
44
 
45
45
  if s.respond_to? :specification_version then
46
46
  s.specification_version = 3
47
47
 
48
48
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
50
- s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
49
+ s.add_development_dependency(%q<bundler>, [">= 0"])
50
+ s.add_development_dependency(%q<rspec>, [">= 0"])
51
51
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
52
52
  else
53
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
54
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
53
+ s.add_dependency(%q<bundler>, [">= 0"])
54
+ s.add_dependency(%q<rspec>, [">= 0"])
55
55
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
56
56
  end
57
57
  else
58
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
58
+ s.add_dependency(%q<bundler>, [">= 0"])
59
+ s.add_dependency(%q<rspec>, [">= 0"])
60
60
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
61
61
  end
62
62
  end
@@ -18,9 +18,9 @@ describe Mmmenu do
18
18
 
19
19
  before(:each) do
20
20
  @request = mock('request')
21
- @request.stub!(:path).once.and_return('/items1/new')
22
- @request.stub!(:method).once.and_return('get')
23
- @request.stub!(:params).once.and_return({})
21
+ @request.stub!(:path).and_return('/items1/new')
22
+ @request.stub!(:method).and_return('get')
23
+ @request.stub!(:params).and_return({})
24
24
  @menu = Mmmenu.new(:items => @items, :request => @request )
25
25
  end
26
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mmmenu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,33 +9,43 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-27 00:00:00.000000000 Z
12
+ date: 2013-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &24009500 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.0
21
+ version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *24009500
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &24007940 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
- - - ~>
35
+ - - ! '>='
31
36
  - !ruby/object:Gem::Version
32
- version: 2.8.0
37
+ version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *24007940
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: jeweler
38
- requirement: &24006480 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: 1.6.4
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *24006480
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.6.4
47
62
  description: Defines multilevel menu structures, uses custom html templates to render
48
63
  them.
49
64
  email: roman.snitko@gmail.com
@@ -86,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
101
  version: '0'
87
102
  segments:
88
103
  - 0
89
- hash: 2496057170991287488
104
+ hash: 3008671744595032140
90
105
  required_rubygems_version: !ruby/object:Gem::Requirement
91
106
  none: false
92
107
  requirements:
@@ -95,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
110
  version: '0'
96
111
  requirements: []
97
112
  rubyforge_project:
98
- rubygems_version: 1.8.10
113
+ rubygems_version: 1.8.24
99
114
  signing_key:
100
115
  specification_version: 3
101
116
  summary: Flexible menu generator for Rails.