cells 4.0.5 → 4.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -14
- data/CHANGES.md +34 -7
- data/Gemfile +2 -2
- data/README.md +18 -88
- data/benchmarks/class_builder.rb +37 -0
- data/benchmarks/collection.rb +47 -0
- data/cells.gemspec +5 -7
- data/lib/cell.rb +2 -11
- data/lib/cell/builder.rb +16 -0
- data/lib/cell/collection.rb +54 -0
- data/lib/cell/concept.rb +6 -7
- data/lib/cell/escaped.rb +1 -0
- data/lib/cell/layout.rb +50 -14
- data/lib/cell/testing.rb +6 -5
- data/lib/cell/util.rb +10 -1
- data/lib/cell/version.rb +1 -1
- data/lib/cell/view_model.rb +27 -56
- data/lib/cells.rb +1 -1
- data/test/builder_test.rb +4 -2
- data/test/cell_test.rb +9 -2
- data/test/concept_test.rb +9 -16
- data/test/context_test.rb +33 -0
- data/test/fixtures/cell_test/song/show_with_block.erb +1 -0
- data/test/fixtures/comment/layout/show.erb +1 -0
- data/test/fixtures/comment/show/show.erb +1 -0
- data/test/fixtures/song/with_block.erb +1 -0
- data/test/layout_test.rb +34 -1
- data/test/prefixes_test.rb +3 -3
- data/test/public_test.rb +43 -9
- data/test/render_test.rb +7 -3
- data/test/test_helper.rb +2 -38
- data/test/{test_case_test.rb → testing_test.rb} +2 -2
- metadata +16 -159
- data/gemfiles/rails3.2.gemfile +0 -16
- data/gemfiles/rails4.0.gemfile +0 -12
- data/gemfiles/rails4.1.gemfile +0 -12
- data/gemfiles/rails4.2.gemfile +0 -10
- data/lib/cell/caching/notification.rb +0 -15
- data/lib/cell/rails.rb +0 -98
- data/lib/cell/railtie.rb +0 -69
- data/lib/cell/test_case.rb +0 -12
- data/lib/cell/translation.rb +0 -19
- data/lib/rails/generators/cell/cell_generator.rb +0 -43
- data/lib/rails/generators/cell/templates/cell.rb.erb +0 -8
- data/lib/rails/generators/cell/templates/view.erb +0 -7
- data/lib/rails/generators/cell/templates/view.haml +0 -4
- data/lib/rails/generators/cell/templates/view.slim +0 -2
- data/lib/rails/generators/concept/concept_generator.rb +0 -38
- data/lib/rails/generators/concept/templates/concept.rb.erb +0 -7
- data/lib/rails/generators/concept/templates/view.erb +0 -7
- data/lib/rails/generators/concept/templates/view.haml +0 -4
- data/lib/rails/generators/concept/templates/view.slim +0 -2
- data/lib/rails/generators/test_unit/cell/cell_generator.rb +0 -21
- data/lib/rails/generators/test_unit/cell/templates/unit_test.rb.erb +0 -11
- data/lib/rails/generators/test_unit/concept/concept_generator.rb +0 -21
- data/lib/rails/generators/test_unit/concept/templates/unit_test.rb.erb +0 -11
- data/test/caching_test.rb +0 -305
- data/test/cell_generator_test.rb +0 -90
- data/test/concept_generator_test.rb +0 -40
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -2
- data/test/dummy/app/cells/album/assets/album.js +0 -1
- data/test/dummy/app/concepts/song/assets/songs.js +0 -1
- data/test/dummy/app/controllers/application_controller.rb +0 -4
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/musician/featured.html.erb +0 -1
- data/test/dummy/app/views/musician/featured_with_block.html.erb +0 -4
- data/test/dummy/app/views/musician/hamlet.html.erb +0 -1
- data/test/dummy/app/views/musician/title.erb +0 -1
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -41
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -22
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -5
- data/test/dummy/script/rails +0 -6
- data/test/rails/translation_test.rb +0 -45
- data/test/rails4.2/.gitignore +0 -13
- data/test/rails4.2/Gemfile +0 -18
- data/test/rails4.2/README.rdoc +0 -3
- data/test/rails4.2/Rakefile +0 -6
- data/test/rails4.2/app/assets/images/.keep +0 -0
- data/test/rails4.2/app/assets/stylesheets/application.css.erb +0 -19
- data/test/rails4.2/app/cells/form_for/show.erb +0 -7
- data/test/rails4.2/app/cells/form_for_cell.rb +0 -7
- data/test/rails4.2/app/cells/form_tag/show.erb +0 -5
- data/test/rails4.2/app/cells/form_tag_cell.rb +0 -5
- data/test/rails4.2/app/cells/formtastic/show.erb +0 -12
- data/test/rails4.2/app/cells/formtastic_cell.rb +0 -9
- data/test/rails4.2/app/cells/simple_form/show.erb +0 -7
- data/test/rails4.2/app/cells/simple_form_cell.rb +0 -11
- data/test/rails4.2/app/cells/song/song.css +0 -1
- data/test/rails4.2/app/cells/song/with_escaped.erb +0 -1
- data/test/rails4.2/app/cells/song_cell.rb +0 -18
- data/test/rails4.2/app/controllers/application_controller.rb +0 -5
- data/test/rails4.2/app/controllers/concerns/.keep +0 -0
- data/test/rails4.2/app/controllers/index_controller.rb +0 -7
- data/test/rails4.2/app/controllers/songs_controller.rb +0 -25
- data/test/rails4.2/app/helpers/application_helper.rb +0 -2
- data/test/rails4.2/app/mailers/.keep +0 -0
- data/test/rails4.2/app/models/.keep +0 -0
- data/test/rails4.2/app/models/artist.rb +0 -25
- data/test/rails4.2/app/models/concerns/.keep +0 -0
- data/test/rails4.2/app/models/song.rb +0 -25
- data/test/rails4.2/app/views/index/index.html.erb +0 -6
- data/test/rails4.2/app/views/layouts/application.html.erb +0 -13
- data/test/rails4.2/app/views/songs/show.html.erb +0 -1
- data/test/rails4.2/app/views/songs/with_escaped.html.erb +0 -1
- data/test/rails4.2/bin/bundle +0 -3
- data/test/rails4.2/bin/rails +0 -4
- data/test/rails4.2/bin/rake +0 -4
- data/test/rails4.2/bin/setup +0 -29
- data/test/rails4.2/config.ru +0 -4
- data/test/rails4.2/config/application.rb +0 -38
- data/test/rails4.2/config/boot.rb +0 -3
- data/test/rails4.2/config/environment.rb +0 -5
- data/test/rails4.2/config/environments/development.rb +0 -25
- data/test/rails4.2/config/environments/production.rb +0 -64
- data/test/rails4.2/config/environments/test.rb +0 -42
- data/test/rails4.2/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails4.2/config/initializers/cookies_serializer.rb +0 -3
- data/test/rails4.2/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/rails4.2/config/initializers/formtastic.rb +0 -2
- data/test/rails4.2/config/initializers/inflections.rb +0 -16
- data/test/rails4.2/config/initializers/mime_types.rb +0 -4
- data/test/rails4.2/config/initializers/session_store.rb +0 -3
- data/test/rails4.2/config/initializers/wrap_parameters.rb +0 -9
- data/test/rails4.2/config/locales/en.yml +0 -23
- data/test/rails4.2/config/routes.rb +0 -9
- data/test/rails4.2/config/secrets.yml +0 -22
- data/test/rails4.2/db/seeds.rb +0 -7
- data/test/rails4.2/engines/my_engine/.gitignore +0 -3
- data/test/rails4.2/engines/my_engine/Gemfile +0 -15
- data/test/rails4.2/engines/my_engine/MIT-LICENSE +0 -20
- data/test/rails4.2/engines/my_engine/README.rdoc +0 -3
- data/test/rails4.2/engines/my_engine/Rakefile +0 -24
- data/test/rails4.2/engines/my_engine/app/assets/images/my_engine/.keep +0 -0
- data/test/rails4.2/engines/my_engine/app/assets/stylesheets/my_engine/application.css +0 -15
- data/test/rails4.2/engines/my_engine/app/concepts/user/cell.rb +0 -8
- data/test/rails4.2/engines/my_engine/app/concepts/user/views/show.erb +0 -1
- data/test/rails4.2/engines/my_engine/app/concepts/user/views/user.scss +0 -3
- data/test/rails4.2/engines/my_engine/app/controllers/my_engine/application_controller.rb +0 -4
- data/test/rails4.2/engines/my_engine/app/controllers/my_engine/user_controller.rb +0 -7
- data/test/rails4.2/engines/my_engine/app/helpers/my_engine/application_helper.rb +0 -4
- data/test/rails4.2/engines/my_engine/app/models/my_engine/user.rb +0 -4
- data/test/rails4.2/engines/my_engine/app/views/layouts/my_engine/application.html.erb +0 -14
- data/test/rails4.2/engines/my_engine/app/views/my_engine/user/show.html.erb +0 -3
- data/test/rails4.2/engines/my_engine/bin/rails +0 -12
- data/test/rails4.2/engines/my_engine/config/routes.rb +0 -3
- data/test/rails4.2/engines/my_engine/db/migrate/20150530135920_create_my_engine_users.rb +0 -8
- data/test/rails4.2/engines/my_engine/lib/my_engine.rb +0 -6
- data/test/rails4.2/engines/my_engine/lib/my_engine/engine.rb +0 -9
- data/test/rails4.2/engines/my_engine/lib/my_engine/version.rb +0 -3
- data/test/rails4.2/engines/my_engine/lib/tasks/my_engine_tasks.rake +0 -4
- data/test/rails4.2/engines/my_engine/my_engine.gemspec +0 -24
- data/test/rails4.2/engines/my_engine/test/fixtures/my_engine/users.yml +0 -11
- data/test/rails4.2/engines/my_engine/test/models/my_engine/user_test.rb +0 -9
- data/test/rails4.2/lib/assets/.keep +0 -0
- data/test/rails4.2/lib/tasks/.keep +0 -0
- data/test/rails4.2/log/.keep +0 -0
- data/test/rails4.2/test/integration/asset_pipeline_test.rb +0 -17
- data/test/rails4.2/test/integration/controller_test.rb +0 -16
- data/test/rails4.2/test/integration/form_for_test.rb +0 -10
- data/test/rails4.2/test/integration/form_tag_test.rb +0 -11
- data/test/rails4.2/test/integration/formtastic_test.rb +0 -12
- data/test/rails4.2/test/integration/simple_form_test.rb +0 -11
- data/test/rails4.2/test/integration/url_helper_test.rb +0 -47
- data/test/rails4.2/test/test_helper.rb +0 -14
- data/test/rails4.2/vendor/assets/stylesheets/.keep +0 -0
- data/test/rails_extensions_test.rb +0 -51
data/gemfiles/rails3.2.gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "railties", "~> 3.2.0"
|
6
|
-
gem "tzinfo"
|
7
|
-
gem "minitest", "4.7.5"
|
8
|
-
|
9
|
-
gemspec :path => "../"
|
10
|
-
|
11
|
-
gem "rack-cache", "< 1.3.0", platform: :ruby_19
|
12
|
-
gem "rack-cache", "< 1.3.0", platform: :jruby
|
13
|
-
gem "test-unit", "~> 3.0", platform: :ruby_22
|
14
|
-
gem "mime-types", "< 3.0", platform: :ruby_19
|
15
|
-
gem "mime-types", "< 3.0", platform: :jruby
|
16
|
-
|
data/gemfiles/rails4.0.gemfile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "railties", "4.0.12"
|
6
|
-
gem "activemodel"
|
7
|
-
gem "minitest", "4.7.5"
|
8
|
-
|
9
|
-
gemspec :path => "../"
|
10
|
-
|
11
|
-
gem "mime-types", "< 3.0", platform: :ruby_19
|
12
|
-
gem "mime-types", "< 3.0", platform: :jruby
|
data/gemfiles/rails4.1.gemfile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "railties", "~> 4.1.0" #, :github => "rails/rails", :branch => "4-1-stable"
|
6
|
-
gem "activemodel", "~> 4.1.0" #, :github => "rails/rails", :branch => "4-1-stable"
|
7
|
-
gem "minitest", "~> 5.2"
|
8
|
-
|
9
|
-
gemspec :path => "../"
|
10
|
-
|
11
|
-
gem "mime-types", "< 3.0", platform: :ruby_19
|
12
|
-
gem "mime-types", "< 3.0", platform: :jruby
|
data/gemfiles/rails4.2.gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module Cell
|
2
|
-
module Caching
|
3
|
-
module Notifications
|
4
|
-
def fetch_from_cache_for(key, options)
|
5
|
-
ActiveSupport::Notifications.instrument('read_fragment.cells', key: key) do
|
6
|
-
cache_store.fetch(key, options) do
|
7
|
-
ActiveSupport::Notifications.instrument('write_fragment.cells', key: key) do
|
8
|
-
yield
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/cell/rails.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
# These methods are automatically added to all controllers and views.
|
2
|
-
module Cell
|
3
|
-
module RailsExtensions
|
4
|
-
module ActionController
|
5
|
-
def cell(name, model=nil, options={}, &block)
|
6
|
-
::Cell::ViewModel.cell(name, model, options.merge(controller: self), &block)
|
7
|
-
end
|
8
|
-
|
9
|
-
def concept(name, model=nil, options={}, &block)
|
10
|
-
::Cell::Concept.cell(name, model, options.merge(controller: self), &block)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module ActionView
|
15
|
-
# Returns the cell instance for +name+. You may pass arbitrary options to your
|
16
|
-
# cell.
|
17
|
-
#
|
18
|
-
# = cell(:song, title: "Creeping Out Sara").(:show)
|
19
|
-
def cell(name, *args, &block)
|
20
|
-
controller.cell(name, *args, &block)
|
21
|
-
end
|
22
|
-
|
23
|
-
# # See Cells::Rails::ActionController#render_cell.
|
24
|
-
# def render_cell(name, state, *args, &block)
|
25
|
-
# ::Cell::Rails.render_cell(name, state, controller, *args, &block)
|
26
|
-
# end
|
27
|
-
|
28
|
-
def concept(name, *args, &block)
|
29
|
-
controller.concept(name, *args, &block)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Gets included into Cell::ViewModel in a Rails environment.
|
34
|
-
module ViewModel
|
35
|
-
extend ActiveSupport::Concern
|
36
|
-
|
37
|
-
# DISCUSS: who actually uses forgery protection with cells? it is not working since 4, anyway?
|
38
|
-
# include ActionController::RequestForgeryProtection
|
39
|
-
included do
|
40
|
-
extend Uber::Delegates
|
41
|
-
delegates :parent_controller, :session, :params, :request, :config, :env, :url_options
|
42
|
-
# forgery protection.
|
43
|
-
delegates :parent_controller, :protect_against_forgery?, :form_authenticity_token, :request_forgery_protection_token
|
44
|
-
end
|
45
|
-
|
46
|
-
def call(*)
|
47
|
-
super.html_safe
|
48
|
-
end
|
49
|
-
|
50
|
-
def perform_caching?
|
51
|
-
::ActionController::Base.perform_caching
|
52
|
-
end
|
53
|
-
|
54
|
-
def cache_store # we want to use DI to set a cache store in cell/rails.
|
55
|
-
::ActionController::Base.cache_store
|
56
|
-
end
|
57
|
-
|
58
|
-
module ClassMethods
|
59
|
-
def expand_cache_key(key)
|
60
|
-
::ActiveSupport::Cache.expand_cache_key(key, :cells)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# In Rails, there are about 10 different implementations of #url_for. Rails doesn't like the idea of objects, so they
|
66
|
-
# have helpers in modules. Those module are now included sequentially into other modules and/or classes. While they
|
67
|
-
# get included, they might or might not include methods, depending on the including module/class
|
68
|
-
# (example here: https://github.com/rails/rails/blob/cad20f720c4c6e04584253cd0a23f22b3d43ab0f/actionpack/lib/action_dispatch/routing/url_for.rb#L87).
|
69
|
-
#
|
70
|
-
# The outcome is that several module override #url_for, and if you're lucky, this works. If you're not, then #url_for breaks
|
71
|
-
# due to a raise in one of its basic implementations, introduced in 3.x, fixed in 4.0 and then re-introduced in 4.2
|
72
|
-
#
|
73
|
-
# This is extremely frustrating as no one in Rails core seems to tackle this problem and introduces a url object instead
|
74
|
-
# of this module madness. I have to constantly test and fix it in Cells. With the module below, I'll stop doing this.
|
75
|
-
#
|
76
|
-
# Either Rails works with Cells and we fix this in form of a URL object that gets passed into the cell (I'm happy with
|
77
|
-
# a global object here, too! Wow!) or URL helpers will stop working in Cells and a lot of people will be unhappy.
|
78
|
-
#
|
79
|
-
# Anyway, this is the reason we need this patch module. If you have trouble with URLs in Cells, then please ask Rails to
|
80
|
-
# fix their implementation. Thank you.
|
81
|
-
module HelpersAreShit
|
82
|
-
def url_for(options = nil) # from ActionDispatch:R:UrlFor.
|
83
|
-
case options
|
84
|
-
when nil
|
85
|
-
_routes.url_for(url_options.symbolize_keys)
|
86
|
-
when Hash
|
87
|
-
_routes.url_for(options.symbolize_keys.reverse_merge!(url_options))
|
88
|
-
when String
|
89
|
-
options
|
90
|
-
when Array
|
91
|
-
polymorphic_url(options, options.extract_options!)
|
92
|
-
else
|
93
|
-
polymorphic_url(options)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
data/lib/cell/railtie.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'rails/railtie'
|
2
|
-
|
3
|
-
module Cell
|
4
|
-
class Railtie < Rails::Railtie
|
5
|
-
require 'cell/rails'
|
6
|
-
config.cells = ActiveSupport::OrderedOptions.new
|
7
|
-
|
8
|
-
initializer('cells.attach_router') do |app|
|
9
|
-
ViewModel.class_eval do
|
10
|
-
include app.routes.url_helpers # TODO: i hate this, make it better in Rails.
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# ruthlessly stolen from the zurb-foundation gem.
|
15
|
-
initializer 'cells.update_asset_paths' do |app|
|
16
|
-
Array(app.config.cells.with_assets).each do |cell_class|
|
17
|
-
# puts "@@@@@ #{cell_class.camelize.constantize.prefixes}"
|
18
|
-
app.config.assets.paths += cell_class.camelize.constantize.prefixes # Song::Cell.prefixes
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
initializer "cells.rails_extensions" do |app|
|
23
|
-
ActiveSupport.on_load(:action_controller) do
|
24
|
-
self.class_eval do
|
25
|
-
include ::Cell::RailsExtensions::ActionController
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
ActiveSupport.on_load(:action_view) do |app|
|
30
|
-
self.class_eval do
|
31
|
-
include ::Cell::RailsExtensions::ActionView
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
initializer "cells.include_default_helpers" do
|
37
|
-
# include asset helpers (image_path, font_path, ect)
|
38
|
-
ViewModel.class_eval do
|
39
|
-
include ActionView::Helpers::FormHelper # includes ActionView::Helpers::UrlHelper, ActionView::Helpers::FormTagHelper
|
40
|
-
include ::Cell::RailsExtensions::HelpersAreShit
|
41
|
-
|
42
|
-
include ActionView::Helpers::AssetTagHelper
|
43
|
-
end
|
44
|
-
|
45
|
-
# set VM#cache_store, etc.
|
46
|
-
ViewModel.send(:include, RailsExtensions::ViewModel)
|
47
|
-
end
|
48
|
-
|
49
|
-
# TODO: allow to turn off this.
|
50
|
-
initializer "cells.include_template_module", after: "cells.include_default_helpers" do
|
51
|
-
# yepp, this is happening. saves me a lot of coding in each extension.
|
52
|
-
ViewModel.send(:include, Cell::Erb) if Cell.const_defined?(:Erb, false)
|
53
|
-
ViewModel.send(:include, Cell::Haml) if Cell.const_defined?(:Haml, false)
|
54
|
-
ViewModel.send(:include, Cell::Slim) if Cell.const_defined?(:Slim, false)
|
55
|
-
end
|
56
|
-
# ViewModel.template_engine = app.config.app_generators.rails.fetch(:template_engine, 'erb').to_s
|
57
|
-
|
58
|
-
initializer('cells.development') do |app|
|
59
|
-
if Rails.env == "development"
|
60
|
-
require "cell/development"
|
61
|
-
ViewModel.send(:include, Development)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
rake_tasks do
|
66
|
-
load 'tasks/cells.rake'
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
data/lib/cell/test_case.rb
DELETED
data/lib/cell/translation.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# NOTE: this will soon be moved to cells-rails.
|
2
|
-
module Cell::Translation
|
3
|
-
def self.included(includer)
|
4
|
-
super
|
5
|
-
includer.inheritable_attr :translation_path
|
6
|
-
end
|
7
|
-
|
8
|
-
def initialize(*)
|
9
|
-
super
|
10
|
-
@virtual_path = translation_path
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
# If you override this to change this path, please report it on the trailblazer/chat gitter channel,
|
15
|
-
# so we can find out best practices.
|
16
|
-
def translation_path
|
17
|
-
self.class.translation_path or controller_path.gsub("/", ".")
|
18
|
-
end
|
19
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Rails
|
2
|
-
module Generators
|
3
|
-
class CellGenerator < NamedBase
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
class_option :parent, type: :string, desc: 'The parent class for the generated cell'
|
7
|
-
class_option :e, type: :string, desc: 'The template engine'
|
8
|
-
|
9
|
-
check_class_collision suffix: 'Cell'
|
10
|
-
|
11
|
-
argument :actions, type: :array, default: [], banner: 'action action2'
|
12
|
-
|
13
|
-
def create_cell_file
|
14
|
-
template 'cell.rb.erb', File.join('app/cells', class_path, "#{file_name}_cell.rb")
|
15
|
-
end
|
16
|
-
|
17
|
-
def create_view_files
|
18
|
-
states.each do |state|
|
19
|
-
@state = state
|
20
|
-
@path = File.join('app/cells', class_path, file_name, "#{state}.#{template_engine}")
|
21
|
-
template "view.#{template_engine}", @path
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
hook_for :test_framework
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def parent_class_name
|
30
|
-
options[:parent] || 'Cell::ViewModel'
|
31
|
-
end
|
32
|
-
|
33
|
-
# The show state is included by default
|
34
|
-
def states
|
35
|
-
(['show'] + actions).uniq
|
36
|
-
end
|
37
|
-
|
38
|
-
def template_engine
|
39
|
-
(options[:e] || Rails.application.config.app_generators.rails[:template_engine] || 'erb').to_s
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Rails
|
2
|
-
module Generators
|
3
|
-
class ConceptGenerator < NamedBase
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
class_option :e, type: :string, desc: 'The template engine'
|
7
|
-
argument :actions, type: :array, default: [], banner: 'action action2'
|
8
|
-
|
9
|
-
check_class_collision suffix: 'Concept'
|
10
|
-
|
11
|
-
|
12
|
-
def create_concept
|
13
|
-
template 'concept.rb.erb', File.join('app/concepts', class_path, file_name, 'cell.rb')
|
14
|
-
end
|
15
|
-
|
16
|
-
def create_views
|
17
|
-
states.each do |state|
|
18
|
-
@state = state
|
19
|
-
@path = File.join('app/concepts', class_path, file_name, 'views', "#{state}.#{template_engine}")
|
20
|
-
template "view.#{template_engine}", @path
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
hook_for :test_framework
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def template_engine
|
29
|
-
(options[:e] || Rails.application.config.app_generators.rails[:template_engine] || 'erb').to_s
|
30
|
-
end
|
31
|
-
|
32
|
-
# The show state is included by default
|
33
|
-
def states
|
34
|
-
(['show'] + actions).uniq
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rails/generators/test_unit'
|
2
|
-
|
3
|
-
module TestUnit # :nodoc:
|
4
|
-
module Generators # :nodoc:
|
5
|
-
class CellGenerator < Base # :nodoc:
|
6
|
-
source_root File.expand_path('../templates', __FILE__)
|
7
|
-
argument :actions, type: :array, default: []
|
8
|
-
check_class_collision suffix: 'CellTest'
|
9
|
-
|
10
|
-
def create_test_file
|
11
|
-
template 'unit_test.rb.erb', File.join('test/cells', class_path, "#{file_name}_cell_test.rb")
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def states
|
17
|
-
(['show'] + actions).uniq
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|