xebec 2.5.2 → 2.6.0
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.
- data/VERSION +1 -1
- data/lib/xebec/has_nav_bars.rb +3 -3
- data/lib/xebec/nav_bar_helper.rb +5 -4
- data/lib/xebec/nav_bar_renderer.rb +1 -1
- data/test/nav_bar_helper_test.rb +12 -0
- data/test/test_helper.rb +1 -1
- data/xebec.gemspec +5 -4
- metadata +4 -4
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.6.0
|
data/lib/xebec/has_nav_bars.rb
CHANGED
|
@@ -15,14 +15,14 @@ module Xebec
|
|
|
15
15
|
# @param [Symbol, String] name the name of the navigation bar to look up
|
|
16
16
|
# @param [Hash] html_attributes additional HTML attributes to add to the
|
|
17
17
|
# navigation bar
|
|
18
|
-
def look_up_nav_bar_and_eval(name = nil, html_attributes = {}, &block)
|
|
18
|
+
def look_up_nav_bar_and_eval(name = nil, html_attributes = {}, options = {}, &block)
|
|
19
19
|
name ||= Xebec::NavBar::DEFAULT_NAME
|
|
20
|
-
look_up_nav_bar(name, html_attributes).tap do |bar|
|
|
20
|
+
look_up_nav_bar(name, html_attributes, options).tap do |bar|
|
|
21
21
|
block.bind(self).call(bar) if block_given?
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def look_up_nav_bar(name, html_attributes)
|
|
25
|
+
def look_up_nav_bar(name, html_attributes, options = {})
|
|
26
26
|
(nav_bars[name] ||= NavBar.new(name, html_attributes)).tap do |bar|
|
|
27
27
|
bar.html_attributes.merge!(html_attributes)
|
|
28
28
|
end
|
data/lib/xebec/nav_bar_helper.rb
CHANGED
|
@@ -31,8 +31,8 @@ module Xebec
|
|
|
31
31
|
# @see Xebec::HasNavBars#nav_bar
|
|
32
32
|
#
|
|
33
33
|
# @return [Xebec::NavBarRenderer]
|
|
34
|
-
def nav_bar(name = nil, html_attributes = {}, &block)
|
|
35
|
-
look_up_nav_bar_and_eval name, html_attributes, &block
|
|
34
|
+
def nav_bar(name = nil, html_attributes = {}, options = {}, &block)
|
|
35
|
+
look_up_nav_bar_and_eval name, html_attributes, options, &block
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
# Renders a navigation bar if and only if it contains any
|
|
@@ -63,10 +63,11 @@ EOS
|
|
|
63
63
|
|
|
64
64
|
# Override HasNavBars#look_up_nav_bar to replace with a
|
|
65
65
|
# renderer if necessary.
|
|
66
|
-
def look_up_nav_bar(name, html_attributes)
|
|
66
|
+
def look_up_nav_bar(name, html_attributes, options = {})
|
|
67
67
|
bar = super(name, html_attributes)
|
|
68
68
|
if bar.kind_of?(Xebec::NavBar)
|
|
69
|
-
|
|
69
|
+
renderer_class = options[:renderer_class] || Xebec::renderer_class
|
|
70
|
+
bar = nav_bars[bar.name] = renderer_class.new(bar, self)
|
|
70
71
|
end
|
|
71
72
|
bar
|
|
72
73
|
end
|
data/test/nav_bar_helper_test.rb
CHANGED
|
@@ -25,6 +25,18 @@ class NavBarHelperTest < Test::Unit::TestCase
|
|
|
25
25
|
Xebec::renderer_class = @old_renderer_class
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
|
+
|
|
29
|
+
should 'use a custom renderer class if one is passed in' do
|
|
30
|
+
begin
|
|
31
|
+
@old_renderer_class = Xebec::renderer_class
|
|
32
|
+
klass = Class.new do
|
|
33
|
+
def initialize(*args, &block); end;
|
|
34
|
+
end
|
|
35
|
+
assert @helper.nav_bar(nil, {}, :renderer_class => klass).kind_of?(klass)
|
|
36
|
+
ensure
|
|
37
|
+
Xebec::renderer_class = @old_renderer_class
|
|
38
|
+
end
|
|
39
|
+
end
|
|
28
40
|
|
|
29
41
|
should 'return a NavBar with the given name' do
|
|
30
42
|
assert_equal :snacks, @helper.nav_bar(:snacks).name
|
data/test/test_helper.rb
CHANGED
data/xebec.gemspec
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Generated by jeweler
|
|
2
|
-
# DO NOT EDIT THIS FILE
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{xebec}
|
|
8
|
-
s.version = "2.
|
|
8
|
+
s.version = "2.6.0"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["James A. Rosen"]
|
|
12
|
-
s.date = %q{2010-04
|
|
12
|
+
s.date = %q{2010-06-04}
|
|
13
13
|
s.description = %q{Helpers for generating navigation bars}
|
|
14
14
|
s.email = %q{james.a.rosen@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -104,3 +104,4 @@ Gem::Specification.new do |s|
|
|
|
104
104
|
s.add_dependency(%q<redgreen>, ["~> 1.2.2"])
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
|
+
|
metadata
CHANGED
|
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
|
4
4
|
prerelease: false
|
|
5
5
|
segments:
|
|
6
6
|
- 2
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
version: 2.
|
|
7
|
+
- 6
|
|
8
|
+
- 0
|
|
9
|
+
version: 2.6.0
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- James A. Rosen
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-04
|
|
17
|
+
date: 2010-06-04 00:00:00 -04:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|