modular 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +1 -0
  3. data/lib/modular.rb +3 -14
  4. data/lib/modular/action_controller_extension.rb +16 -7
  5. data/lib/modular/components.rb +7 -4
  6. data/lib/modular/components/base.rb +75 -5
  7. data/lib/modular/components/container.rb +37 -11
  8. data/lib/modular/configuration.rb +8 -0
  9. data/lib/modular/creation.rb +20 -13
  10. data/lib/{generators → modular/generators}/component/USAGE +0 -0
  11. data/lib/modular/generators/component/component_generator.rb +18 -0
  12. data/lib/{generators → modular/generators}/component/templates/component.rb.erb +0 -0
  13. data/lib/{generators → modular/generators}/component/templates/template.erb +0 -0
  14. data/lib/modular/mst_rendering.rb +10 -0
  15. data/lib/modular/railtie.rb +4 -0
  16. data/lib/modular/rendering.rb +1 -42
  17. data/lib/modular/version.rb +1 -1
  18. data/spec/components/{base.rb → base_spec.rb} +12 -6
  19. data/spec/components/container_spec.rb +27 -0
  20. data/spec/components/{hello_world.rb → hello_world_spec.rb} +0 -0
  21. data/spec/components/{helpers_example.rb → helpers_example_spec.rb} +0 -0
  22. data/spec/components/spec/internal/log/test.log +0 -0
  23. data/spec/controllers/callback_layout_controller_spec.rb +4 -0
  24. data/spec/controllers/rendering_spec.rb +33 -0
  25. data/spec/internal/app/components/mustache_container.rb +5 -0
  26. data/spec/internal/app/components/mustached.rb +5 -0
  27. data/spec/internal/app/controllers/callback_layout_controller.rb +5 -5
  28. data/spec/internal/app/controllers/example_controller.rb +9 -1
  29. data/spec/internal/app/views/components/mustache_container.mst +3 -0
  30. data/spec/internal/app/views/components/mustached.mst +1 -0
  31. data/spec/internal/app/views/example/mustache.html.erb +1 -0
  32. data/spec/internal/app/views/example/mustache_nested.html.erb +1 -0
  33. data/spec/internal/config/initializers/modular.rb +11 -6
  34. data/spec/modular/configuration_spec.rb +6 -6
  35. data/spec/modular/creation_spec.rb +36 -5
  36. data/spec/modular/validation_spec.rb +115 -0
  37. data/templates/components/container.html.erb +7 -0
  38. data/templates/layout.erb +1 -3
  39. metadata +23 -47
  40. data/lib/generators/component/component_generator.rb +0 -16
  41. data/lib/modular/helpers.rb +0 -74
  42. data/modular-app/Gemfile +0 -20
  43. data/modular-app/Rakefile +0 -7
  44. data/modular-app/config.ru +0 -4
  45. data/modular-app/config/application.rb +0 -42
  46. data/modular-app/config/boot.rb +0 -6
  47. data/modular-app/config/database.yml +0 -22
  48. data/modular-app/config/environment.rb +0 -5
  49. data/modular-app/config/environments/development.rb +0 -26
  50. data/modular-app/config/environments/production.rb +0 -49
  51. data/modular-app/config/environments/test.rb +0 -35
  52. data/modular-app/config/initializers/backtrace_silencers.rb +0 -7
  53. data/modular-app/config/initializers/inflections.rb +0 -10
  54. data/modular-app/config/initializers/mime_types.rb +0 -5
  55. data/modular-app/config/initializers/secret_token.rb +0 -7
  56. data/modular-app/config/initializers/session_store.rb +0 -8
  57. data/modular-app/config/locales/en.yml +0 -5
  58. data/modular-app/config/routes.rb +0 -7
  59. data/modular-app/db/migrate/20110721090602_create_simple_models.rb +0 -12
  60. data/modular-app/db/schema.rb +0 -20
  61. data/modular-app/db/seeds.rb +0 -7
  62. data/modular-app/script/rails +0 -6
  63. data/modular-app/spec/spec_helper.rb +0 -27
  64. data/spec/components/container.rb +0 -34
  65. data/spec/components/validated.rb +0 -15
  66. data/spec/controllers/example_controller_spec.rb +0 -12
  67. data/spec/controllers/indirect_render_controller_spec.rb +0 -13
  68. data/spec/internal/app/components/heavy_task.rb +0 -8
  69. data/spec/internal/app/controllers/indirect_render_controller.rb +0 -7
  70. data/spec/internal/app/views/components/container.html.erb +0 -7
  71. data/spec/internal/app/views/components/heavy_task.html.erb +0 -1
  72. data/spec/internal/tmp/modular/cached_for_time.html.erb +0 -14
  73. data/spec/internal/tmp/modular/cached_forever.html.erb +0 -12
  74. data/spec/internal/tmp/modular/heavy.html.erb +0 -19
  75. data/spec/internal/tmp/modular/nested.html.erb +0 -28
  76. data/spec/views/indirect_render/index.html.erb_spec.rb +0 -4
