menu_maker 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 762e776957a11f8346961c2c9e1d18a61982a735
4
- data.tar.gz: 58fe8eb9c5e1f3d1ba658acf102de6f644930d6a
3
+ metadata.gz: 9a4923f33929c3532d9abb35368c8068996c61ab
4
+ data.tar.gz: a17f276b14a200735d44f482ccf982fbac830609
5
5
  SHA512:
6
- metadata.gz: 3b1fcb4239f1584b1dbde0dc8ef43dbd5b369dd14e3a69f38fcf960f40977a6b552885fade391bbb21a45c09ba552a63544d8cb250f12d51134cec3103f36859
7
- data.tar.gz: 56b9c2c19d7d7d6fa87ca76a6fbcfe61be1d48e1e3ef8dfc3b2f83343b60c27d3e628e9f6b0a98970c5c3041b0b8c8d7492cddbd32dbcf5d3c4262794371a017
6
+ metadata.gz: 68fa806dfe5e5a74366d8e810fbcf56382402e3af6ad2976bdbff32e7ec6ec4b5e1914eab395f75f69e02aa27040db50d29a8131454ca792e5e1e13aeaacd788
7
+ data.tar.gz: d548a02b709d6661fca1a12e42ccea7fb175f6a1cc5cab1fa63dafde4f45c3d46074c64ddfafab181574cb218f9025ef04e1e0392b78c462c9422543eb56fcd8
@@ -1,27 +1,17 @@
1
1
  module MenuMaker
2
2
  class CustomMenuRenderer < MenuRenderer
3
3
  render do
4
- out = build_menu do |item, css_class|
5
- output = build_html do |html|
6
- html << render_link(item)
4
+ output = build_menu do |item, css_class|
5
+ html = build_html { render_link(item) + item.render_submenu }
7
6
 
8
- if item.has_submenu?
9
- css_class << 'dropdown'
10
- html << item.submenu.render
11
- end
7
+ css_class << 'dropdown' if item.has_submenu?
8
+ css_class << 'active open' if item.has_path? current_path
12
9
 
13
- html
14
- end
15
-
16
- if item.has_path? current_path
17
- css_class << 'active open'
18
- end
19
-
20
- options = css_class.any? ? { class: css_class.join(' ') } : {}
21
- h.li(output, nil, options)
10
+ options = { class: css_class.join(' ') } if css_class.any?
11
+ h.li(html, nil, options || {})
22
12
  end
23
13
 
24
- h.content_tag(:ul, out, class: 'nav navbar-nav side-nav')
14
+ h.content_tag(:ul, output, class: 'nav navbar-nav side-nav')
25
15
  end
26
16
 
27
17
  private
@@ -37,15 +27,10 @@ module MenuMaker
37
27
 
38
28
  def render_link(item)
39
29
  if item.has_submenu?
40
- options = {
41
- class: 'dropdown-toggle',
42
- data: { toggle: 'dropdown' }
43
- }
44
- else
45
- options = {}
30
+ options = { class: 'dropdown-toggle', data: { toggle: 'dropdown' } }
46
31
  end
47
32
 
48
- h.link_to(render_title(item), item.path, options)
33
+ h.link_to(render_title(item), item.path, options || {})
49
34
  end
50
35
  end
51
36
  end
@@ -2,13 +2,8 @@ module MenuMaker
2
2
  class CustomSubmenuRenderer < MenuRenderer
3
3
  render do
4
4
  output = build_menu do |item|
5
- options = if item.path == current_path
6
- { link: { class: 'active' } }
7
- else
8
- {}
9
- end
10
-
11
- h.li(item.title, item.path, options)
5
+ options = { link: { class: 'active' } } if item.path == current_path
6
+ h.li(item.title, item.path, options || {})
12
7
  end
13
8
 
14
9
  h.content_tag(:ul, output, class: 'dropdown-menu')
@@ -92,6 +92,10 @@ module MenuMaker
92
92
  def respond_to_missing?(method)
93
93
  !!(options && options[method])
94
94
  end
95
+
96
+ def render_submenu
97
+ has_submenu? ? submenu.render : ''
98
+ end
95
99
  end
96
100
 
97
101
  class MenuError < StandardError; end
@@ -44,7 +44,7 @@ module MenuMaker
44
44
  private
45
45
 
46
46
  def find_current_path(current_path)
47
- @current_path = current_path || request_path || ''
47
+ current_path || request_path || ''
48
48
  end
49
49
 
50
50
  def helpers_has_request?
@@ -1,3 +1,3 @@
1
1
  module MenuMaker
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -633,3 +633,63 @@ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_first_li_submenu_item_
633
633
  -----------------------------------------------------------------------------------------
634
634
  MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_second_li_submenu_item_selected
635
635
  -----------------------------------------------------------------------------------------
