nav 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/nav/builder.rb CHANGED
@@ -3,7 +3,7 @@ module Nav
3
3
  def initialize( template, options = {} )
4
4
  @template, @options = template, options
5
5
  @actions = []
6
-
6
+
7
7
  yield self if block_given?
8
8
  end
9
9
 
@@ -26,11 +26,8 @@ module Nav
26
26
  wrapper_options = {
27
27
  :current => html_options.delete(:current),
28
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
29
  }
33
-
30
+
34
31
  [ link_to(name, options, html_options), wrapper_options, options ]
35
32
  end
36
33
  end
@@ -53,29 +50,27 @@ module Nav
53
50
  def action_wrapper( contents, options = {}, url_for_options = {} )
54
51
  present = [contents, options, url_for_options] # the one we're dealing with
55
52
  present_index = @actions.index( present )
56
-
53
+
57
54
  before_present = @actions.at( present_index - 1 ) if present_index > 0
58
55
  after_present = @actions.at( present_index + 1 ) if present_index < @actions.size
59
56
 
60
57
  classes = []
58
+ classes << options[:class] if options.key?(:class)
61
59
  classes << "first" if present == @actions.first
62
60
  classes << "after_first" if present_index == 1
63
61
  classes << "before_last" if present == @actions[-2]
64
62
  classes << "last" if present == @actions.last
65
63
  classes << "current" if current?( *present )
66
- classes << "disabled" if options.delete(:disabled)
64
+ classes << "disabled" if options[:disabled]
67
65
  classes << "before_current" if after_present && current?( *after_present )
68
66
  classes << "after_current" if before_present && current?( *before_present )
69
- # classes << classes.join("_") if classes.any?
70
-
71
- contents = options[:prepend].to_s + contents + options[:append].to_s
72
67
 
73
68
  content_tag :li, contents.html_safe, :class => classes.join(" ")
74
69
  end
75
70
 
76
71
  def current?( contents, options = {}, url_for_options = {} )
77
72
  current = options[:current]
78
-
73
+
79
74
  is_current = case current
80
75
  when TrueClass then true
81
76
  when Regexp then request_uri.match(current).nil? ? false : true
@@ -83,7 +78,7 @@ module Nav
83
78
  else false
84
79
  end
85
80
 
86
- return true if is_current && !options[:disabled] && options[:force_current]
81
+ return true if is_current && !options[:disabled]
87
82
  return true if is_current || !url_for_options.is_a?(Symbol) && @template.current_page?(url_for_options) && url_for_options != {} && !options[:disabled]
88
83
 
89
84
  false
data/lib/nav/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Nav
2
2
 
3
- VERSION = "0.6.0"
4
-
3
+ VERSION = "0.7.0"
4
+
5
5
  end
data/lib/nav.rb CHANGED
@@ -3,7 +3,7 @@ module Nav
3
3
  autoload :Builder, File.dirname(__FILE__) + '/nav/builder'
4
4
 
5
5
  def nav( options = {}, &block )
6
- Nav::Builder.new( self, options, &block )
6
+ Nav::Builder.new( self, options, &block ).to_s
7
7
  end
8
8
 
9
9
  end
data/test/nav_test.rb CHANGED
@@ -1,13 +1,7 @@
1
1
  require_relative 'test_helper'
2
- puts 'awesome'
3
2
 
4
3
  describe Nav do
5
4
 
6
- # <ul id="nav">
7
- # <li class="">before <a href="/">test</a></li>
8
- # <li class="">before <a href="#" onclick="new Ajax.Request('/', {asynchronous:true, evalScripts:true, parameters:'authenticity_token=' + encodeURIComponent('7016ef6fd7413d836cd720a6071e22e4f14e0212')}); return false;">test</a></li>
9
- # </ul>
10
-
11
5
  before do
12
6
  @view = ActionView::Base.new
13
7
  @view.output_buffer = ''
@@ -30,14 +24,5 @@ describe Nav do
30
24
  assert_match(/<a.*href=\"\/link\">my-link<\/a>/, m)
31
25
  end
32
26
 
33
- it "should display :prepend options before the link" do
34
- m = @view.nav { |m| m.action('my-link', '/link', :prepend => 'something before') }
35
- assert_match(/<li.*>something before<a/, m)
36
- end
37
-
38
- it "should display :append options after the link" do
39
- m = @view.nav { |m| m.action('my-link', '/link', :append => 'something after') }
40
- assert_match(/<\/a>something after<\/li>/, m)
41
- end
42
-
27
+ # TODO: Add test cases for actions with blocks
43
28
  end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
+ require 'rubygems'
1
2
  require 'minitest/autorun'
2
3
 
3
-
4
4
  begin
5
5
  require 'action_view'
6
6
  require 'rr'
@@ -13,5 +13,5 @@ end
13
13
 
14
14
  class MiniTest::Unit::TestCase
15
15
  include RR::Adapters::TestUnit
16
-
16
+
17
17
  end
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.6.0
4
+ version: 0.7.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: 2012-02-27 00:00:00.000000000 Z
12
+ date: 2012-02-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
16
- requirement: &70123352610920 !ruby/object:Gem::Requirement
16
+ requirement: &70286083358500 !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: *70123352610920
24
+ version_requirements: *70286083358500
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rr
27
- requirement: &70123352610360 !ruby/object:Gem::Requirement
27
+ requirement: &70286083357760 !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: *70123352610360
35
+ version_requirements: *70286083357760
36
36
  description: Simple nagivation builder
37
37
  email:
38
38
  executables: []