nav 0.4.1 → 0.5.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.
@@ -7,17 +7,32 @@ module Nav
7
7
  yield self if block_given?
8
8
  end
9
9
 
10
- def action( name, options = {}, html_options = {} )
11
- wrapper_options = {
12
- :current => html_options.delete(:current),
13
- :disabled => html_options.delete(:disabled),
14
- :force_current => html_options.delete(:force_current),
15
- :url => options,
16
- :prepend => html_options.delete(:prepend),
17
- :append => html_options.delete(:append)
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
- @actions << [link_to(name, options, html_options), wrapper_options, options]
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 == present
47
- classes << "last" if @actions.last == present
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
 
@@ -1,5 +1,5 @@
1
1
  module Nav
2
2
 
3
- VERSION = "0.4.1"
3
+ VERSION = "0.5.0"
4
4
 
5
5
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Nav::VERSION
8
8
  s.authors = ["Rudolf Schmidt"]
9
9
 
10
- s.homepage = ""
10
+ s.homepage = "http://rubygems.org/gems/nav"
11
11
  s.summary = %q{Simple nagivation builder}
12
12
  s.description = %q{Simple nagivation builder}
13
13
 
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.1
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-11-22 00:00:00.000000000Z
12
+ date: 2011-12-31 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
16
- requirement: &10030440 !ruby/object:Gem::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: *10030440
24
+ version_requirements: *23153860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rr
27
- requirement: &10029860 !ruby/object:Gem::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: *10029860
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: []