cells 3.9.0 → 3.9.1
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGES.textile +5 -0
- data/README.md +14 -1
- data/cells.gemspec +2 -1
- data/gemfiles/Gemfile.rails3-0 +1 -0
- data/gemfiles/Gemfile.rails3-1 +1 -0
- data/gemfiles/Gemfile.rails3-2 +1 -0
- data/gemfiles/Gemfile.rails4-0 +5 -2
- data/gemfiles/Gemfile.rails4-1 +10 -0
- data/lib/cell/base.rb +23 -13
- data/lib/cell/rails/view_model.rb +3 -3
- data/lib/cell/rails3_0_strategy.rb +11 -9
- data/lib/cell/rails3_1_strategy.rb +9 -7
- data/lib/cell/rails4_0_strategy.rb +9 -8
- data/lib/cell/rails4_1_strategy.rb +40 -0
- data/lib/cell/test_case.rb +10 -0
- data/lib/cells/engines.rb +13 -11
- data/lib/cells/version.rb +1 -1
- data/lib/generators/cells/base.rb +4 -2
- data/test/app/cells/bassist_cell.rb +9 -0
- data/test/cell_generator_test.rb +5 -0
- data/test/cell_module_test.rb +6 -1
- data/test/cells_module_test.rb +4 -4
- data/test/deprecations_test.rb +23 -17
- data/test/dummy/label/app/cells/label/show.erb +1 -0
- data/test/dummy/label/app/cells/label_cell.rb +5 -0
- data/test/dummy/label/label.gemspec +20 -0
- data/test/dummy/label/lib/label.rb +4 -0
- data/test/dummy/label/lib/label/version.rb +3 -0
- data/test/helper_test.rb +1 -1
- data/test/rails/caching_test.rb +1 -1
- data/test/rails/cells_test.rb +2 -2
- data/test/rails/integration_test.rb +12 -0
- data/test/rails/render_test.rb +42 -45
- data/test/rails/router_test.rb +29 -34
- data/test/rails/view_model_test.rb +6 -5
- data/test/rails/view_test.rb +4 -4
- data/test/test_case_test.rb +119 -113
- data/test/test_helper.rb +13 -1
- metadata +25 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f2a369ee523b519082124fc42f359172124f6e45
|
|
4
|
+
data.tar.gz: bc788476880fec68c6134ab8111f5ea62d519b26
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54a6bbc71fd9fadae7fd54a940bf1c160b9675e03eff6b2320f5dd4c590fc22229f692e6f7db77b06ed3c64ef09186cee732cbda52e7a6c55295a7c46dfea7c0
|
|
7
|
+
data.tar.gz: 2271f4d6188a31b7b2c64617fffaf83adc30c8c3cff7c18124072fb8aff1c03c5f3fb267b87cf313099eb5a70c21571bd35a5f324428c632ab7319a61bbd188a
|
data/.travis.yml
CHANGED
data/CHANGES.textile
CHANGED
data/README.md
CHANGED
|
@@ -367,10 +367,13 @@ Note that this currently "only" works with Rails 3.2-4.0.
|
|
|
367
367
|
|
|
368
368
|
Now `Rails::Engine`s can contribute to Cells view paths. By default, any 'app/cells' found inside any Engine is automatically included into Cells view paths. If you need to, you can customize the view paths changing/appending to the `'app/cell_views'` path configuration. See the `Cell::EngineIntegration` for more details.
|
|
369
369
|
|
|
370
|
-
|
|
370
|
+
|
|
371
|
+
## Generator Options
|
|
371
372
|
|
|
372
373
|
By default, generated cells inherit from `Cell::Rails`. If you want to change this, specify your new class name in `config/application.rb`:
|
|
373
374
|
|
|
375
|
+
### Base Class
|
|
376
|
+
|
|
374
377
|
```ruby
|
|
375
378
|
module MyApp
|
|
376
379
|
class Application < Rails::Application
|
|
@@ -381,6 +384,16 @@ module MyApp
|
|
|
381
384
|
end
|
|
382
385
|
```
|
|
383
386
|
|
|
387
|
+
### Base Path
|
|
388
|
+
|
|
389
|
+
You can configure the cells path in case your cells don't reside in `app/cells`.
|
|
390
|
+
|
|
391
|
+
```ruby
|
|
392
|
+
config.generators do |g|
|
|
393
|
+
g.base_cell_path "app/widgets"
|
|
394
|
+
end
|
|
395
|
+
```
|
|
396
|
+
|
|
384
397
|
## Rails 2.3 note
|
|
385
398
|
|
|
386
399
|
In order to copy the cells rake tasks to your app, run
|
data/cells.gemspec
CHANGED
|
@@ -26,5 +26,6 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
s.add_development_dependency "haml"
|
|
27
27
|
s.add_development_dependency "slim"
|
|
28
28
|
s.add_development_dependency "tzinfo" # FIXME: why the hell do we need this for 3.1?
|
|
29
|
-
s.add_development_dependency "minitest", "
|
|
29
|
+
s.add_development_dependency "minitest", ">= 4.7.5"
|
|
30
|
+
s.add_development_dependency "activemodel"
|
|
30
31
|
end
|
data/gemfiles/Gemfile.rails3-0
CHANGED
data/gemfiles/Gemfile.rails3-1
CHANGED
data/gemfiles/Gemfile.rails3-2
CHANGED
data/gemfiles/Gemfile.rails4-0
CHANGED
|
@@ -3,5 +3,8 @@ source "http://rubygems.org"
|
|
|
3
3
|
# Specify your gem's dependencies in cells.gemspec
|
|
4
4
|
gemspec path: '../'
|
|
5
5
|
|
|
6
|
-
gem 'railties', '4.0.
|
|
7
|
-
gem 'activemodel'
|
|
6
|
+
gem 'railties', '4.0.2'
|
|
7
|
+
gem 'activemodel', '4.0.2'
|
|
8
|
+
gem 'minitest', '4.7.5'
|
|
9
|
+
|
|
10
|
+
gem 'label', :path => "../test/dummy/label"
|
data/lib/cell/base.rb
CHANGED
|
@@ -5,21 +5,29 @@ require 'cell/rendering'
|
|
|
5
5
|
require 'cell/dsl'
|
|
6
6
|
|
|
7
7
|
module Cell
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
module RailsVersion
|
|
9
|
+
def rails3_0?
|
|
10
|
+
::ActionPack::VERSION::MAJOR == 3 and ::ActionPack::VERSION::MINOR == 0
|
|
11
|
+
end
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
def rails3_1_or_more?
|
|
14
|
+
(::ActionPack::VERSION::MAJOR == 3 and ::ActionPack::VERSION::MINOR >= 1)
|
|
15
|
+
end
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
def rails3_2_or_more?
|
|
18
|
+
(::ActionPack::VERSION::MAJOR == 3 and ::ActionPack::VERSION::MINOR >= 2)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def rails4_0?
|
|
22
|
+
::ActionPack::VERSION::MAJOR == 4 and ::ActionPack::VERSION::MINOR == 0
|
|
23
|
+
end
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
def rails4_1_or_more?
|
|
26
|
+
(::ActionPack::VERSION::MAJOR == 4 and ::ActionPack::VERSION::MINOR >= 1) or ::ActionPack::VERSION::MAJOR > 4
|
|
27
|
+
end
|
|
28
|
+
alias_method :rails4_1?, :rails4_1_or_more?
|
|
22
29
|
end
|
|
30
|
+
extend RailsVersion # TODO: deprecate in 3.10.
|
|
23
31
|
|
|
24
32
|
|
|
25
33
|
class Base < AbstractController::Base
|
|
@@ -30,12 +38,14 @@ module Cell
|
|
|
30
38
|
|
|
31
39
|
extend Builder
|
|
32
40
|
include AbstractController
|
|
33
|
-
include AbstractController::Rendering,
|
|
41
|
+
include AbstractController::Rendering, Helpers, Callbacks, Translation, Logger
|
|
34
42
|
|
|
35
43
|
require 'cell/rails3_0_strategy' if Cell.rails3_0?
|
|
36
44
|
require 'cell/rails3_1_strategy' if Cell.rails3_1_or_more?
|
|
37
|
-
require 'cell/rails4_0_strategy' if Cell.
|
|
45
|
+
require 'cell/rails4_0_strategy' if Cell.rails4_0?
|
|
46
|
+
require 'cell/rails4_1_strategy' if Cell.rails4_1_or_more?
|
|
38
47
|
include VersionStrategy
|
|
48
|
+
include Layouts
|
|
39
49
|
include Rendering
|
|
40
50
|
include Caching
|
|
41
51
|
include Cell::DSL
|
|
@@ -12,8 +12,8 @@ class Cell::Rails
|
|
|
12
12
|
attr_reader :model
|
|
13
13
|
|
|
14
14
|
module ClassMethods
|
|
15
|
-
def property(
|
|
16
|
-
delegate
|
|
15
|
+
def property(*names)
|
|
16
|
+
delegate *names, :to => :model
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
extend ActiveSupport::Concern
|
|
@@ -106,7 +106,7 @@ class Cell::Rails
|
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
# FIXME: fix that in rails core.
|
|
109
|
-
if Cell.
|
|
109
|
+
if Cell.rails4_0?
|
|
110
110
|
include LinkToHelper
|
|
111
111
|
else
|
|
112
112
|
include ActionView::Helpers::UrlHelper
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
# This file contains VersionStrategies for the Cell and Cells module for Rails 3.0.
|
|
2
2
|
module Cell
|
|
3
|
+
Layouts = AbstractController::Layouts
|
|
4
|
+
|
|
3
5
|
# Methods to be included in Cell::Rails in 3.0 context, where there's no view inheritance.
|
|
4
6
|
module VersionStrategy
|
|
5
7
|
extend ActiveSupport::Concern
|
|
6
|
-
|
|
8
|
+
|
|
7
9
|
class MissingTemplate < ActionView::ActionViewError
|
|
8
10
|
def initialize(message, possible_paths)
|
|
9
11
|
super(message + " and possible paths #{possible_paths}")
|
|
10
12
|
end
|
|
11
13
|
end
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
|
|
14
16
|
module ClassMethods
|
|
15
17
|
def helper_modules
|
|
16
18
|
[_helpers, _routes.url_helpers]
|
|
17
19
|
end
|
|
18
|
-
|
|
20
|
+
|
|
19
21
|
# Return the default view path for +state+. Override this if you cell has a differing naming style.
|
|
20
22
|
def view_for_state(state)
|
|
21
23
|
"#{cell_name}/#{state}"
|
|
@@ -33,13 +35,13 @@ module Cell
|
|
|
33
35
|
controller_path
|
|
34
36
|
end
|
|
35
37
|
end
|
|
36
|
-
|
|
38
|
+
|
|
37
39
|
private
|
|
38
40
|
# Computes all possible paths for +state+ by traversing up the inheritance chain.
|
|
39
41
|
def possible_paths_for_state(state)
|
|
40
42
|
self.class.find_class_view_for_state(state).reverse!
|
|
41
43
|
end
|
|
42
|
-
|
|
44
|
+
|
|
43
45
|
# Climbs up the inheritance chain, looking for a view for the current +state+.
|
|
44
46
|
def find_family_view_for_state(state)
|
|
45
47
|
exception = nil
|
|
@@ -55,10 +57,10 @@ module Cell
|
|
|
55
57
|
|
|
56
58
|
raise MissingTemplate.new(exception.message, possible_paths)
|
|
57
59
|
end
|
|
58
|
-
|
|
60
|
+
|
|
59
61
|
def process_opts_for(opts, state)
|
|
60
62
|
lookup_context.formats = opts.delete(:format) if opts[:format]
|
|
61
|
-
|
|
63
|
+
|
|
62
64
|
opts[:template] = find_family_view_for_state(opts.delete(:view) || state)
|
|
63
65
|
end
|
|
64
66
|
end
|
|
@@ -71,7 +73,7 @@ module Cells
|
|
|
71
73
|
def registered_engines
|
|
72
74
|
::Rails.application.railties.engines
|
|
73
75
|
end
|
|
74
|
-
|
|
76
|
+
|
|
75
77
|
def existent_directories_for(path)
|
|
76
78
|
path.to_a.select { |d| File.directory?(d) }
|
|
77
79
|
end
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
# This file contains VersionStrategies for the Cell and Cells module for Rails >= 3.1.
|
|
2
2
|
module Cell
|
|
3
|
+
Layouts = AbstractController::Layouts
|
|
4
|
+
|
|
3
5
|
# Methods to be included in Cell::Rails in 3.1 context.
|
|
4
6
|
module VersionStrategy
|
|
5
7
|
extend ActiveSupport::Concern
|
|
6
|
-
|
|
8
|
+
|
|
7
9
|
include AbstractController::UrlFor # must be included before _routes is set in Railstie. # TODO: remove that.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
|
|
10
12
|
module ClassMethods
|
|
11
13
|
def helper_modules
|
|
12
14
|
[_routes.url_helpers, _routes.mounted_helpers, _helpers]
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
+
|
|
18
|
+
private
|
|
17
19
|
def process_opts_for(opts, state)
|
|
18
20
|
opts[:action] = opts[:view] || state
|
|
19
|
-
|
|
21
|
+
|
|
20
22
|
lookup_context.formats = [opts.delete(:format)] if opts[:format]
|
|
21
23
|
end
|
|
22
24
|
end
|
|
@@ -29,7 +31,7 @@ module Cells
|
|
|
29
31
|
def registered_engines
|
|
30
32
|
::Rails.application.railties.engines
|
|
31
33
|
end
|
|
32
|
-
|
|
34
|
+
|
|
33
35
|
def existent_directories_for(path)
|
|
34
36
|
path.existent_directories
|
|
35
37
|
end
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
# This file contains VersionStrategies for the Cell and Cells module for Rails >= 3.1.
|
|
2
1
|
module Cell
|
|
2
|
+
Layouts = AbstractController::Layouts
|
|
3
|
+
|
|
3
4
|
# Methods to be included in Cell::Rails in 3.1 context.
|
|
4
5
|
module VersionStrategy
|
|
5
6
|
extend ActiveSupport::Concern
|
|
6
|
-
|
|
7
|
+
|
|
7
8
|
include AbstractController::UrlFor # must be included before _routes is set in Railstie. # TODO: remove that.
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
|
|
10
11
|
module ClassMethods
|
|
11
12
|
def helper_modules
|
|
12
13
|
[_routes.url_helpers, _routes.mounted_helpers, _helpers]
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
|
-
|
|
16
|
-
private
|
|
16
|
+
|
|
17
|
+
private
|
|
17
18
|
def process_opts_for(opts, state)
|
|
18
19
|
opts[:action] = opts[:view] || state
|
|
19
|
-
|
|
20
|
+
|
|
20
21
|
lookup_context.formats = [opts.delete(:format)] if opts[:format]
|
|
21
22
|
end
|
|
22
23
|
end
|
|
@@ -29,7 +30,7 @@ module Cells
|
|
|
29
30
|
def registered_engines
|
|
30
31
|
::Rails::Engine::Railties.engines
|
|
31
32
|
end
|
|
32
|
-
|
|
33
|
+
|
|
33
34
|
def existent_directories_for(path)
|
|
34
35
|
path.existent_directories
|
|
35
36
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# This file contains VersionStrategies for the Cell and Cells module for Rails >= 3.1.
|
|
2
|
+
module Cell
|
|
3
|
+
Layouts = ActionView::Layouts
|
|
4
|
+
|
|
5
|
+
# Methods to be included in Cell::Rails in 3.1 context.
|
|
6
|
+
module VersionStrategy
|
|
7
|
+
extend ActiveSupport::Concern
|
|
8
|
+
|
|
9
|
+
include AbstractController::UrlFor # must be included before _routes is set in Railstie. # TODO: remove that.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
module ClassMethods
|
|
13
|
+
def helper_modules
|
|
14
|
+
[_routes.url_helpers, _routes.mounted_helpers, _helpers]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
def process_opts_for(opts, state)
|
|
20
|
+
opts[:action] = opts[:view] || state
|
|
21
|
+
|
|
22
|
+
lookup_context.formats = [opts.delete(:format)] if opts[:format]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
module Cells
|
|
29
|
+
module Engines
|
|
30
|
+
module VersionStrategy
|
|
31
|
+
def registered_engines
|
|
32
|
+
::Rails::Engine::Railties.new
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def existent_directories_for(path)
|
|
36
|
+
path.existent_directories
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/cell/test_case.rb
CHANGED
|
@@ -149,5 +149,15 @@ module Cell
|
|
|
149
149
|
def invoke(state, *args)
|
|
150
150
|
@last_invoke = self.class.controller_class.new(@controller).render_state(state, *args)
|
|
151
151
|
end
|
|
152
|
+
|
|
153
|
+
if Cell.rails4_0? or Cell.rails4_1?
|
|
154
|
+
include ActiveSupport::Testing::ConstantLookup
|
|
155
|
+
def self.determine_default_controller_class(name) # FIXME: fix that in Rails 4.x.
|
|
156
|
+
determine_constant_from_test_name(name) do |constant|
|
|
157
|
+
Class === constant #&& constant < ActionController::Metal
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
152
162
|
end
|
|
153
163
|
end
|
data/lib/cells/engines.rb
CHANGED
|
@@ -3,38 +3,38 @@ module Cells
|
|
|
3
3
|
# By default, any 'app/cells' found inside any Engine is automatically included into Cells view paths.
|
|
4
4
|
#
|
|
5
5
|
# You can customize the view paths changing/appending to the <tt>'app/cell_views'</tt> path configuration:
|
|
6
|
-
#
|
|
6
|
+
#
|
|
7
7
|
# module MyAwesome
|
|
8
8
|
# class Engine < Rails::Engine
|
|
9
9
|
# # loads views from 'cell/views' and NOT from 'app/cells'
|
|
10
10
|
# config.paths.add 'app/cell_views', :with => 'cell/views'
|
|
11
|
-
#
|
|
11
|
+
#
|
|
12
12
|
# # appends 'lib/my_cells_view_path' to this Railtie view path contribution
|
|
13
13
|
# config.paths['app/cell_views'] << 'lib/my_cells_view_path'
|
|
14
14
|
# end
|
|
15
15
|
# end
|
|
16
|
-
#
|
|
16
|
+
#
|
|
17
17
|
# You can manually specify which Engines will be added to Cell view paths
|
|
18
|
-
#
|
|
18
|
+
#
|
|
19
19
|
# Cell::Base.config.view_path_engines = [MyAwesome::Engine]
|
|
20
|
-
#
|
|
20
|
+
#
|
|
21
21
|
# And even disable the automatic loading
|
|
22
|
-
#
|
|
22
|
+
#
|
|
23
23
|
# Cell::Base.config.view_path_engines = false
|
|
24
|
-
#
|
|
24
|
+
#
|
|
25
25
|
# You can programatically append a Rails::Engine to Cell view path
|
|
26
|
-
#
|
|
26
|
+
#
|
|
27
27
|
# Cells.setup do |config|
|
|
28
28
|
# config.append_engine_view_path!(MyEngine::Engine)
|
|
29
29
|
# end
|
|
30
30
|
#
|
|
31
31
|
module Engines
|
|
32
32
|
extend VersionStrategy # adds #registered_engines and #existent_directories_for.
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
# Appends all <tt>Rails::Engine</tt>s cell-views path to Cell::Base#view_paths
|
|
35
|
-
#
|
|
35
|
+
#
|
|
36
36
|
# All <tt>Rails::Engine</tt>s specified at <tt>config.view_path_engines</tt> will have its cell-views path appended to Cell::Base#view_paths
|
|
37
|
-
#
|
|
37
|
+
#
|
|
38
38
|
# Defaults <tt>config.view_path_engines</tt> to all loaded <tt>Rails::Engine</tt>s.
|
|
39
39
|
#
|
|
40
40
|
def self.append_engines_view_paths_for(config)
|
|
@@ -52,6 +52,8 @@ module Cells
|
|
|
52
52
|
# Defaults <tt>paths['app/cell_views']</tt> to 'app/cells'
|
|
53
53
|
#
|
|
54
54
|
def self.append_engine_view_path!(engine)
|
|
55
|
+
return unless engine.is_a?(::Rails::Engine) # In Rails 4.1, this could be a Rails::Railtie, which doesn't make sense.
|
|
56
|
+
|
|
55
57
|
engine.paths['app/cell_views'] || engine.paths.add('app/cell_views', :with => 'app/cells')
|
|
56
58
|
Cell::Rails.append_view_path(existent_directories_for(engine.paths["app/cell_views"]))
|
|
57
59
|
end
|