@@ -1,27 +0,0 @@
1
- # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV["RAILS_ENV"] ||= 'test'
3
- require File.expand_path("../../config/environment", __FILE__)
4
- require 'rspec/rails'
5
-
6
- # Requires supporting ruby files with custom matchers and macros, etc,
7
- # in spec/support/ and its subdirectories.
8
- Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
9
-
10
- RSpec.configure do |config|
11
- # == Mock Framework
12
- #
13
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
14
- #
15
- # config.mock_with :mocha
16
- # config.mock_with :flexmock
17
- # config.mock_with :rr
18
- config.mock_with :rspec
19
-
20
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
21
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
22
-
23
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
24
- # examples within a transaction, remove the following line or assign false
25
- # instead of true.
26
- config.use_transactional_fixtures = true
27
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Modular::Components::Container, ' vertical container class ' do
4
- before :each do
5
- @cmp = described_class.new
6
- end
7
-
8
- it "should have container" do
9
- @cmp.components.should be_a_kind_of Array
10
- end
11
-
12
- it "should unserialize children" do
13
- @cmp.components.push Modular.create(:FakeNewsFeed, { :news_count => 50, :title => 'Best news feed' }).to_json
14
- json = @cmp.to_json
15
- container = Modular.from_json(json)
16
- container.components[0].should be_a_kind_of FakeNewsFeed
17
- end
18
-
19
- it "should have add_container and add_child methods" do
20
- @cmp.add :container, :title => 'Test container title' do
21
- add :FakeNewsFeed, :title => 'Worst news feed'
22
-
23
- add :Vertical, :title => 'Vertical container'
24
- end
25
-
26
- @cmp.components[0].title.should == 'Test container title'
27
-
28
- feed = @cmp.components[0].components[0]
29
- feed.should be_a_kind_of FakeNewsFeed
30
- feed.title.should == 'Worst news feed'
31
-
32
- @cmp.components[0].components[1].should be_a_kind_of Vertical
33
- end
34
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Modular::Components::Validated, ' as non-generatable component ' do
4
- it "should throw error if generated" do
5
- lambda {
6
- Modular.create(:Container).add_container :title => 'Test container title' do |cont2|
7
- add_child(:Validated)
8
- end
9
- }.should raise_error
10
-
11
- lambda {
12
- Modular.create(:Validated)
13
- }.should raise_error
14
- end
15
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ExampleController do
4
-
5
- describe "GET 'index'" do
6
- it "should be successful" do
7
- get 'index'
8
- response.body.should contain 'Template - Best news feed'
9
- end
10
- end
11
-
12
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe IndirectRenderController do
4
- describe 'GET /index' do
5
- render_views
6
-
7
- it "should be successful" do
8
- get 'index'
9
- get 'index'
10
- #Modular.layout(:heavy).components[1].called.should == 1
11
- end
12
- end
13
- end
@@ -1,8 +0,0 @@
1
- class Modular::Components::HeavyTask < Modular::Components::Base
2
- include Modular::Rendering
3
-
4
- def execute
5
- end
6
- end
7
-
8
- HeavyTask = Modular::Components::HeavyTask
@@ -1,7 +0,0 @@
1
- class IndirectRenderController < ApplicationController
2
- modular_layout 'heavy'
3
-
4
- def index
5
- end
6
-
7
- end
@@ -1,7 +0,0 @@
1
- <table>
2
- <tr><td>
3
- <% @attributes[:components].each do |component| %>
4
- <%=render_component component %>
5
- <% end %>
6
- </td></tr>
7
- </table>
@@ -1 +0,0 @@
1
- <h3>Template for HeavyTask</h3>
@@ -1,14 +0,0 @@
1
- <% @layout_id = 'cached_for_time'.to_sym %>
2
-
3
-
4
-
5
- <h3>Template for CachedForTime</h3>
6
-
7
-
8
-
9
- <%
10
- layout = 'application'
11
- #Old one is @_content_for
12
- @view_flow.content[:layout] = self.output_buffer
13
- self.output_buffer = render(:file => "layouts/#{layout}")
14
- %>
@@ -1,12 +0,0 @@
1
- <% @layout_id = 'cached_forever'.to_sym %>
2
-
3
-
4
-
5
-
6
-
7
- <%
8
- layout = 'application'
9
- #Old one is @_content_for
10
- @view_flow.content[:layout] = self.output_buffer
11
- self.output_buffer = render(:file => "layouts/#{layout}")
12
- %>
@@ -1,19 +0,0 @@
1
- <% @layout_id = 'heavy'.to_sym %>
2
-
3
-
4
-
5
- <table>
6
- <tr><td>
7
- <h1>Template - Best news feed</h1>
8
- <h3>Template for HeavyTask</h3>
9
-
10
- </td></tr>
11
- </table>
12
-
13
-
14
- <%
15
- layout = 'application'
16
- #Old one is @_content_for
17
- @view_flow.content[:layout] = self.output_buffer
18
- self.output_buffer = render(:file => "layouts/#{layout}")
19
- %>
@@ -1,28 +0,0 @@
1
- <% @layout_id = 'nested'.to_sym %>
2
-
3
-
4
-
5
- <table>
6
- <tr><td>
7
- <h1>Template - Best news feed</h1>
8
- <table>
9
- <tr><td>
10
- <div>
11
- <h3>FooBar component!</h3>
12
- <p>Nested component</p>
13
- </div>
14
-
15
- </td></tr>
16
- </table>
17
-
18
- <%=yield%>
19
- </td></tr>
20
- </table>
21
-
22
-
23
- <%
24
- layout = 'application'
25
- #Old one is @_content_for
26
- @view_flow.content[:layout] = self.output_buffer
27
- self.output_buffer = render(:file => "layouts/#{layout}")
28
- %>
@@ -1,4 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "indirect_render/index" do
4
- end