simple-navigation 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/VERSION.yml +1 -1
- data/lib/simple_navigation.rb +8 -3
- data/simple-navigation.gemspec +2 -2
- data/spec/lib/simple_navigation_spec.rb +19 -7
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
*2.0.1
|
2
|
+
|
3
|
+
* fixed handling of a non-existent explicit navigation item for a navigation context
|
4
|
+
|
1
5
|
*2.0.0
|
2
6
|
|
3
7
|
* added auto_highlight feature. Active navigation is determined by comparing urls, no need to explicitly set it in the controllers anymore. Thanks to Jack Dempsey and Florian Hanke for the support on this.
|
data/VERSION.yml
CHANGED
data/lib/simple_navigation.rb
CHANGED
@@ -61,8 +61,13 @@ module SimpleNavigation
|
|
61
61
|
# the correct instance variable in the controller.
|
62
62
|
def handle_explicit_navigation
|
63
63
|
if SimpleNavigation.explicit_navigation_args
|
64
|
-
|
65
|
-
|
64
|
+
begin
|
65
|
+
level, navigation = parse_explicit_navigation_args
|
66
|
+
self.controller.instance_variable_set(:"@sn_current_navigation_#{level}", navigation)
|
67
|
+
rescue
|
68
|
+
#we do nothing here
|
69
|
+
#TODO: check if this is the right way to handle wrong explicit navigation
|
70
|
+
end
|
66
71
|
end
|
67
72
|
end
|
68
73
|
|
@@ -78,7 +83,7 @@ module SimpleNavigation
|
|
78
83
|
options = {}
|
79
84
|
if args.size == 1 #only an navi-key has been specified, try to find out level
|
80
85
|
level = SimpleNavigation.primary_navigation.level_for_item(args.first)
|
81
|
-
options[:"level_#{level}"] = args.first
|
86
|
+
options[:"level_#{level}"] = args.first if level
|
82
87
|
else
|
83
88
|
args.each_with_index {|arg, i| options[:"level_#{i + 1}"] = arg}
|
84
89
|
end
|
data/simple-navigation.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{simple-navigation}
|
8
|
-
s.version = "2.0.
|
8
|
+
s.version = "2.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andi Schacke"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-13}
|
13
13
|
s.description = %q{With the simple-navigation gem installed you can easily create multilevel navigations for your Ruby on Rails applications. The navigation is defined in a single configuration file. It supports automatic as well as explicit highlighting of the currently active navigation.}
|
14
14
|
s.email = %q{andreas.schacke@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -180,14 +180,26 @@ describe SimpleNavigation do
|
|
180
180
|
end
|
181
181
|
end
|
182
182
|
context 'single navigation' do
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
183
|
+
context 'specified key is a valid navigation item' do
|
184
|
+
before(:each) do
|
185
|
+
@primary = stub(:primary, :level_for_item => 2)
|
186
|
+
SimpleNavigation.stub!(:primary_navigation => @primary)
|
187
|
+
args :key
|
188
|
+
end
|
189
|
+
it "should set the correct instance var in the controller" do
|
190
|
+
@controller.should_receive(:instance_variable_set).with(:@sn_current_navigation_2, :key)
|
191
|
+
SimpleNavigation.handle_explicit_navigation
|
192
|
+
end
|
187
193
|
end
|
188
|
-
|
189
|
-
|
190
|
-
|
194
|
+
context 'specified key is an invalid navigation item' do
|
195
|
+
before(:each) do
|
196
|
+
@primary = stub(:primary, :level_for_item => nil)
|
197
|
+
SimpleNavigation.stub!(:primary_navigation => @primary)
|
198
|
+
args :key
|
199
|
+
end
|
200
|
+
it "should not raise an ArgumentError" do
|
201
|
+
lambda {SimpleNavigation.handle_explicit_navigation}.should_not raise_error(ArgumentError)
|
202
|
+
end
|
191
203
|
end
|
192
204
|
end
|
193
205
|
context 'hash with level' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-navigation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andi Schacke
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-13 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|