ichiban 1.2.7 → 1.2.8

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: e432ce9f46b90434cc7dbbdaf5dc43d5797c90f3
4
- data.tar.gz: 40ad539678520c0931556150b139e8f49dccde5a
3
+ metadata.gz: 40da37f436ac3296743d2becb2098d58e59ef504
4
+ data.tar.gz: 78927f05443992fde4ae019ffd842c5f29e7e611
5
5
  SHA512:
6
- metadata.gz: bc627c2d62143885e1527df917e98f0ec849042cb8cbf1461c47807f600ba4e800600388b73b20ed62244e6aa585c63d0bb21db8c9dc435df05e5cf750000033
7
- data.tar.gz: e9ac06ee5c7d1d9290d3ab939f5d33020f3f5bcfb2ceb688dd1d98611a8ab3778ea41d6281e4d805563f848aec6878d5a03492ec5428d5de13f6c7eab7f8f3f8
6
+ metadata.gz: 628a764f66be754f023e99a7eaf7669c9ec3695538d98fd3ad5dc87216e8dd989567b3b94e871b838649e1a0d937bf02c3ae0435edb7613e5e36d4e53edcb8b2
7
+ data.tar.gz: bb431afb2682dfe43124451b4dd955d716e4f5b4a0684dbcbf3c9cb57fd542d4117a0173cd2ae5a5a8303910102c1894061165c67abd442521282f6c83d5c561
@@ -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.detect do |item|
49
- # If an item has a sub-menu, then that menu must be the third element of the array.
50
- # (The format is [text, path, sub_menu, li_options].) So we recursively search the
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
- if fourth.is_a?(Hash)
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
@@ -1,3 +1,3 @@
1
1
  module Ichiban
2
- VERSION = '1.2.7'
2
+ VERSION = '1.2.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ichiban
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarrett Colby