nav 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nav/builder.rb +30 -13
- data/lib/nav/version.rb +1 -1
- data/nav.gemspec +1 -1
- metadata +7 -7
data/lib/nav/builder.rb
CHANGED
@@ -7,17 +7,32 @@ module Nav
|
|
7
7
|
yield self if block_given?
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
# @example A basic action
|
11
|
+
# action "Home", home_url
|
12
|
+
# action "Tome, home_url, :current => true
|
13
|
+
#
|
14
|
+
# @example Given a block
|
15
|
+
# action do
|
16
|
+
# content_tag :span, "A simple text""
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# action :current => true do
|
20
|
+
# content_tag :span, "A simple text""
|
21
|
+
# end
|
22
|
+
def action( name = nil, options = {}, html_options = {} )
|
23
|
+
@actions << if block_given?
|
24
|
+
[ yield, name || {}, {} ]
|
25
|
+
else
|
26
|
+
wrapper_options = {
|
27
|
+
:current => html_options.delete(:current),
|
28
|
+
:disabled => html_options.delete(:disabled),
|
29
|
+
:force_current => html_options.delete(:force_current),
|
30
|
+
:prepend => html_options.delete(:prepend),
|
31
|
+
:append => html_options.delete(:append)
|
32
|
+
}
|
19
33
|
|
20
|
-
|
34
|
+
[ link_to(name, options, html_options), wrapper_options, options ]
|
35
|
+
end
|
21
36
|
end
|
22
37
|
|
23
38
|
def to_s
|
@@ -43,13 +58,15 @@ module Nav
|
|
43
58
|
after_present = @actions.at( present_index + 1 ) if present_index < @actions.size
|
44
59
|
|
45
60
|
classes = []
|
46
|
-
classes << "first" if @actions.first
|
47
|
-
classes << "
|
61
|
+
classes << "first" if present == @actions.first
|
62
|
+
classes << "after_first" if present_index == 1
|
63
|
+
classes << "before_last" if present == @actions[-2]
|
64
|
+
classes << "last" if present == @actions.last
|
48
65
|
classes << "current" if current?( *present )
|
49
66
|
classes << "disabled" if options.delete(:disabled)
|
50
67
|
classes << "before_current" if after_present && current?( *after_present )
|
51
68
|
classes << "after_current" if before_present && current?( *before_present )
|
52
|
-
classes << classes.join("_") if classes.any?
|
69
|
+
# classes << classes.join("_") if classes.any?
|
53
70
|
|
54
71
|
contents = options[:prepend].to_s + contents + options[:append].to_s
|
55
72
|
|
data/lib/nav/version.rb
CHANGED
data/nav.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-31 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
16
|
-
requirement: &
|
16
|
+
requirement: &23153860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *23153860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rr
|
27
|
-
requirement: &
|
27
|
+
requirement: &23153120 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *23153120
|
36
36
|
description: Simple nagivation builder
|
37
37
|
email:
|
38
38
|
executables: []
|
@@ -50,7 +50,7 @@ files:
|
|
50
50
|
- nav.gemspec
|
51
51
|
- test/nav_test.rb
|
52
52
|
- test/test_helper.rb
|
53
|
-
homepage:
|
53
|
+
homepage: http://rubygems.org/gems/nav
|
54
54
|
licenses: []
|
55
55
|
post_install_message:
|
56
56
|
rdoc_options: []
|