tabs_on_rails 1.3.3 → 2.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +16 -8
- data/{LICENSE.rdoc → LICENSE} +3 -1
- data/README.rdoc +18 -43
- data/Rakefile +3 -3
- data/init.rb +1 -1
- data/lib/tabs_on_rails/{controller_mixin.rb → action_controller.rb} +4 -4
- data/lib/tabs_on_rails/railtie.rb +14 -20
- data/lib/tabs_on_rails/tabs.rb +6 -17
- data/lib/tabs_on_rails/version.rb +4 -4
- data/lib/tabs_on_rails.rb +2 -12
- data/tabs_on_rails.gemspec +12 -7
- data/test/{controller_mixin_test.rb → tabs_on_rails/controller_mixin_test.rb} +113 -117
- data/test/{tabs → tabs_on_rails/tabs}/builder_test.rb +0 -0
- data/test/{tabs → tabs_on_rails/tabs}/tabs_builder_test.rb +15 -16
- data/test/{tabs_test.rb → tabs_on_rails/tabs_test.rb} +1 -0
- data/test/test_helper.rb +22 -18
- data/test/{fixtures/mixin → views/working}/default.html.erb +1 -1
- data/test/{fixtures/mixin → views/working}/with_item_options.html.erb +1 -1
- data/test/views/working/with_open_close_tabs.html.erb +4 -0
- metadata +65 -17
- data/rails/init.rb +0 -20
- data/test/fixtures/mixin/with_open_close_tabs.html.erb +0 -4
data/CHANGELOG.rdoc
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
= Changelog
|
2
2
|
|
3
3
|
|
4
|
-
== Release
|
4
|
+
== Release 2.0.0.pre2
|
5
|
+
|
6
|
+
* FIXED: Fixed permission error (#8)
|
7
|
+
|
8
|
+
|
9
|
+
== Release 2.0.0.pre
|
10
|
+
|
11
|
+
* CHANGED: Dropped support for Rails 2.
|
12
|
+
|
13
|
+
* CHANGED: Remove "Incomplete `close_tabs' definition" warning. open_tabs/close_tabs can now have zero or more arguments.
|
5
14
|
|
6
|
-
* FIXED: Permission error (see http://stackoverflow.com/questions/5085174/rails-gem-permissions-problem-tabs-on-rails)
|
7
15
|
|
8
16
|
== Release 1.3.2
|
9
17
|
|
@@ -19,10 +27,10 @@
|
|
19
27
|
|
20
28
|
== Release 1.3.0
|
21
29
|
|
22
|
-
*
|
30
|
+
* NEW: Ability to customize the behavior and the style of the li tab item
|
23
31
|
passing a hash of options.
|
24
32
|
|
25
|
-
|
33
|
+
<%= tabs_tag do |tab| %>
|
26
34
|
<%= tab.home 'Homepage', root_path, :style => "padding: 10px" %>
|
27
35
|
<%= tab.dashboard 'Dashboard', dashboard_path %>
|
28
36
|
<% end %>
|
@@ -36,7 +44,7 @@
|
|
36
44
|
|
37
45
|
== Release 1.2.0
|
38
46
|
|
39
|
-
*
|
47
|
+
* NEW: Rails 3 compatibility.
|
40
48
|
|
41
49
|
* CHANGED: Simplified tabs_tag helper by moving the rendering logic into TabsOnRails::Tabs#render.
|
42
50
|
|
@@ -60,7 +68,7 @@
|
|
60
68
|
|
61
69
|
== Release 1.0.0
|
62
70
|
|
63
|
-
*
|
71
|
+
* NEW: Ability to pass arbitrary options to open_tabs and close_tags method. Thanks to aaronchi (closes #315)
|
64
72
|
|
65
73
|
* REMOVED: tabs_tag no longer accepts a Builder as first parameter. Removed deprecation warning.
|
66
74
|
|
@@ -96,7 +104,7 @@ First stable release.
|
|
96
104
|
|
97
105
|
== Release 0.3.0
|
98
106
|
|
99
|
-
*
|
107
|
+
* NEW: Support for namespaces in order to manage concurrent tab menus (closes #144).
|
100
108
|
|
101
109
|
* FIXED: `Uninitialized constant RAILS_DEFAULT_LOGGER (NameError)' error message when running tests outside a Rails environment.
|
102
110
|
|
@@ -109,7 +117,7 @@ First stable release.
|
|
109
117
|
|
110
118
|
== Release 0.2.0
|
111
119
|
|
112
|
-
*
|
120
|
+
* NEW: The README file is definitely more useful now, filled up with some basic documentation.
|
113
121
|
|
114
122
|
* CHANGED: Use the standard way to initialize a Rails plugin when packaged as a GEM (closes #146).
|
115
123
|
|
data/{LICENSE.rdoc → LICENSE}
RENAMED
data/README.rdoc
CHANGED
@@ -6,59 +6,33 @@ It provides helpers for generating navigation menus with a flexible interface.
|
|
6
6
|
|
7
7
|
== Requirements
|
8
8
|
|
9
|
-
* Ruby >= 1.8.6
|
10
|
-
* Rails >= 2.2
|
11
|
-
|
12
|
-
or
|
13
|
-
|
14
9
|
* Rails 3
|
15
10
|
|
16
|
-
|
17
|
-
(see {this comment}[http://www.simonecarletti.com/blog/2009/04/tabsonrails/#comment-2901]
|
18
|
-
and {this commit}[http://github.com/weppos/tabs_on_rails/commit/d5ae9f401e3d0acc87251fa8957a8625e90ba4b3]).
|
11
|
+
Please note
|
19
12
|
|
13
|
+
* TabsOnRails 2.x requires Rails 3. Use TabsOnRails 1.3.x with Rails 2.
|
14
|
+
* TabsOnRails doesn't work with Rails 2.1 or lower
|
15
|
+
("comment":http://www.simonecarletti.com/blog/2009/04/tabsonrails/#comment-2901 and "commit":http://github.com/weppos/tabs_on_rails/commit/d5ae9f401e3d0acc87251fa8957a8625e90ba4b3).
|
20
16
|
|
21
|
-
== Installation
|
22
17
|
|
23
|
-
|
18
|
+
== Installation
|
24
19
|
|
25
|
-
|
20
|
+
"RubyGems":http://rubygems.org is the preferred way to install *TabsOnRails* and the best way if you want install a stable version.
|
26
21
|
|
27
22
|
$ gem install tabs_on_rails
|
28
23
|
|
29
|
-
|
30
|
-
file so that Rails will automatically check the requirement on startup.
|
31
|
-
|
32
|
-
Rails::Initializer.run do |config|
|
33
|
-
|
34
|
-
# other configurations
|
35
|
-
# ...
|
36
|
-
|
37
|
-
config.gem "tabs_on_rails"
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
With Rails 3, specify the Gem dependency in the
|
42
|
-
{Bundler}[http://gembundler.com] Gemfile.
|
24
|
+
Specify the Gem dependency in the "Bundler":http://gembundler.com Gemfile.
|
43
25
|
|
44
26
|
gem "tabs_on_rails"
|
45
27
|
|
46
|
-
|
47
|
-
=== As a Plugin
|
48
|
-
|
49
|
-
$ script/plugin install git://github.com/weppos/tabs_on_rails.git
|
50
|
-
|
51
|
-
Warning: this method is deprecated and will be removed in a future version.
|
52
|
-
Use {Bundler}[http://gembundler.com]
|
53
|
-
and the {:git option}[http://gembundler.com/v1.0/git.html]
|
54
|
-
if you want to grab the latest version from the Git repository.
|
28
|
+
Use "Bundler":http://gembundler.com and the ":git option":http://gembundler.com/v1.0/git.html if you want to grab the latest version from the Git repository.
|
55
29
|
|
56
30
|
|
57
31
|
== Usage
|
58
32
|
|
59
33
|
In your template use the <tt>tabs_tag</tt> helper to create your tab.
|
60
34
|
|
61
|
-
|
35
|
+
<%= tabs_tag do |tab| %>
|
62
36
|
<%= tab.home 'Homepage', root_path %>
|
63
37
|
<%= tab.dashboard 'Dashboard', dashboard_path %>
|
64
38
|
<%= tab.account 'Account', account_path %>
|
@@ -107,7 +81,7 @@ You can pass a hash of options to customize the style and the behavior of the ta
|
|
107
81
|
Behind the scenes, each time you create a tab, the <tt>#tab_for</tt>
|
108
82
|
method is invoked.
|
109
83
|
|
110
|
-
|
84
|
+
<%= tabs_tag do |tab| %>
|
111
85
|
<%= tab.home 'Homepage', root_path, :style => "padding: 10px" %>
|
112
86
|
<%= tab.dashboard 'Dashboard', dashboard_path %>
|
113
87
|
<% end %>
|
@@ -124,7 +98,7 @@ See <tt>TabsOnRails::Tabs::TabsBuilder#tab_for</tt> for more details.
|
|
124
98
|
|
125
99
|
The open_tabs and the close_tabs methods can be customized with the <tt>:open_tabs</tt> and <tt>:close_tabs</tt> option.
|
126
100
|
|
127
|
-
|
101
|
+
<%= tabs_tag :open_tabs => { :id => "tabs", :class => "cool" } do |tab| %>
|
128
102
|
<%= tab.home 'Homepage', root_path %>
|
129
103
|
<%= tab.dashboard 'Dashboard', dashboard_path %>
|
130
104
|
<%= tab.account 'Account', account_path %>
|
@@ -190,12 +164,12 @@ Let's call it :navigation.
|
|
190
164
|
|
191
165
|
class ProjectsController
|
192
166
|
set_tab :projects
|
193
|
-
|
167
|
+
|
194
168
|
# Create an other tab navigation level
|
195
169
|
set_tab :first, :navigation, :only => %w(first)
|
196
170
|
set_tab :second, :navigation, :only => %w(second)
|
197
171
|
set_tab :third, :navigation, :only => %w(third)
|
198
|
-
|
172
|
+
|
199
173
|
def first; end
|
200
174
|
def second; end
|
201
175
|
def third; end
|
@@ -213,13 +187,13 @@ The default namespace is called :default. Passing :default as name is the same a
|
|
213
187
|
|
214
188
|
To switch namespace in your template, just pass the :namespace option to the <tt>tabs_tag</tt> helper method.
|
215
189
|
|
216
|
-
|
190
|
+
<%= tabs_tag do |tab| %>
|
217
191
|
<%= tab.home 'Homepage', root_path %>
|
218
192
|
<%= tab.dashboard 'Dashboard', dashboard_path %>
|
219
193
|
<%= tab.projects 'Projects', projects_path %>
|
220
194
|
<% end %>
|
221
195
|
|
222
|
-
|
196
|
+
<%= tabs_tag :namespace => :navigation do |tab| %>
|
223
197
|
<%= tab.first 'First', first_project_path %>
|
224
198
|
<%= tab.second 'Second', second_project_path %>
|
225
199
|
<%= tab.third 'Account', third_project_path %>
|
@@ -292,7 +266,7 @@ The following example creates a custom tab builder called <tt>MenuTabBuilder</tt
|
|
292
266
|
|
293
267
|
In your view, simply pass the builder class to the <tt>tabs_tag</tt> method.
|
294
268
|
|
295
|
-
|
269
|
+
<%= tabs_tag(:builder => MenuTabBuilder) do |tab| %>
|
296
270
|
<%= tab.home 'Homepage', root_path %>
|
297
271
|
<%= tab.dashboard, 'Dashboard', dashboard_path %>
|
298
272
|
<%= tab.account 'Account', account_path, :style => 'float: right;' %>
|
@@ -322,4 +296,5 @@ This is the final result.
|
|
322
296
|
|
323
297
|
== License
|
324
298
|
|
325
|
-
Copyright (c) 2009-
|
299
|
+
*TabsOnRails* is Copyright (c) 2009-2011 Simone Carletti.
|
300
|
+
This is Free Software distributed under the MIT license.
|
data/Rakefile
CHANGED
@@ -28,7 +28,6 @@ task :default => ["test"]
|
|
28
28
|
# http://rubygems.org/read/chapter/20
|
29
29
|
#
|
30
30
|
spec = Gem::Specification.new do |s|
|
31
|
-
|
32
31
|
s.name = PKG_NAME
|
33
32
|
s.version = PKG_VERSION
|
34
33
|
s.summary = "A simple Ruby on Rails plugin for creating and managing Tabs."
|
@@ -47,7 +46,7 @@ spec = Gem::Specification.new do |s|
|
|
47
46
|
s.rdoc_options = %w(--main README.rdoc)
|
48
47
|
|
49
48
|
# Add any extra files to include in the gem (like your README)
|
50
|
-
s.files = %w( Rakefile init.rb ) + Dir.glob("*.{rdoc,gemspec}") + Dir.glob("{test,lib,rails}/**/*")
|
49
|
+
s.files = %w( Rakefile LICENSE init.rb ) + Dir.glob("*.{rdoc,gemspec}") + Dir.glob("{test,lib,rails}/**/*")
|
51
50
|
s.require_paths = ["lib"]
|
52
51
|
|
53
52
|
# If you want to depend on other gems, add them here, along with any
|
@@ -56,6 +55,8 @@ spec = Gem::Specification.new do |s|
|
|
56
55
|
|
57
56
|
# If your tests use any gems, include them here
|
58
57
|
s.add_development_dependency("bundler")
|
58
|
+
s.add_development_dependency("rails", "~> 3.0.3")
|
59
|
+
s.add_development_dependency("mocha", "~> 0.9.10")
|
59
60
|
end
|
60
61
|
|
61
62
|
# This task actually builds the gem. We also regenerate a static
|
@@ -110,7 +111,6 @@ begin
|
|
110
111
|
end
|
111
112
|
rescue LoadError
|
112
113
|
task :clobber_rcov
|
113
|
-
puts "RCov is not available"
|
114
114
|
end
|
115
115
|
|
116
116
|
|
data/init.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'tabs_on_rails'
|
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
module TabsOnRails
|
18
18
|
|
19
|
-
module
|
19
|
+
module ActionController
|
20
20
|
|
21
21
|
def self.included(base)
|
22
22
|
base.extend ClassMethods
|
@@ -115,7 +115,7 @@ module TabsOnRails
|
|
115
115
|
|
116
116
|
# In your template use the <tt>tabs_tag</tt> helper to create your tab.
|
117
117
|
#
|
118
|
-
#
|
118
|
+
# <%= tabs_tag do |tab| %>
|
119
119
|
# <%= tab.home 'Homepage', root_path %>
|
120
120
|
# <%= tab.dashboard 'Dashboard', dashboard_path %>
|
121
121
|
# <%= tab.account 'Account', account_path %>
|
@@ -164,7 +164,7 @@ module TabsOnRails
|
|
164
164
|
# Behind the scenes, each time you create a tab, the <tt>#tab_for</tt>
|
165
165
|
# method is invoked.
|
166
166
|
#
|
167
|
-
#
|
167
|
+
# <%= tabs_tag do |tab| %>
|
168
168
|
# <%= tab.home 'Homepage', root_path, :style => "padding: 10px" %>
|
169
169
|
# <%= tab.dashboard 'Dashboard', dashboard_path %>
|
170
170
|
# <% end %>
|
@@ -187,7 +187,7 @@ module TabsOnRails
|
|
187
187
|
# The open_tabs and the close_tabs methods can be customized
|
188
188
|
# with the <tt>:open_tabs</tt> and <tt>:close_tabs</tt> option.
|
189
189
|
#
|
190
|
-
#
|
190
|
+
# <%= tabs_tag :open_tabs => { :id => "tabs", :class => "cool" } do |tab| %>
|
191
191
|
# <%= tab.home 'Homepage', root_path %>
|
192
192
|
# <%= tab.dashboard 'Dashboard', dashboard_path %>
|
193
193
|
# <%= tab.account 'Account', account_path %>
|
@@ -17,28 +17,22 @@
|
|
17
17
|
module TabsOnRails
|
18
18
|
|
19
19
|
if defined? Rails::Railtie
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
20
|
+
class Railtie < ::Rails::Railtie
|
21
|
+
# initializer "tabs_on_rails.initialize" do
|
22
|
+
# ActiveSupport.on_load :action_controller do
|
23
|
+
# ::ActionController::Base.send :include, TabsOnRails::ActionController
|
24
|
+
# end
|
25
|
+
# end
|
28
26
|
end
|
29
|
-
|
30
27
|
end
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
def self.rails_version
|
35
|
-
@@rails_version ||= Rails::VERSION::STRING rescue "2.2"
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.init
|
39
|
-
ActionController::Base.send :include, TabsOnRails::ControllerMixin
|
40
|
-
end
|
29
|
+
end
|
41
30
|
|
42
|
-
|
31
|
+
require "active_support"
|
32
|
+
require "action_controller"
|
43
33
|
|
44
|
-
|
34
|
+
# There should be a better way to do this!
|
35
|
+
# I can't rely on Railtie#initializer because TabsOnRails::ActionController
|
36
|
+
# provides class methods which should be available when the class
|
37
|
+
# is evaluated.
|
38
|
+
ActionController::Base.send :include, TabsOnRails::ActionController
|
data/lib/tabs_on_rails/tabs.rb
CHANGED
@@ -17,7 +17,6 @@
|
|
17
17
|
require 'tabs_on_rails/tabs/builder'
|
18
18
|
require 'tabs_on_rails/tabs/tabs_builder'
|
19
19
|
|
20
|
-
|
21
20
|
module TabsOnRails
|
22
21
|
|
23
22
|
class Tabs
|
@@ -27,15 +26,11 @@ module TabsOnRails
|
|
27
26
|
@builder = (options.delete(:builder) || TabsBuilder).new(@context, options)
|
28
27
|
@options = options
|
29
28
|
end
|
30
|
-
|
29
|
+
|
31
30
|
%w(open_tabs close_tabs).each do |name|
|
32
31
|
define_method(name) do |*args| # def open_tabs(*args)
|
33
32
|
method = @builder.method(name) # method = @builder.method(:open_tabs)
|
34
33
|
if method.arity.zero? # if method.arity.zero?
|
35
|
-
message = "Incomplete `#{name}' definition. " + # ...
|
36
|
-
"Use #{name}(*args) to ignore arguments " + # ...
|
37
|
-
"or #{name}(options) to collect options" # ...
|
38
|
-
ActiveSupport::Deprecation.warn(message) # ...
|
39
34
|
method.call # method.call
|
40
35
|
else # else
|
41
36
|
method.call(*args) # method.call(*args)
|
@@ -54,17 +49,11 @@ module TabsOnRails
|
|
54
49
|
open_tabs_options = options.delete(:open_tabs) || {}
|
55
50
|
close_tabs_options = options.delete(:close_tabs) || {}
|
56
51
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
"".tap do |html|
|
63
|
-
html << open_tabs(open_tabs_options).to_s
|
64
|
-
html << @context.capture(self, &block)
|
65
|
-
html << close_tabs(close_tabs_options).to_s
|
66
|
-
end.html_safe
|
67
|
-
end
|
52
|
+
"".tap do |html|
|
53
|
+
html << open_tabs(open_tabs_options).to_s
|
54
|
+
html << @context.capture(self, &block)
|
55
|
+
html << close_tabs(close_tabs_options).to_s
|
56
|
+
end.html_safe
|
68
57
|
end
|
69
58
|
|
70
59
|
end
|
@@ -18,10 +18,10 @@ module TabsOnRails
|
|
18
18
|
|
19
19
|
# Holds information about library version.
|
20
20
|
module Version
|
21
|
-
MAJOR =
|
22
|
-
MINOR =
|
23
|
-
PATCH =
|
24
|
-
BUILD =
|
21
|
+
MAJOR = 2
|
22
|
+
MINOR = 0
|
23
|
+
PATCH = 0
|
24
|
+
BUILD = "pre2"
|
25
25
|
|
26
26
|
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join(".")
|
27
27
|
end
|
data/lib/tabs_on_rails.rb
CHANGED
@@ -14,11 +14,10 @@
|
|
14
14
|
#++
|
15
15
|
|
16
16
|
|
17
|
-
require 'tabs_on_rails/controller_mixin'
|
18
17
|
require 'tabs_on_rails/tabs'
|
19
|
-
require 'tabs_on_rails/railtie'
|
20
18
|
require 'tabs_on_rails/version'
|
21
|
-
|
19
|
+
require 'tabs_on_rails/action_controller'
|
20
|
+
require 'tabs_on_rails/railtie'
|
22
21
|
|
23
22
|
module TabsOnRails
|
24
23
|
|
@@ -26,12 +25,3 @@ module TabsOnRails
|
|
26
25
|
GEM = "tabs_on_rails"
|
27
26
|
|
28
27
|
end
|
29
|
-
|
30
|
-
# Compatibility with Rails 2
|
31
|
-
unless "".respond_to?(:html_safe)
|
32
|
-
class String
|
33
|
-
def html_safe
|
34
|
-
self
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/tabs_on_rails.gemspec
CHANGED
@@ -2,32 +2,37 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{tabs_on_rails}
|
5
|
-
s.version = "
|
5
|
+
s.version = "2.0.0.pre"
|
6
6
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Simone Carletti"]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2011-01-30}
|
10
10
|
s.description = %q{ TabsOnRails is a simple Ruby on Rails plugin for creating and managing Tabs. It provides helpers for creating tabs with a flexible interface.
|
11
11
|
}
|
12
12
|
s.email = %q{weppos@weppos.net}
|
13
|
-
s.extra_rdoc_files = ["CHANGELOG.rdoc", "
|
14
|
-
s.files = ["Rakefile", "init.rb", "CHANGELOG.rdoc", "
|
13
|
+
s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc"]
|
14
|
+
s.files = ["Rakefile", "LICENSE", "init.rb", "CHANGELOG.rdoc", "README.rdoc", "tabs_on_rails.gemspec", "test/tabs_on_rails", "test/tabs_on_rails/controller_mixin_test.rb", "test/tabs_on_rails/tabs", "test/tabs_on_rails/tabs/builder_test.rb", "test/tabs_on_rails/tabs/tabs_builder_test.rb", "test/tabs_on_rails/tabs_test.rb", "test/test_helper.rb", "test/views", "test/views/working", "test/views/working/default.html.erb", "test/views/working/with_item_options.html.erb", "test/views/working/with_open_close_tabs.html.erb", "lib/tabs_on_rails", "lib/tabs_on_rails/action_controller.rb", "lib/tabs_on_rails/railtie.rb", "lib/tabs_on_rails/tabs", "lib/tabs_on_rails/tabs/builder.rb", "lib/tabs_on_rails/tabs/tabs_builder.rb", "lib/tabs_on_rails/tabs.rb", "lib/tabs_on_rails/version.rb", "lib/tabs_on_rails.rb"]
|
15
15
|
s.homepage = %q{http://www.simonecarletti.com/code/tabs_on_rails}
|
16
16
|
s.rdoc_options = ["--main", "README.rdoc"]
|
17
17
|
s.require_paths = ["lib"]
|
18
|
-
s.rubygems_version = %q{1.
|
18
|
+
s.rubygems_version = %q{1.4.2}
|
19
19
|
s.summary = %q{A simple Ruby on Rails plugin for creating and managing Tabs.}
|
20
20
|
|
21
21
|
if s.respond_to? :specification_version then
|
22
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
22
|
s.specification_version = 3
|
24
23
|
|
25
24
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
25
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
26
|
+
s.add_development_dependency(%q<rails>, ["~> 3.0.3"])
|
27
|
+
s.add_development_dependency(%q<mocha>, ["~> 0.9.10"])
|
27
28
|
else
|
28
29
|
s.add_dependency(%q<bundler>, [">= 0"])
|
30
|
+
s.add_dependency(%q<rails>, ["~> 3.0.3"])
|
31
|
+
s.add_dependency(%q<mocha>, ["~> 0.9.10"])
|
29
32
|
end
|
30
33
|
else
|
31
34
|
s.add_dependency(%q<bundler>, [">= 0"])
|
35
|
+
s.add_dependency(%q<rails>, ["~> 3.0.3"])
|
36
|
+
s.add_dependency(%q<mocha>, ["~> 0.9.10"])
|
32
37
|
end
|
33
38
|
end
|
@@ -1,18 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
|
6
|
-
class MixinController < ActionController::Base
|
7
|
-
end
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@controller = MixinController.new
|
11
|
-
@controller_proxy = ControllerProxy.new(@controller)
|
12
|
-
@request = ActionController::TestRequest.new
|
13
|
-
@response = ActionController::TestResponse.new
|
14
|
-
end
|
3
|
+
class MixinTestController < ActionController::Base
|
4
|
+
end
|
15
5
|
|
6
|
+
class MixinTest < ActionController::TestCase
|
7
|
+
tests MixinTestController
|
16
8
|
|
17
9
|
def test_set_tab
|
18
10
|
controller.set_tab :footab
|
@@ -90,121 +82,41 @@ class ControllerMixinTest < ActionController::TestCase
|
|
90
82
|
end
|
91
83
|
|
92
84
|
|
93
|
-
class
|
94
|
-
|
95
|
-
|
96
|
-
include ActionView::Helpers::UrlHelper
|
97
|
-
|
98
|
-
MockBuilder = Class.new(TabsOnRails::Tabs::Builder) do
|
99
|
-
def initialize_with_mocha(*args)
|
100
|
-
checkpoint
|
101
|
-
initialize_without_mocha(*args)
|
102
|
-
end
|
103
|
-
alias_method_chain :initialize, :mocha
|
104
|
-
|
105
|
-
def checkpoint
|
106
|
-
end
|
107
|
-
|
108
|
-
def tab_for(tab, name, *args)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
NilBoundariesBuilder = Class.new(TabsOnRails::Tabs::Builder) do
|
113
|
-
def tab_for(tab, name, *args)
|
114
|
-
@context.content_tag(:span, name)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
NilOpenBoundaryBuilder = Class.new(NilBoundariesBuilder) do
|
119
|
-
def close_tabs(options = {})
|
120
|
-
'<br />'
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
NilCloseBoundaryBuilder = Class.new(NilBoundariesBuilder) do
|
125
|
-
def open_tabs(options = {})
|
126
|
-
'<br />'
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
|
131
|
-
def test_tabs_tag_should_raise_local_jump_error_without_block
|
132
|
-
assert_raise(LocalJumpError) { tabs_tag }
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_tabs_tag_with_builder
|
136
|
-
MockBuilder.any_instance.expects(:checkpoint).once
|
137
|
-
tabs_tag(:builder => MockBuilder) {}
|
138
|
-
end
|
85
|
+
class WorkingMixinTestController < ActionController::Base
|
86
|
+
def self.controller_name; "working"; end
|
87
|
+
def self.controller_path; "working"; end
|
139
88
|
|
140
|
-
|
141
|
-
MockBuilder.any_instance.expects(:checkpoint).once
|
142
|
-
tabs_tag(:builder => MockBuilder, :namespace => :custom) do |tabs|
|
143
|
-
builder = tabs.instance_variable_get(:'@builder')
|
144
|
-
assert_equal(:custom, builder.instance_variable_get(:'@namespace'))
|
145
|
-
end
|
146
|
-
end
|
89
|
+
layout false
|
147
90
|
|
91
|
+
set_tab :dashboard
|
92
|
+
set_tab :welcome, :only => %w( action_welcome )
|
93
|
+
set_tab :dashboard, :only => %w( action_namespace )
|
94
|
+
set_tab :homepage, :namespace, :only => %w( action_namespace )
|
148
95
|
|
149
|
-
def
|
150
|
-
|
151
|
-
concat t.single('Single', '#')
|
152
|
-
end
|
153
|
-
|
154
|
-
assert_dom_equal '<span>Single</span>', content
|
96
|
+
def action_dashboard
|
97
|
+
execute("action_dashboard")
|
155
98
|
end
|
156
99
|
|
157
|
-
def
|
158
|
-
|
159
|
-
concat t.single('Single', '#')
|
160
|
-
end
|
161
|
-
|
162
|
-
assert_dom_equal '<span>Single</span><br />', content
|
100
|
+
def action_namespace
|
101
|
+
execute("action_namespace")
|
163
102
|
end
|
164
103
|
|
165
|
-
def
|
166
|
-
|
167
|
-
concat t.single('Single', '#')
|
168
|
-
end
|
169
|
-
|
170
|
-
assert_dom_equal '<br /><span>Single</span>', content
|
104
|
+
def action_welcome
|
105
|
+
execute("action_welcome")
|
171
106
|
end
|
172
107
|
|
173
|
-
|
108
|
+
private
|
174
109
|
|
175
|
-
|
176
|
-
|
177
|
-
include ControllerTestHelpers
|
178
|
-
|
179
|
-
class MixinController < ActionController::Base
|
180
|
-
def self.controller_name; "mixin"; end
|
181
|
-
def self.controller_path; "mixin"; end
|
182
|
-
|
183
|
-
layout false
|
184
|
-
|
185
|
-
set_tab :dashboard
|
186
|
-
set_tab :welcome, :only => %w(action_welcome)
|
187
|
-
set_tab :dashboard, :only => %w(action_namespace)
|
188
|
-
set_tab :homepage, :namespace, :only => %w(action_namespace)
|
189
|
-
|
190
|
-
def method_missing(method, *args)
|
191
|
-
if method =~ /^action_(.*)/
|
110
|
+
def execute(method)
|
111
|
+
if method.to_s =~ /^action_(.*)/
|
192
112
|
render :action => (params[:template] || 'default')
|
193
113
|
end
|
194
114
|
end
|
195
115
|
|
196
|
-
|
197
|
-
end
|
198
|
-
|
199
|
-
MixinController.view_paths = [ File.dirname(__FILE__) + "/fixtures/" ]
|
200
|
-
|
201
|
-
def setup
|
202
|
-
@controller = MixinController.new
|
203
|
-
@controller_proxy = ControllerProxy.new(@controller)
|
204
|
-
@request = ActionController::TestRequest.new
|
205
|
-
@response = ActionController::TestResponse.new
|
206
|
-
end
|
116
|
+
end
|
207
117
|
|
118
|
+
class WorkingMixinTest < ActionController::TestCase
|
119
|
+
tests WorkingMixinTestController
|
208
120
|
|
209
121
|
def test_render_default
|
210
122
|
get :action_dashboard
|
@@ -243,8 +155,8 @@ class ControllerMixinWithControllerTest < ActionController::TestCase
|
|
243
155
|
|
244
156
|
def test_set_tab_with_only_option
|
245
157
|
get :action_welcome
|
246
|
-
assert_equal
|
247
|
-
assert_equal
|
158
|
+
assert_equal :welcome, controller.current_tab
|
159
|
+
assert_equal :welcome, controller.current_tab(:default)
|
248
160
|
assert_dom_equal(%Q{<ul>
|
249
161
|
<li><a href="/d">Dashboard</a></li>
|
250
162
|
<li class="current"><span>Welcome</span></li>
|
@@ -253,9 +165,9 @@ class ControllerMixinWithControllerTest < ActionController::TestCase
|
|
253
165
|
|
254
166
|
def test_set_tab_with_namespace
|
255
167
|
get :action_namespace
|
256
|
-
assert_equal
|
257
|
-
assert_equal
|
258
|
-
assert_equal
|
168
|
+
assert_equal :dashboard, controller.current_tab
|
169
|
+
assert_equal :dashboard, controller.current_tab(:default)
|
170
|
+
assert_equal :homepage, controller.current_tab(:namespace)
|
259
171
|
assert_dom_equal(%Q{<ul>
|
260
172
|
<li class="current"><span>Dashboard</span></li>
|
261
173
|
<li><a href="/w">Welcome</a></li>
|
@@ -278,3 +190,87 @@ class ControllerMixinWithControllerTest < ActionController::TestCase
|
|
278
190
|
end
|
279
191
|
|
280
192
|
end
|
193
|
+
|
194
|
+
|
195
|
+
class ControllerMixinHelpersTest < ActionView::TestCase
|
196
|
+
tests TabsOnRails::ActionController::HelperMethods
|
197
|
+
include ActionView::Helpers::TagHelper
|
198
|
+
include ActionView::Helpers::UrlHelper
|
199
|
+
|
200
|
+
MockBuilder = Class.new(TabsOnRails::Tabs::Builder) do
|
201
|
+
def initialize_with_mocha(*args)
|
202
|
+
checkpoint
|
203
|
+
initialize_without_mocha(*args)
|
204
|
+
end
|
205
|
+
alias_method_chain :initialize, :mocha
|
206
|
+
|
207
|
+
def checkpoint
|
208
|
+
end
|
209
|
+
|
210
|
+
def tab_for(tab, name, *args)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
NilBoundariesBuilder = Class.new(TabsOnRails::Tabs::Builder) do
|
215
|
+
def tab_for(tab, name, *args)
|
216
|
+
@context.content_tag(:span, name)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
NilOpenBoundaryBuilder = Class.new(NilBoundariesBuilder) do
|
221
|
+
def close_tabs(options = {})
|
222
|
+
'<br />'
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
NilCloseBoundaryBuilder = Class.new(NilBoundariesBuilder) do
|
227
|
+
def open_tabs(options = {})
|
228
|
+
'<br />'
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
def test_tabs_tag_should_raise_local_jump_error_without_block
|
234
|
+
assert_raise(LocalJumpError) { tabs_tag }
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_tabs_tag_with_builder
|
238
|
+
MockBuilder.any_instance.expects(:checkpoint).once
|
239
|
+
tabs_tag(:builder => MockBuilder) { "" }
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_tabs_tag_with_namespace
|
243
|
+
MockBuilder.any_instance.expects(:checkpoint).once
|
244
|
+
tabs_tag(:builder => MockBuilder, :namespace => :custom) do |tabs|
|
245
|
+
builder = tabs.instance_variable_get(:'@builder')
|
246
|
+
assert_equal(:custom, builder.instance_variable_get(:'@namespace'))
|
247
|
+
""
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
|
252
|
+
def test_tabs_tag_should_not_concat_open_close_tabs_when_nil
|
253
|
+
content = tabs_tag(:builder => NilBoundariesBuilder) do |t|
|
254
|
+
concat t.single('Single', '#')
|
255
|
+
end
|
256
|
+
|
257
|
+
assert_dom_equal '<span>Single</span>', content
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_tabs_tag_should_not_concat_open_tabs_when_nil
|
261
|
+
content = tabs_tag(:builder => NilOpenBoundaryBuilder) do |t|
|
262
|
+
concat t.single('Single', '#')
|
263
|
+
end
|
264
|
+
|
265
|
+
assert_dom_equal '<span>Single</span><br />', content
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_tabs_tag_should_not_concat_close_tabs_when_nil
|
269
|
+
content = tabs_tag(:builder => NilCloseBoundaryBuilder) do |t|
|
270
|
+
concat t.single('Single', '#')
|
271
|
+
end
|
272
|
+
|
273
|
+
assert_dom_equal '<br /><span>Single</span>', content
|
274
|
+
end
|
275
|
+
|
276
|
+
end
|
File without changes
|
@@ -1,27 +1,26 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class TabsBuilderTest < ActionView::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
4
|
+
tests TabsOnRails::ActionController::HelperMethods
|
5
|
+
|
6
|
+
include ActionView::Helpers::TagHelper
|
7
|
+
include ActionView::Helpers::UrlHelper
|
8
|
+
|
9
|
+
def current_tab(namespace)
|
10
|
+
case namespace
|
11
|
+
when nil, :default
|
12
|
+
:dashboard
|
13
|
+
when :foospace
|
14
|
+
:footab
|
15
|
+
else
|
16
|
+
:elsetab
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
20
|
+
|
21
21
|
def setup
|
22
|
-
@template = Template.new
|
23
22
|
@klass = TabsOnRails::Tabs::TabsBuilder
|
24
|
-
@builder = @klass.new(
|
23
|
+
@builder = @klass.new(self)
|
25
24
|
end
|
26
25
|
|
27
26
|
def test_should_extend_builder
|
data/test/test_helper.rb
CHANGED
@@ -1,33 +1,37 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler'
|
3
|
-
Bundler.setup
|
4
|
-
|
3
|
+
Bundler.setup
|
5
4
|
|
6
5
|
require 'test/unit'
|
7
|
-
require '
|
8
|
-
|
9
|
-
|
6
|
+
require 'mocha'
|
7
|
+
|
8
|
+
ENV["RAILS_ENV"] = "test"
|
10
9
|
|
11
|
-
|
12
|
-
require
|
10
|
+
require "active_support"
|
11
|
+
require "action_controller"
|
12
|
+
require "rails/railtie"
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
15
|
+
require 'tabs_on_rails'
|
16
16
|
|
17
|
-
ActionController::Base.
|
18
|
-
ActionController::Routing::Routes.reload rescue nil
|
17
|
+
ActionController::Base.view_paths = File.join(File.dirname(__FILE__), 'views')
|
19
18
|
|
19
|
+
TabsOnRails::Routes = ActionDispatch::Routing::RouteSet.new
|
20
|
+
TabsOnRails::Routes.draw do
|
21
|
+
match ':controller(/:action(/:id))'
|
22
|
+
end
|
20
23
|
|
21
|
-
|
22
|
-
# See action_pack/test/abstract_unit for more details.
|
24
|
+
ActionController::Base.send :include, TabsOnRails::Routes.url_helpers
|
23
25
|
|
26
|
+
class ActiveSupport::TestCase
|
27
|
+
setup do
|
28
|
+
@routes = TabsOnRails::Routes
|
29
|
+
end
|
24
30
|
|
25
|
-
module ControllerTestHelpers
|
26
|
-
private
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
def controller
|
33
|
+
@controller_proxy ||= ControllerProxy.new(@controller)
|
34
|
+
end
|
31
35
|
|
32
36
|
class ControllerProxy
|
33
37
|
def initialize(controller)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
<%= tabs_tag(:open_tabs => { :id => "tabs" }, :close_tabs => { :class => "ignored" }) do |tabs| %>
|
2
2
|
<%= tabs.dashboard 'Dashboard', '/d', :class => "custom" %>
|
3
3
|
<%= tabs.welcome 'Welcome', '/w', :class => "custom" %>
|
4
4
|
<% end -%>
|
metadata
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabs_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
hash: 1923832045
|
5
|
+
prerelease: 6
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- pre
|
11
|
+
- 2
|
12
|
+
version: 2.0.0.pre2
|
6
13
|
platform: ruby
|
7
14
|
authors:
|
8
15
|
- Simone Carletti
|
@@ -10,7 +17,7 @@ autorequire:
|
|
10
17
|
bindir: bin
|
11
18
|
cert_chain: []
|
12
19
|
|
13
|
-
date: 2011-02-
|
20
|
+
date: 2011-02-03 00:00:00 +01:00
|
14
21
|
default_executable:
|
15
22
|
dependencies:
|
16
23
|
- !ruby/object:Gem::Dependency
|
@@ -21,9 +28,44 @@ dependencies:
|
|
21
28
|
requirements:
|
22
29
|
- - ">="
|
23
30
|
- !ruby/object:Gem::Version
|
31
|
+
hash: 3
|
32
|
+
segments:
|
33
|
+
- 0
|
24
34
|
version: "0"
|
25
35
|
type: :development
|
26
36
|
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rails
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 1
|
46
|
+
segments:
|
47
|
+
- 3
|
48
|
+
- 0
|
49
|
+
- 3
|
50
|
+
version: 3.0.3
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: mocha
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 47
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 9
|
65
|
+
- 10
|
66
|
+
version: 0.9.10
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
27
69
|
description: " TabsOnRails is a simple Ruby on Rails plugin for creating and managing Tabs. It provides helpers for creating tabs with a flexible interface.\n"
|
28
70
|
email: weppos@weppos.net
|
29
71
|
executables: []
|
@@ -32,31 +74,29 @@ extensions: []
|
|
32
74
|
|
33
75
|
extra_rdoc_files:
|
34
76
|
- CHANGELOG.rdoc
|
35
|
-
- LICENSE.rdoc
|
36
77
|
- README.rdoc
|
37
78
|
files:
|
38
79
|
- Rakefile
|
80
|
+
- LICENSE
|
39
81
|
- init.rb
|
40
82
|
- CHANGELOG.rdoc
|
41
|
-
- LICENSE.rdoc
|
42
83
|
- README.rdoc
|
43
84
|
- tabs_on_rails.gemspec
|
44
|
-
- test/controller_mixin_test.rb
|
45
|
-
- test/
|
46
|
-
- test/
|
47
|
-
- test/
|
48
|
-
- test/tabs/builder_test.rb
|
49
|
-
- test/tabs/tabs_builder_test.rb
|
50
|
-
- test/tabs_test.rb
|
85
|
+
- test/tabs_on_rails/controller_mixin_test.rb
|
86
|
+
- test/tabs_on_rails/tabs/builder_test.rb
|
87
|
+
- test/tabs_on_rails/tabs/tabs_builder_test.rb
|
88
|
+
- test/tabs_on_rails/tabs_test.rb
|
51
89
|
- test/test_helper.rb
|
52
|
-
-
|
90
|
+
- test/views/working/default.html.erb
|
91
|
+
- test/views/working/with_item_options.html.erb
|
92
|
+
- test/views/working/with_open_close_tabs.html.erb
|
93
|
+
- lib/tabs_on_rails/action_controller.rb
|
53
94
|
- lib/tabs_on_rails/railtie.rb
|
54
95
|
- lib/tabs_on_rails/tabs/builder.rb
|
55
96
|
- lib/tabs_on_rails/tabs/tabs_builder.rb
|
56
97
|
- lib/tabs_on_rails/tabs.rb
|
57
98
|
- lib/tabs_on_rails/version.rb
|
58
99
|
- lib/tabs_on_rails.rb
|
59
|
-
- rails/init.rb
|
60
100
|
has_rdoc: true
|
61
101
|
homepage: http://www.simonecarletti.com/code/tabs_on_rails
|
62
102
|
licenses: []
|
@@ -72,17 +112,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
112
|
requirements:
|
73
113
|
- - ">="
|
74
114
|
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
116
|
+
segments:
|
117
|
+
- 0
|
75
118
|
version: "0"
|
76
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
120
|
none: false
|
78
121
|
requirements:
|
79
|
-
- - "
|
122
|
+
- - ">"
|
80
123
|
- !ruby/object:Gem::Version
|
81
|
-
|
124
|
+
hash: 25
|
125
|
+
segments:
|
126
|
+
- 1
|
127
|
+
- 3
|
128
|
+
- 1
|
129
|
+
version: 1.3.1
|
82
130
|
requirements: []
|
83
131
|
|
84
132
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.
|
133
|
+
rubygems_version: 1.4.2
|
86
134
|
signing_key:
|
87
135
|
specification_version: 3
|
88
136
|
summary: A simple Ruby on Rails plugin for creating and managing Tabs.
|
data/rails/init.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# = Tabs on Rails
|
3
|
-
#
|
4
|
-
# A simple Ruby on Rails plugin for creating and managing Tabs.
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# Category:: Rails
|
8
|
-
# Package:: TabsOnRails
|
9
|
-
# Author:: Simone Carletti <weppos@weppos.net>
|
10
|
-
# License:: MIT License
|
11
|
-
#
|
12
|
-
#--
|
13
|
-
#
|
14
|
-
#++
|
15
|
-
|
16
|
-
|
17
|
-
require "tabs_on_rails"
|
18
|
-
|
19
|
-
|
20
|
-
TabsOnRails::Railtie.init
|