ichiban 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ichiban/nav_helper.rb +19 -7
- data/lib/ichiban/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40da37f436ac3296743d2becb2098d58e59ef504
|
4
|
+
data.tar.gz: 78927f05443992fde4ae019ffd842c5f29e7e611
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 628a764f66be754f023e99a7eaf7669c9ec3695538d98fd3ad5dc87216e8dd989567b3b94e871b838649e1a0d937bf02c3ae0435edb7613e5e36d4e53edcb8b2
|
7
|
+
data.tar.gz: bb431afb2682dfe43124451b4dd955d716e4f5b4a0684dbcbf3c9cb57fd542d4117a0173cd2ae5a5a8303910102c1894061165c67abd442521282f6c83d5c561
|
data/lib/ichiban/nav_helper.rb
CHANGED
@@ -45,12 +45,9 @@ module Ichiban
|
|
45
45
|
|
46
46
|
# The path for this menu item did not match. So search recursively for a matching
|
47
47
|
# path in this item's sub-menu.
|
48
|
-
!sub_menu.
|
49
|
-
|
50
|
-
|
51
|
-
# descendant menu(s) of this item.
|
52
|
-
(item[2].is_a?(Array) and menu_matches_current_path?(item[1], item[2], options))
|
53
|
-
end.nil?
|
48
|
+
(!sub_menu.nil? and sub_menu.any? do |_, sub_path, sub_sub_menu|
|
49
|
+
menu_matches_current_path? sub_path, sub_sub_menu, options
|
50
|
+
end)
|
54
51
|
end
|
55
52
|
|
56
53
|
# Recursive
|
@@ -67,7 +64,13 @@ module Ichiban
|
|
67
64
|
@ctx.content_tag('ul', ul_options) do
|
68
65
|
items.inject('') do |lis, item|
|
69
66
|
text = item.shift
|
67
|
+
unless text.is_a?(String)
|
68
|
+
raise "Invalid data structure passed to nav. Expected String, but got #{text.inspect}"
|
69
|
+
end
|
70
70
|
path = item.shift
|
71
|
+
unless path.is_a?(String)
|
72
|
+
raise "Invalid data structure passed to nav. Expected String, but got #{path.inspect}"
|
73
|
+
end
|
71
74
|
|
72
75
|
# After the text and path, there are two optional parameters: Sub-menu (an array)
|
73
76
|
# and <li> options (a hash). If both exist, they must come in that order. But either
|
@@ -85,11 +88,20 @@ module Ichiban
|
|
85
88
|
case third
|
86
89
|
when Array
|
87
90
|
sub_menu = third
|
88
|
-
|
91
|
+
case fourth
|
92
|
+
when Hash
|
89
93
|
li_attrs = fourth
|
94
|
+
when nil
|
95
|
+
# Do nothing.
|
96
|
+
else
|
97
|
+
raise "Invalid data structure passed to nav. Expected Hash or nil, but got #{fourth.inspect}"
|
90
98
|
end
|
91
99
|
when Hash
|
92
100
|
li_attrs.merge!(third)
|
101
|
+
when nil
|
102
|
+
# Do nothing.
|
103
|
+
else
|
104
|
+
raise "Invalid data structure passed to nav. Expected Array, Hash, or nil, but got #{third.inspect}"
|
93
105
|
end
|
94
106
|
|
95
107
|
# If the path has a leading slash, consider it absolute and prepend it with
|
data/lib/ichiban/version.rb
CHANGED