modular 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rvmrc +1 -0
- data/.travis.yml +2 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +155 -0
- data/LICENSE +7 -0
- data/README.rdoc +21 -0
- data/Rakefile +14 -2
- data/TODO +3 -2
- data/config.ru +7 -0
- data/lib/modular.rb +15 -35
- data/lib/modular/action_controller_extension.rb +20 -0
- data/lib/modular/components.rb +6 -0
- data/lib/modular/components/base.rb +9 -7
- data/lib/modular/components/container.rb +1 -10
- data/lib/modular/components/main_content.rb +1 -3
- data/lib/modular/configuration.rb +10 -10
- data/lib/modular/creation.rb +29 -0
- data/lib/modular/{abstract_model.rb → helpers.rb} +0 -0
- data/lib/modular/layout_generator.rb +8 -7
- data/lib/modular/railtie.rb +11 -0
- data/lib/modular/rendering.rb +68 -73
- data/lib/modular/version.rb +1 -1
- data/modular.gemspec +0 -1
- data/{modular-app/spec → spec}/components/base.rb +0 -0
- data/{modular-app/spec → spec}/components/container.rb +3 -3
- data/{modular-app/spec → spec}/components/hello_world.rb +0 -0
- data/{modular-app/spec → spec}/components/helpers_example.rb +0 -0
- data/{modular-app/spec → spec}/components/validated.rb +0 -0
- data/{modular-app/spec → spec}/controllers/cached_for_time_controller_spec.rb +0 -0
- data/{modular-app/spec → spec}/controllers/cached_forever_controller_spec.rb +0 -0
- data/{modular-app/spec → spec}/controllers/callback_layout_controller_spec.rb +0 -0
- data/{modular-app/spec → spec}/controllers/example_controller_spec.rb +0 -0
- data/{modular-app/spec → spec}/controllers/indirect_render_controller_spec.rb +0 -0
- data/{modular-app/spec → spec}/controllers/layout_test_controller_spec.rb +1 -1
- data/{modular-app → spec/internal}/app/components/cached_for_time.rb +2 -4
- data/spec/internal/app/components/cached_forever.rb +8 -0
- data/spec/internal/app/components/fake_news_feed.rb +3 -0
- data/{modular-app → spec/internal}/app/components/foobar.rb +0 -0
- data/spec/internal/app/components/heavy_task.rb +8 -0
- data/{modular-app → spec/internal}/app/components/hello_world.rb +0 -0
- data/{modular-app → spec/internal}/app/components/helpers_example.rb +0 -0
- data/{modular-app → spec/internal}/app/components/validated.rb +0 -0
- data/{modular-app → spec/internal}/app/components/vertical.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/application_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/cached_for_time_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/cached_forever_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/callback_layout_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/example_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/indirect_render_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/layout_test_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/models/simple_model.rb +0 -0
- data/{modular-app → spec/internal}/app/views/cached_for_time/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/cached_forever/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/callback_layout/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/cached_for_time.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/cached_forever.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/container.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/fake_news_feed.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/foobar.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/heavy_task.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/hello_world.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/helpers_example.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/validated.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/vertical.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/example/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/indirect_render/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/layout_test/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/layouts/application.html.erb +0 -0
- data/spec/internal/config/database.yml +3 -0
- data/{modular-app → spec/internal}/config/initializers/modular.rb +1 -1
- data/spec/internal/config/routes.rb +7 -0
- data/spec/internal/db/schema.rb +6 -0
- data/spec/internal/log/.gitignore +1 -0
- data/{README → spec/internal/public/favicon.ico} +0 -0
- data/spec/internal/tmp/.gitkeep +0 -0
- data/spec/internal/tmp/modular/cached_for_time.html.erb +14 -0
- data/spec/internal/tmp/modular/cached_forever.html.erb +12 -0
- data/spec/internal/tmp/modular/heavy.html.erb +19 -0
- data/spec/internal/tmp/modular/nested.html.erb +28 -0
- data/spec/modular/configuration_spec.rb +46 -0
- data/spec/{base.rb → modular/creation_spec.rb} +11 -16
- data/spec/spec_helper.rb +11 -3
- data/spec/views/indirect_render/index.html.erb_spec.rb +4 -0
- data/templates/layout.erb +5 -10
- metadata +119 -133
- data/autotest/discover.rb +0 -12
- data/lib/modular/rails.rb +0 -16
- data/modular-app/app/components/cached_forever.rb +0 -10
- data/modular-app/app/components/fake_news_feed.rb +0 -9
- data/modular-app/app/components/heavy_task.rb +0 -5
- data/modular-app/app/helpers/application_helper.rb +0 -2
- data/modular-app/app/helpers/callback_layout_helper.rb +0 -2
- data/modular-app/app/helpers/example_helper.rb +0 -2
- data/modular-app/app/helpers/indirect_render_helper.rb +0 -2
- data/modular-app/spec/helpers/indirect_render_helper_spec.rb +0 -14
- data/modular-app/spec/views/indirect_render/index.html.erb_spec.rb +0 -4
- data/spec/configuration.rb +0 -74
data/autotest/discover.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
Autotest.add_discovery { "rspec2" }
|
2
|
-
|
3
|
-
Autotest.add_hook :initialize do |at|
|
4
|
-
at.add_mapping(%r%^spec/.*\.rb$%) { |filename, _|
|
5
|
-
|
6
|
-
filename
|
7
|
-
}
|
8
|
-
|
9
|
-
%w{.git .svn .hg .DS_Store ._* spec/helpers spec/testdata}.each do |exception|
|
10
|
-
at.add_exception(exception)
|
11
|
-
end
|
12
|
-
end
|
data/lib/modular/rails.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'action_controller'
|
2
|
-
|
3
|
-
class ActionController::Base
|
4
|
-
def render_modular_layout(name)
|
5
|
-
layout = Modular.layout name
|
6
|
-
render :text => layout.render
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.modular_layout(name, params = {})
|
10
|
-
proc = Proc.new do |controller|
|
11
|
-
'../../../' + Modular.generate_rails_layout(name.is_a?(Symbol) ? controller.__send__(name) : name, params)
|
12
|
-
end
|
13
|
-
|
14
|
-
layout proc
|
15
|
-
end
|
16
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# Specs in this file have access to a helper object that includes
|
4
|
-
# the IndirectRenderHelper. For example:
|
5
|
-
#
|
6
|
-
# describe IndirectRenderHelper do
|
7
|
-
# describe "string concat" do
|
8
|
-
# it "concats two strings with spaces" do
|
9
|
-
# helper.concat_strings("this","that").should == "this that"
|
10
|
-
# end
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
describe IndirectRenderHelper do
|
14
|
-
end
|
data/spec/configuration.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Modular::Configuration, ' as modular config' do
|
4
|
-
|
5
|
-
it "should use defaults from config" do
|
6
|
-
Modular.configure
|
7
|
-
|
8
|
-
Modular.config.columns.should_not be nil
|
9
|
-
Modular.config.column_width.should_not be nil
|
10
|
-
Modular.config.padding_width.should_not be nil
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should be configurable by lambda" do
|
14
|
-
Modular.configure do |c|
|
15
|
-
c.columns = 99
|
16
|
-
c.column_width = 999
|
17
|
-
c.padding_width = 9999
|
18
|
-
end
|
19
|
-
|
20
|
-
Modular.config.columns.should === 99
|
21
|
-
Modular.config.column_width.should === 999
|
22
|
-
Modular.config.padding_width.should === 9999
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should export configuration as json" do
|
26
|
-
Modular.configure do |c|
|
27
|
-
c.columns = 12
|
28
|
-
c.column_width = 100
|
29
|
-
c.padding_width = 10
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
lambda { Modular.config.to_json }.should_not raise_error
|
34
|
-
|
35
|
-
target = ActiveSupport::JSON::decode(Modular.config.to_json).with_indifferent_access
|
36
|
-
|
37
|
-
target[:columns].should === 12
|
38
|
-
target[:column_width].should === 100
|
39
|
-
target[:padding_width].should === 10
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should register layout" do
|
43
|
-
component = Modular.create :FakeNewsFeed, :news_count => 50, :title => 'Best news feed'
|
44
|
-
|
45
|
-
Modular.configure do
|
46
|
-
register_layout :simple, component
|
47
|
-
end
|
48
|
-
|
49
|
-
Modular.layout(:simple).to_json == component
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should have DSL for registering layout" do
|
53
|
-
Modular.configure do
|
54
|
-
register_layout :simple, :Container do
|
55
|
-
add :FakeNewsFeed, :title => 'Best news feed'
|
56
|
-
add :FakeNewsFeed, :title => 'Just news feed'
|
57
|
-
|
58
|
-
add :container do
|
59
|
-
add :FakeNewsFeed, :title => 'Worst news feed'
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
l = Modular.layout(:simple)
|
65
|
-
|
66
|
-
l.should be_a_kind_of Modular::Components::Container
|
67
|
-
|
68
|
-
l.components[0..1].each do |e|
|
69
|
-
e.should be_a_kind_of Modular::Components::FakeNewsFeed
|
70
|
-
end
|
71
|
-
l.components.length.should == 3
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|