tab_menu 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,7 +17,7 @@ This will render:
17
17
 
18
18
  <pre>
19
19
  <ul class="user_menu tabbed">
20
- <li class="active"><a href="/account">Profile</a></li>
20
+ <li class="current"><a href="/account">Profile</a></li>
21
21
  <li><a href="/account/edit">Change Settings</li>
22
22
  </ul>
23
23
  </pre>
@@ -33,6 +33,16 @@ You can now set the current tab like so:
33
33
 
34
34
  note the active class is designated for the current url and that url helpers are allowed in the second argument
35
35
 
36
+ h2. Changing the Active Class
37
+
38
+ You can change the class name given to the current tab in an initializer:
39
+
40
+ <pre>
41
+ TabMenu.active_class = "active"
42
+ </pre>
43
+
44
+ To use tab_menu with Twitter Bootstrap, you should use "active" for this option.
45
+
36
46
  h2. TODO
37
47
 
38
48
  * Submenus
@@ -1 +1,12 @@
1
+ require "tab_menu/configuration"
1
2
  require "tab_menu/rails" if defined?(Rails)
3
+
4
+ module TabMenu
5
+ def self.configure(&block)
6
+ @configuration = TabMenu::Configuration.new(&block)
7
+ end
8
+
9
+ def self.configuration
10
+ @configuration ||= TabMenu::Configuration.new
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ module TabMenu
2
+ class Configuration
3
+ def initialize(&block)
4
+ @active_class = "current"
5
+ instance_eval(&block) if block_given?
6
+ end
7
+
8
+ def active_class
9
+ @active_class
10
+ end
11
+
12
+ def active_class=(css_class)
13
+ @active_class = css_class
14
+ end
15
+ end
16
+ end
@@ -12,12 +12,17 @@ module TabMenu
12
12
  def tab(name, url, li_html_options = {}, link_to_options = {})
13
13
  #append current to the contentli class attribute if its the current page
14
14
  if (!@current_tab.nil? && @current_tab.downcase == name.downcase) || (@current_tab.nil? && @controller.current_page?(url))
15
- li_html_options[:class] = [li_html_options[:class], "current"].join(" ").strip()
15
+ li_html_options[:class] = [li_html_options[:class], configuration.active_class].join(" ").strip()
16
16
  end
17
17
 
18
18
  content_tag(:li, name, li_html_options) do
19
19
  @controller.link_to name, url, link_to_options
20
20
  end
21
21
  end
22
+
23
+ protected
24
+ def configuration
25
+ TabMenu.configuration
26
+ end
22
27
  end
23
- end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module TabMenu
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe TabMenu::Configuration do
4
+ let(:configuration) { TabMenu::Configuration.new }
5
+ it "should default the active class to current" do
6
+ configuration.active_class.should eql("current")
7
+ end
8
+
9
+ it "allows me to change the active_class" do
10
+ configuration.active_class = "active"
11
+ configuration.active_class.should eql("active")
12
+ end
13
+ end
14
+
@@ -23,6 +23,9 @@ end
23
23
  describe TabMenu::TabBuilder do
24
24
  include TabMenu::ViewHelpers
25
25
 
26
+ before do
27
+ TabMenu.configure {}
28
+ end
26
29
  before(:each) do
27
30
  @controller = TabMenuController.new
28
31
  self.stub!(:current_page?).and_return(false)
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe TabMenu do
4
+ after do
5
+ TabMenu.configure {}
6
+ end
7
+ it "has a configuration object" do
8
+ TabMenu.configuration.should be_kind_of(TabMenu::Configuration)
9
+ end
10
+
11
+ it "allows me to configure with a block" do
12
+ TabMenu.configure do |config|
13
+ config.active_class = "active"
14
+ end
15
+
16
+ TabMenu.configuration.active_class.should eql("active")
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tab_menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-29 00:00:00.000000000Z
12
+ date: 2012-02-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &2153707040 !ruby/object:Gem::Requirement
16
+ requirement: &2156388360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153707040
24
+ version_requirements: *2156388360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: actionpack
27
- requirement: &2153705540 !ruby/object:Gem::Requirement
27
+ requirement: &2156387480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2153705540
35
+ version_requirements: *2156387480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2153704340 !ruby/object:Gem::Requirement
38
+ requirement: &2156386260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2153704340
46
+ version_requirements: *2156386260
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
- requirement: &2153703320 !ruby/object:Gem::Requirement
49
+ requirement: &2156384640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2153703320
57
+ version_requirements: *2156384640
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rails
60
- requirement: &2153702540 !ruby/object:Gem::Requirement
60
+ requirement: &2156383780 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2153702540
68
+ version_requirements: *2156383780
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
- requirement: &2153701740 !ruby/object:Gem::Requirement
71
+ requirement: &2156383100 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2153701740
79
+ version_requirements: *2156383100
80
80
  description: Rails Gem to generate tabs
81
81
  email:
82
82
  - dpickett@enlightsolutions.com
@@ -95,14 +95,17 @@ files:
95
95
  - init.rb
96
96
  - install.rb
97
97
  - lib/tab_menu.rb
98
+ - lib/tab_menu/configuration.rb
98
99
  - lib/tab_menu/rails.rb
99
100
  - lib/tab_menu/tab_builder.rb
100
101
  - lib/tab_menu/version.rb
101
102
  - lib/tab_menu/view_helpers.rb
102
103
  - spec/debug.log
103
104
  - spec/spec_helper.rb
105
+ - spec/tab_menu/configuration_spec.rb
104
106
  - spec/tab_menu/tab_builder_spec.rb
105
107
  - spec/tab_menu/view_helpers_spec.rb
108
+ - spec/tab_menu_spec.rb
106
109
  - tab_menu.gemspec
107
110
  - uninstall.rb
108
111
  homepage: ''
@@ -119,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
122
  version: '0'
120
123
  segments:
121
124
  - 0
122
- hash: -2696424801541203648
125
+ hash: 2614815561386698227
123
126
  required_rubygems_version: !ruby/object:Gem::Requirement
124
127
  none: false
125
128
  requirements:
@@ -128,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
131
  version: '0'
129
132
  segments:
130
133
  - 0
131
- hash: -2696424801541203648
134
+ hash: 2614815561386698227
132
135
  requirements: []
133
136
  rubyforge_project:
134
137
  rubygems_version: 1.8.6
@@ -138,5 +141,7 @@ summary: Rails Gem to generate tabs
138
141
  test_files:
139
142
  - spec/debug.log
140
143
  - spec/spec_helper.rb
144
+ - spec/tab_menu/configuration_spec.rb
141
145
  - spec/tab_menu/tab_builder_spec.rb
142
146
  - spec/tab_menu/view_helpers_spec.rb
147
+ - spec/tab_menu_spec.rb