navigasmic 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.4
1
+ 0.5.5
@@ -47,10 +47,12 @@ module Navigasmic
47
47
  options[:html][:id] ||= label.to_s.gsub(/\s/, '_').underscore
48
48
 
49
49
  options[:html][:class] = template.add_class(options[:html][:class], @@classnames[:disabled]) if item.disabled?
50
- options[:html][:class] = template.add_class(options[:html][:class], @@classnames[:highlighted]) if item.highlighted?(template.request.path, template.params)
50
+ options[:html][:class] = template.add_class(options[:html][:class], @@classnames[:highlighted]) if item.highlighted?(template.request.path, template.params, template)
51
51
 
52
52
  label = label_for_item(label)
53
- label = template.link_to(label, item.link, options.delete(:link_html)) unless item.link.empty? || item.disabled?
53
+ link = item.link.is_a?(Proc) ? template.instance_eval(&item.link) : item.link
54
+
55
+ label = template.link_to(label, link, options.delete(:link_html)) unless !item.link? || item.disabled?
54
56
 
55
57
  item.hidden? ? '' : template.content_tag(@@item_tag, label + buffer, options.delete(:html))
56
58
  end
@@ -77,11 +77,18 @@ module Navigasmic #:nodoc:
77
77
 
78
78
  options[:highlights_on] = [options[:highlights_on]] if options[:highlights_on].kind_of?(Hash) || options[:highlights_on].kind_of?(String)
79
79
  @highlights_on = options[:highlights_on] || []
80
- @highlights_on << @link if link?
80
+
81
+ if link?
82
+ if @link.is_a?(Proc)
83
+ @highlights_on << template.instance_eval(&@link)
84
+ else
85
+ @highlights_on << @link if link?
86
+ end
87
+ end
81
88
  end
82
89
 
83
90
  def link?
84
- @link && !@link.empty?
91
+ @link && !@link.blank?
85
92
  end
86
93
 
87
94
  def disabled?
@@ -92,7 +99,7 @@ module Navigasmic #:nodoc:
92
99
  !@visible
93
100
  end
94
101
 
95
- def highlighted?(path, params = {})
102
+ def highlighted?(path, params = {}, template = nil)
96
103
  params = clean_unwanted_keys(params)
97
104
  result = false
98
105
 
@@ -103,7 +110,7 @@ module Navigasmic #:nodoc:
103
110
  when String
104
111
  highlighted &= path == highlight
105
112
  when Proc
106
- h = template.instance_eval(highlight)
113
+ h = template.instance_eval(&highlight)
107
114
  raise 'proc highlighting rules must evaluate to TrueClass or FalseClass' unless (h.is_a?(TrueClass) || h.is_a?(FalseClass))
108
115
  highlighted &= h
109
116
  when Regexp
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{navigasmic}
8
- s.version = "0.5.4"
8
+ s.version = "0.5.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeremy Jackson"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: navigasmic
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 4
10
- version: 0.5.4
9
+ - 5
10
+ version: 0.5.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Jackson