636
+ -------------------------------------------------------------------
637
+ MenuMaker::MenuHelperTest: test_menu_helper_that_maps_to_Menu_class
638
+ -------------------------------------------------------------------
639
+ -------------------------------------------------------------------------
640
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_first_li_active
641
+ -------------------------------------------------------------------------
642
+ --------------------------------------------------------------------------------------
643
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_first_li_submenu_item_active
644
+ --------------------------------------------------------------------------------------
645
+ -----------------------------------------------------------------------------------------
646
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_second_li_submenu_item_selected
647
+ -----------------------------------------------------------------------------------------
648
+ -------------------------------------------------------------------
649
+ MenuMaker::MenuHelperTest: test_menu_helper_that_maps_to_Menu_class
650
+ -------------------------------------------------------------------
651
+ -------------------------------------------------------------------------
652
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_first_li_active
653
+ -------------------------------------------------------------------------
654
+ --------------------------------------------------------------------------------------
655
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_first_li_submenu_item_active
656
+ --------------------------------------------------------------------------------------
657
+ -----------------------------------------------------------------------------------------
658
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_second_li_submenu_item_selected
659
+ -----------------------------------------------------------------------------------------
660
+ -------------------------------------------------------------------
661
+ MenuMaker::MenuHelperTest: test_menu_helper_that_maps_to_Menu_class
662
+ -------------------------------------------------------------------
663
+ -------------------------------------------------------------------------
664
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_first_li_active
665
+ -------------------------------------------------------------------------
666
+ --------------------------------------------------------------------------------------
667
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_first_li_submenu_item_active
668
+ --------------------------------------------------------------------------------------
669
+ -----------------------------------------------------------------------------------------
670
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_second_li_submenu_item_selected
671
+ -----------------------------------------------------------------------------------------
672
+ -------------------------------------------------------------------
673
+ MenuMaker::MenuHelperTest: test_menu_helper_that_maps_to_Menu_class
674
+ -------------------------------------------------------------------
675
+ -------------------------------------------------------------------------
676
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_first_li_active
677
+ -------------------------------------------------------------------------
678
+ --------------------------------------------------------------------------------------
679
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_first_li_submenu_item_active
680
+ --------------------------------------------------------------------------------------
681
+ -----------------------------------------------------------------------------------------
682
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_second_li_submenu_item_selected
683
+ -----------------------------------------------------------------------------------------
684
+ -------------------------------------------------------------------
685
+ MenuMaker::MenuHelperTest: test_menu_helper_that_maps_to_Menu_class
686
+ -------------------------------------------------------------------
687
+ -------------------------------------------------------------------------
688
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_first_li_active
689
+ -------------------------------------------------------------------------
690
+ --------------------------------------------------------------------------------------
691
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_first_li_submenu_item_active
692
+ --------------------------------------------------------------------------------------
693
+ -----------------------------------------------------------------------------------------
694
+ MenuMaker::MenuHelperTest: test_outputs_the_menu_with_the_second_li_submenu_item_selected
695
+ -----------------------------------------------------------------------------------------
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: menu_maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago A. Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-28 00:00:00.000000000 Z
11
+ date: 2014-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -39,7 +39,6 @@ files:
39
39
  - lib/menu_maker.rb
40
40
  - lib/menu_maker/custom_menu_renderer.rb
41
41
  - lib/menu_maker/custom_submenu_renderer.rb
42
- - lib/menu_maker/default_menu_renderer.rb
43
42
  - lib/menu_maker/engine.rb
44
43
  - lib/menu_maker/menu.rb
45
44
  - lib/menu_maker/menu_renderer.rb
@@ -1,51 +0,0 @@
1
- module MenuMaker
2
- class DefaultMenuRenderer < MenuRenderer
3
- render do
4
- out = build_menu do |item, css_class|
5
- output = build_html do |html|
6
- html << render_link(item)
7
-
8
- if item.has_submenu?
9
- css_class << 'dropdown'
10
- html << item.submenu.render
11
- end
12
-
13
- html
14
- end
15
-
16
- if item.has_path? current_path
17
- css_class << 'active open'
18
- end
19
-
20
- options = css_class.any? ? { class: css_class.join(' ') } : {}
21
- h.li(output, nil, options)
22
- end
23
-
24
- h.content_tag(:ul, out, class: 'nav navbar-nav side-nav')
25
- end
26
-
27
- private
28
-
29
- def render_title(item)
30
- build_html do
31
- caret = item.has_submenu? ? ' <b class="caret"></b>' : ''
32
- i = %{<i class="#{item.icon}"></i>}
33
-
34
- "#{i} #{item.title}#{caret}"
35
- end
36
- end
37
-
38
- def render_link(item)
39
- if item.has_submenu?
40
- options = {
41
- class: 'dropdown-toggle',
42
- data: { toggle: 'dropdown' }
43
- }
44
- else
45
- options = {}
46
- end
47
-
48
- h.link_to(render_title(item), item.path, options)
49
- end
50
- end
51
- end