thorero-gen 0.9.4

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.
Files changed (152) hide show
  1. data/LICENSE +20 -0
  2. data/README +21 -0
  3. data/Rakefile +65 -0
  4. data/TODO +13 -0
  5. data/bin/merb-gen +10 -0
  6. data/lib/merb-gen.rb +37 -0
  7. data/lib/merb-gen/controller.rb +69 -0
  8. data/lib/merb-gen/freezer.rb +19 -0
  9. data/lib/merb-gen/generator.rb +55 -0
  10. data/lib/merb-gen/helper.rb +53 -0
  11. data/lib/merb-gen/merb.rb +27 -0
  12. data/lib/merb-gen/merb/merb_flat.rb +31 -0
  13. data/lib/merb-gen/merb/merb_full.rb +35 -0
  14. data/lib/merb-gen/merb/merb_very_flat.rb +33 -0
  15. data/lib/merb-gen/merb_plugin.rb +33 -0
  16. data/lib/merb-gen/migration.rb +69 -0
  17. data/lib/merb-gen/model.rb +67 -0
  18. data/lib/merb-gen/part_controller.rb +55 -0
  19. data/lib/merb-gen/resource.rb +32 -0
  20. data/lib/merb-gen/resource_controller.rb +91 -0
  21. data/lib/merb-gen/session_migration.rb +44 -0
  22. data/lib/merb-gen/slice.rb +25 -0
  23. data/lib/merb-gen/slice/full.rb +31 -0
  24. data/lib/merb-gen/slice/thin.rb +31 -0
  25. data/lib/merb-gen/slice/very_thin.rb +31 -0
  26. data/spec/controller_spec.rb +94 -0
  27. data/spec/merb_spec.rb +28 -0
  28. data/spec/migration_spec.rb +47 -0
  29. data/spec/model_spec.rb +95 -0
  30. data/spec/resource_controller_spec.rb +98 -0
  31. data/spec/spec_helper.rb +7 -0
  32. data/templates/application/merb/Rakefile +76 -0
  33. data/templates/application/merb/app/controllers/application.rb +2 -0
  34. data/templates/application/merb/app/controllers/exceptions.rb +13 -0
  35. data/templates/application/merb/app/helpers/global_helpers.rb +5 -0
  36. data/templates/application/merb/app/views/exceptions/internal_server_error.html.erb +216 -0
  37. data/templates/application/merb/app/views/exceptions/not_acceptable.html.erb +63 -0
  38. data/templates/application/merb/app/views/exceptions/not_found.html.erb +47 -0
  39. data/templates/application/merb/app/views/layout/application.html.erb +11 -0
  40. data/templates/application/merb/autotest/discover.rb +1 -0
  41. data/templates/application/merb/autotest/merb.rb +149 -0
  42. data/templates/application/merb/autotest/merb_rspec.rb +166 -0
  43. data/templates/application/merb/config/environments/development.rb +7 -0
  44. data/templates/application/merb/config/environments/production.rb +7 -0
  45. data/templates/application/merb/config/environments/rake.rb +7 -0
  46. data/templates/application/merb/config/environments/test.rb +6 -0
  47. data/templates/application/merb/config/init.rb +164 -0
  48. data/templates/application/merb/config/rack.rb +12 -0
  49. data/templates/application/merb/config/router.rb +35 -0
  50. data/templates/application/merb/public/images/merb.jpg +0 -0
  51. data/templates/application/merb/public/merb.fcgi +22 -0
  52. data/templates/application/merb/public/stylesheets/master.css +119 -0
  53. data/templates/application/merb/spec/spec.opts +0 -0
  54. data/templates/application/merb/spec/spec_helper.rb +13 -0
  55. data/templates/application/merb/test/test_helper.rb +14 -0
  56. data/templates/application/merb_flat/README.txt +10 -0
  57. data/templates/application/merb_flat/application.rb +15 -0
  58. data/templates/application/merb_flat/config/framework.rb +7 -0
  59. data/templates/application/merb_flat/config/init.rb +18 -0
  60. data/templates/application/merb_flat/views/foo.html.erb +3 -0
  61. data/templates/application/merb_plugin/LICENSE +20 -0
  62. data/templates/application/merb_plugin/README +4 -0
  63. data/templates/application/merb_plugin/Rakefile +59 -0
  64. data/templates/application/merb_plugin/TODO +5 -0
  65. data/templates/application/merb_plugin/lib/%base_name%.rb +18 -0
  66. data/templates/application/merb_plugin/lib/%base_name%/merbtasks.rb +6 -0
  67. data/templates/application/merb_plugin/spec/%base_name%_spec.rb +7 -0
  68. data/templates/application/merb_plugin/spec/spec_helper.rb +2 -0
  69. data/templates/application/merb_plugin/test/%base_name%_test.rb +0 -0
  70. data/templates/application/merb_plugin/test/test_helper.rb +2 -0
  71. data/templates/application/merb_very_flat/application.rbt +17 -0
  72. data/templates/application/slice/full/LICENSE +20 -0
  73. data/templates/application/slice/full/README +170 -0
  74. data/templates/application/slice/full/Rakefile +48 -0
  75. data/templates/application/slice/full/TODO +15 -0
  76. data/templates/application/slice/full/app/controllers/application.rb +5 -0
  77. data/templates/application/slice/full/app/controllers/main.rb +7 -0
  78. data/templates/application/slice/full/app/helpers/application_helper.rb +64 -0
  79. data/templates/application/slice/full/app/views/layout/%underscored_base_name%.html.erb +16 -0
  80. data/templates/application/slice/full/app/views/main/index.html.erb +1 -0
  81. data/templates/application/slice/full/lib/%base_name%.rb +78 -0
  82. data/templates/application/slice/full/lib/%base_name%/merbtasks.rb +166 -0
  83. data/templates/application/slice/full/lib/%base_name%/slicetasks.rb +18 -0
  84. data/templates/application/slice/full/public/javascripts/master.js +0 -0
  85. data/templates/application/slice/full/public/stylesheets/master.css +2 -0
  86. data/templates/application/slice/full/spec/%base_name%_spec.rb +130 -0
  87. data/templates/application/slice/full/spec/controllers/main_spec.rb +61 -0
  88. data/templates/application/slice/full/spec/spec_helper.rb +44 -0
  89. data/templates/application/slice/full/stubs/app/controllers/application.rb +2 -0
  90. data/templates/application/slice/full/stubs/app/controllers/main.rb +2 -0
  91. data/templates/application/slice/thin/LICENSE +20 -0
  92. data/templates/application/slice/thin/README +130 -0
  93. data/templates/application/slice/thin/Rakefile +46 -0
  94. data/templates/application/slice/thin/TODO +7 -0
  95. data/templates/application/slice/thin/application.rb +36 -0
  96. data/templates/application/slice/thin/lib/%base_name%.rb +93 -0
  97. data/templates/application/slice/thin/lib/%base_name%/merbtasks.rb +106 -0
  98. data/templates/application/slice/thin/lib/%base_name%/slicetasks.rb +18 -0
  99. data/templates/application/slice/thin/public/javascripts/master.js +0 -0
  100. data/templates/application/slice/thin/public/stylesheets/master.css +2 -0
  101. data/templates/application/slice/thin/stubs/application.rb +9 -0
  102. data/templates/application/slice/thin/views/layout/%underscored_base_name%.html.erb +16 -0
  103. data/templates/application/slice/thin/views/main/index.html.erb +1 -0
  104. data/templates/application/slice/very_thin/LICENSE +20 -0
  105. data/templates/application/slice/very_thin/README +110 -0
  106. data/templates/application/slice/very_thin/Rakefile +46 -0
  107. data/templates/application/slice/very_thin/TODO +7 -0
  108. data/templates/application/slice/very_thin/application.rb +36 -0
  109. data/templates/application/slice/very_thin/lib/%base_name%.rb +89 -0
  110. data/templates/application/slice/very_thin/lib/%base_name%/merbtasks.rb +106 -0
  111. data/templates/application/slice/very_thin/lib/%base_name%/slicetasks.rb +18 -0
  112. data/templates/component/controller/app/controllers/%file_name%.rb +11 -0
  113. data/templates/component/controller/app/views/%file_name%/index.html.erb +1 -0
  114. data/templates/component/controller/spec/controllers/%file_name%_spec.rb +7 -0
  115. data/templates/component/controller/test/controllers/%file_name%_test.rb +17 -0
  116. data/templates/component/freezer/script/frozen_merb +43 -0
  117. data/templates/component/helper/app/helpers/%file_name%_helper.rb +7 -0
  118. data/templates/component/helper/spec/helpers/%file_name%_helper_spec.rb +5 -0
  119. data/templates/component/migration/activerecord/schema/migrations/%file_name%.rb +19 -0
  120. data/templates/component/migration/datamapper/schema/migrations/%file_name%.rb +7 -0
  121. data/templates/component/migration/sequel/schema/migrations/%file_name%.rb +24 -0
  122. data/templates/component/model/activerecord/app/models/%file_name%.rb +2 -0
  123. data/templates/component/model/datamapper/app/models/%file_name%.rb +6 -0
  124. data/templates/component/model/none/app/models/%file_name%.rb +5 -0
  125. data/templates/component/model/rspec/spec/models/%file_name%_spec.rb +7 -0
  126. data/templates/component/model/sequel/app/models/%file_name%.rb +2 -0
  127. data/templates/component/model/test_unit/test/models/%file_name%_test.rb +9 -0
  128. data/templates/component/part_controller/app/parts/%file_name%_part.rb +9 -0
  129. data/templates/component/part_controller/app/parts/views/%file_name%_part/index.html.erb +3 -0
  130. data/templates/component/resource_controller/activerecord/app/controllers/%file_name%.rb +57 -0
  131. data/templates/component/resource_controller/activerecord/app/views/%file_name%/edit.html.erb +3 -0
  132. data/templates/component/resource_controller/activerecord/app/views/%file_name%/index.html.erb +3 -0
  133. data/templates/component/resource_controller/activerecord/app/views/%file_name%/new.html.erb +3 -0
  134. data/templates/component/resource_controller/activerecord/app/views/%file_name%/show.html.erb +3 -0
  135. data/templates/component/resource_controller/datamapper/app/controllers/%file_name%.rb +59 -0
  136. data/templates/component/resource_controller/datamapper/app/views/%file_name%/edit.html.erb +21 -0
  137. data/templates/component/resource_controller/datamapper/app/views/%file_name%/index.html.erb +24 -0
  138. data/templates/component/resource_controller/datamapper/app/views/%file_name%/new.html.erb +20 -0
  139. data/templates/component/resource_controller/datamapper/app/views/%file_name%/show.html.erb +14 -0
  140. data/templates/component/resource_controller/none/app/controllers/%file_name%.rb +36 -0
  141. data/templates/component/resource_controller/none/app/views/%file_name%/edit.html.erb +3 -0
  142. data/templates/component/resource_controller/none/app/views/%file_name%/index.html.erb +3 -0
  143. data/templates/component/resource_controller/none/app/views/%file_name%/new.html.erb +3 -0
  144. data/templates/component/resource_controller/none/app/views/%file_name%/show.html.erb +3 -0
  145. data/templates/component/resource_controller/sequel/app/controllers/%file_name%.rb +59 -0
  146. data/templates/component/resource_controller/sequel/app/views/%file_name%/edit.html.erb +3 -0
  147. data/templates/component/resource_controller/sequel/app/views/%file_name%/index.html.erb +3 -0
  148. data/templates/component/resource_controller/sequel/app/views/%file_name%/new.html.erb +3 -0
  149. data/templates/component/resource_controller/sequel/app/views/%file_name%/show.html.erb +3 -0
  150. data/templates/component/session_migration/activerecord/schema/migrations/%version%_sessions.rb +12 -0
  151. data/templates/component/session_migration/sequel/schema/migrations/%version%_sessions.rb +16 -0
  152. metadata +362 -0
@@ -0,0 +1,18 @@
1
+ namespace :slices do
2
+ namespace :<%= underscored_name %> do
3
+
4
+ # add your own <%= base_name %> tasks here
5
+
6
+ # implement this to test for structural/code dependencies
7
+ # like certain directories or availability of other files
8
+ desc "Test for any dependencies"
9
+ task :preflight do
10
+ end
11
+
12
+ # implement this to perform any database related setup steps
13
+ desc "Migrate the database"
14
+ task :migrate do
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,2 @@
1
+ html, body { margin: 0; padding: 0; }
2
+ #container { width: 800px; margin: 4em auto; padding: 4em 4em 6em 4em; background: #DDDDDD; }
@@ -0,0 +1,130 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "<%= module_name %> (module)" do
4
+
5
+ it "should have proper specs"
6
+
7
+ # Feel free to remove the specs below
8
+
9
+ before :all do
10
+ Merb::Router.prepare { |r| r.add_slice(:<%= module_name %>) } if standalone?
11
+ end
12
+
13
+ after :all do
14
+ Merb::Router.reset! if standalone?
15
+ end
16
+
17
+ it "should be registered in Merb::Slices.slices" do
18
+ Merb::Slices.slices.should include(<%= module_name %>)
19
+ end
20
+
21
+ it "should be registered in Merb::Slices.paths" do
22
+ Merb::Slices.paths[<%= module_name %>.name].should == current_slice_root
23
+ end
24
+
25
+ it "should have an :identifier property" do
26
+ <%= module_name %>.identifier.should == "<%= base_name %>"
27
+ end
28
+
29
+ it "should have an :identifier_sym property" do
30
+ <%= module_name %>.identifier_sym.should == :<%= underscored_name %>
31
+ end
32
+
33
+ it "should have a :root property" do
34
+ <%= module_name %>.root.should == Merb::Slices.paths[<%= module_name %>.name]
35
+ <%= module_name %>.root_path('app').should == current_slice_root / 'app'
36
+ end
37
+
38
+ it "should have a :file property" do
39
+ <%= module_name %>.file.should == current_slice_root / 'lib' / '<%= base_name %>.rb'
40
+ end
41
+
42
+ it "should have metadata properties" do
43
+ <%= module_name %>.description.should == "<%= module_name %> is a chunky Merb slice!"
44
+ <%= module_name %>.version.should == "0.0.1"
45
+ <%= module_name %>.author.should == "YOUR NAME"
46
+ end
47
+
48
+ it "should have :routes and :named_routes properties" do
49
+ <%= module_name %>.routes.should_not be_empty
50
+ <%= module_name %>.named_routes[:<%= underscored_name %>_index].should be_kind_of(Merb::Router::Route)
51
+ end
52
+
53
+ it "should have an url helper method for slice-specific routes" do
54
+ <%= module_name %>.url(:controller => 'main', :action => 'show', :format => 'html').should == "/<%= base_name %>/main/show.html"
55
+ <%= module_name %>.url(:<%= underscored_name %>_index, :format => 'html').should == "/<%= base_name %>/index.html"
56
+ end
57
+
58
+ it "should have a config property (Hash)" do
59
+ <%= module_name %>.config.should be_kind_of(Hash)
60
+ end
61
+
62
+ it "should have bracket accessors as shortcuts to the config" do
63
+ <%= module_name %>[:foo] = 'bar'
64
+ <%= module_name %>[:foo].should == 'bar'
65
+ <%= module_name %>[:foo].should == <%= module_name %>.config[:foo]
66
+ end
67
+
68
+ it "should have a :layout config option set" do
69
+ <%= module_name %>.config[:layout].should == :<%= underscored_name %>
70
+ end
71
+
72
+ it "should have a dir_for method" do
73
+ app_path = <%= module_name %>.dir_for(:application)
74
+ app_path.should == current_slice_root / 'app'
75
+ [:view, :model, :controller, :helper, :mailer, :part].each do |type|
76
+ <%= module_name %>.dir_for(type).should == app_path / "#{type}s"
77
+ end
78
+ public_path = <%= module_name %>.dir_for(:public)
79
+ public_path.should == current_slice_root / 'public'
80
+ [:stylesheet, :javascript, :image].each do |type|
81
+ <%= module_name %>.dir_for(type).should == public_path / "#{type}s"
82
+ end
83
+ end
84
+
85
+ it "should have a app_dir_for method" do
86
+ root_path = <%= module_name %>.app_dir_for(:root)
87
+ root_path.should == Merb.root / 'slices' / '<%= base_name %>'
88
+ app_path = <%= module_name %>.app_dir_for(:application)
89
+ app_path.should == root_path / 'app'
90
+ [:view, :model, :controller, :helper, :mailer, :part].each do |type|
91
+ <%= module_name %>.app_dir_for(type).should == app_path / "#{type}s"
92
+ end
93
+ public_path = <%= module_name %>.app_dir_for(:public)
94
+ public_path.should == Merb.dir_for(:public) / 'slices' / '<%= base_name %>'
95
+ [:stylesheet, :javascript, :image].each do |type|
96
+ <%= module_name %>.app_dir_for(type).should == public_path / "#{type}s"
97
+ end
98
+ end
99
+
100
+ it "should have a public_dir_for method" do
101
+ public_path = <%= module_name %>.public_dir_for(:public)
102
+ public_path.should == '/slices' / '<%= base_name %>'
103
+ [:stylesheet, :javascript, :image].each do |type|
104
+ <%= module_name %>.public_dir_for(type).should == public_path / "#{type}s"
105
+ end
106
+ end
107
+
108
+ it "should have a public_path_for method" do
109
+ public_path = <%= module_name %>.public_dir_for(:public)
110
+ <%= module_name %>.public_path_for("path", "to", "file").should == public_path / "path" / "to" / "file"
111
+ [:stylesheet, :javascript, :image].each do |type|
112
+ <%= module_name %>.public_path_for(type, "path", "to", "file").should == public_path / "#{type}s" / "path" / "to" / "file"
113
+ end
114
+ end
115
+
116
+ it "should have a app_path_for method" do
117
+ <%= module_name %>.app_path_for("path", "to", "file").should == <%= module_name %>.app_dir_for(:root) / "path" / "to" / "file"
118
+ <%= module_name %>.app_path_for(:controller, "path", "to", "file").should == <%= module_name %>.app_dir_for(:controller) / "path" / "to" / "file"
119
+ end
120
+
121
+ it "should have a slice_path_for method" do
122
+ <%= module_name %>.slice_path_for("path", "to", "file").should == <%= module_name %>.dir_for(:root) / "path" / "to" / "file"
123
+ <%= module_name %>.slice_path_for(:controller, "path", "to", "file").should == <%= module_name %>.dir_for(:controller) / "path" / "to" / "file"
124
+ end
125
+
126
+ it "should keep a list of path component types to use when copying files" do
127
+ (<%= module_name %>.mirrored_components & <%= module_name %>.slice_paths.keys).length.should == <%= module_name %>.mirrored_components.length
128
+ end
129
+
130
+ end
@@ -0,0 +1,61 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "<%= module_name %>::Main (controller)" do
4
+
5
+ # Feel free to remove the specs below
6
+
7
+ before :all do
8
+ Merb::Router.prepare { |r| r.add_slice(:<%= module_name %>) } if standalone?
9
+ end
10
+
11
+ after :all do
12
+ Merb::Router.reset! if standalone?
13
+ end
14
+
15
+ it "should have access to the slice module" do
16
+ controller = dispatch_to(<%= module_name %>::Main, :index)
17
+ controller.slice.should == <%= module_name %>
18
+ controller.slice.should == <%= module_name %>::Main.slice
19
+ end
20
+
21
+ it "should have an index action" do
22
+ controller = dispatch_to(<%= module_name %>::Main, :index)
23
+ controller.status.should == 200
24
+ controller.body.should contain('<%= module_name %>')
25
+ end
26
+
27
+ it "should work with the default route" do
28
+ controller = get("/<%= base_name %>/main/index")
29
+ controller.should be_kind_of(<%= module_name %>::Main)
30
+ controller.action_name.should == 'index'
31
+ end
32
+
33
+ it "should work with the example named route" do
34
+ controller = get("/<%= base_name %>/index.html")
35
+ controller.should be_kind_of(<%= module_name %>::Main)
36
+ controller.action_name.should == 'index'
37
+ end
38
+
39
+ it "should have routes in <%= module_name %>.routes" do
40
+ <%= module_name %>.routes.should_not be_empty
41
+ end
42
+
43
+ it "should have a slice_url helper method for slice-specific routes" do
44
+ controller = dispatch_to(<%= module_name %>::Main, 'index')
45
+ controller.slice_url(:action => 'show', :format => 'html').should == "/<%= base_name %>/main/show.html"
46
+ controller.slice_url(:<%= underscored_name %>_index, :format => 'html').should == "/<%= base_name %>/index.html"
47
+ end
48
+
49
+ it "should have helper methods for dealing with public paths" do
50
+ controller = dispatch_to(<%= module_name %>::Main, :index)
51
+ controller.public_path_for(:image).should == "/slices/<%= base_name %>/images"
52
+ controller.public_path_for(:javascript).should == "/slices/<%= base_name %>/javascripts"
53
+ controller.public_path_for(:stylesheet).should == "/slices/<%= base_name %>/stylesheets"
54
+ end
55
+
56
+ it "should have a slice-specific _template_root" do
57
+ <%= module_name %>::Main._template_root.should == <%= module_name %>.dir_for(:view)
58
+ <%= module_name %>::Main._template_root.should == <%= module_name %>::Application._template_root
59
+ end
60
+
61
+ end
@@ -0,0 +1,44 @@
1
+ require 'rubygems'
2
+ require 'merb-core'
3
+ require 'merb-slices'
4
+ require 'spec'
5
+
6
+ # Add <%= base_name %>.rb to the search path
7
+ Merb::Plugins.config[:merb_slices][:auto_register] = true
8
+ Merb::Plugins.config[:merb_slices][:search_path] = File.join(File.dirname(__FILE__), '..', 'lib', '<%= base_name %>.rb')
9
+
10
+ # Using Merb.root below makes sure that the correct root is set for
11
+ # - testing standalone, without being installed as a gem and no host application
12
+ # - testing from within the host application; its root will be used
13
+ Merb.start_environment(
14
+ :testing => true,
15
+ :adapter => 'runner',
16
+ :environment => ENV['MERB_ENV'] || 'test',
17
+ :merb_root => Merb.root,
18
+ :session_store => 'memory'
19
+ )
20
+
21
+ module Merb
22
+ module Test
23
+ module SliceHelper
24
+
25
+ # The absolute path to the current slice
26
+ def current_slice_root
27
+ @current_slice_root ||= File.expand_path(File.join(File.dirname(__FILE__), '..'))
28
+ end
29
+
30
+ # Whether the specs are being run from a host application or standalone
31
+ def standalone?
32
+ Merb.root == ::<%= module_name %>.root
33
+ end
34
+
35
+ end
36
+ end
37
+ end
38
+
39
+ Spec::Runner.configure do |config|
40
+ config.include(Merb::Test::ViewHelper)
41
+ config.include(Merb::Test::RouteHelper)
42
+ config.include(Merb::Test::ControllerHelper)
43
+ config.include(Merb::Test::SliceHelper)
44
+ end
@@ -0,0 +1,2 @@
1
+ class <%= module_name %>::Application < Merb::Controller
2
+ end
@@ -0,0 +1,2 @@
1
+ class <%= module_name %>::Main < <%= module_name %>::Application
2
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) <%= Time.now.year %> YOUR NAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,130 @@
1
+ <%= module_name %>
2
+ <%= "=" * module_name.size %>
3
+
4
+ A thin slice for the Merb framework.
5
+
6
+ ------------------------------------------------------------------------------
7
+
8
+ <%= base_name %>
9
+ |-- LICENSE
10
+ |-- README
11
+ |-- Rakefile [1]
12
+ |-- TODO
13
+ |-- application.rb [2]
14
+ |-- lib
15
+ | |-- <%= base_name %>
16
+ | | |-- merbtasks.rb [3]
17
+ | | `-- slicetasks.rb [4]
18
+ | `-- <%= base_name %>.rb [5]
19
+ |-- public [6]
20
+ | |-- javascripts
21
+ | | `-- master.js
22
+ | `-- stylesheets
23
+ | `-- master.css
24
+ |-- stubs [7]
25
+ | `-- application.rb
26
+ `-- views [8]
27
+ |-- layout
28
+ | `-- <%= underscored_name %>.html.erb [9]
29
+ `-- main
30
+ `-- index.html.erb
31
+
32
+
33
+ 1. Rake tasks to package/install the gem - edit this to modify the manifest.
34
+ 2. The slice application in a single file: controllers, models, helper methods.
35
+ 3. Standard rake tasks available to your application.
36
+ 4. Your custom application rake tasks.
37
+ 5. The main slice file - contains all slice setup logic/config.
38
+ 6. Public assets you (optionally) install using rake slices:my_slice:install
39
+ 7. Stubs of classes/views/files for the end-user to override - usually these
40
+ mimic the files in app/ and/or public/; use rake slices:<%= underscored_name %>:stubs to
41
+ get started with the override stubs. Also, slices:<%= underscored_name %>:patch will
42
+ copy over views to override in addition to the files found in /stubs.
43
+ 8. A thin slice stores its views seperately.
44
+ 9. The default layout, as specified in Merb::Slices::config[:my_slice][:layout]
45
+ change this to :application to use the app's layout.
46
+
47
+
48
+ To see all available tasks for <%= module_name %> run:
49
+
50
+ rake -T slices:<%= underscored_name %>
51
+
52
+ ------------------------------------------------------------------------------
53
+
54
+ Instructions for installation:
55
+
56
+ file: config/init.rb
57
+
58
+ # add the slice as a regular dependency
59
+
60
+ dependency '<%= base_name %>'
61
+
62
+ # if needed, configure which slices to load and in which order
63
+
64
+ Merb::Plugins.config[:merb_slices] = { :queue => ["<%= module_name %>", ...] }
65
+
66
+ # optionally configure the plugins in a before_app_loads callback
67
+
68
+ Merb::BootLoader.before_app_loads do
69
+
70
+ Merb::Slices::config[:<%= underscored_name %>][:option] = value
71
+
72
+ end
73
+
74
+ file: config/router.rb
75
+
76
+ # example: /<%= base_name %>/:controller/:action/:id
77
+
78
+ r.add_slice(:<%= module_name %>)
79
+
80
+ # example: /foo/:controller/:action/:id
81
+
82
+ r.add_slice(:<%= module_name %>, 'foo') # same as :path => 'foo'
83
+
84
+ # example: /:lang/:controller/:action/:id (with :a param set)
85
+
86
+ r.add_slice(:<%= module_name %>, :path => ':lang', :params => { :a => 'b' })
87
+
88
+ # example: /:controller/:action/:id
89
+
90
+ r.slice(:<%= module_name %>)
91
+
92
+ Normally you should also run the following rake task:
93
+
94
+ rake slices:<%= underscored_name %>:install
95
+
96
+ ------------------------------------------------------------------------------
97
+
98
+ About Slices
99
+ ============
100
+
101
+ Merb-Slices is a Merb plugin for using and creating application 'slices' which
102
+ help you modularize your application. Usually these are reuseable extractions
103
+ from your main app. In effect, a Slice is just like a regular Merb MVC
104
+ application, both in functionality as well as in structure.
105
+
106
+ When you generate a Slice stub structure, a module is setup to serve as a
107
+ namespace for your controller, models, helpers etc. This ensures maximum
108
+ encapsulation. You could say a Slice is a mixture between a Merb plugin (a
109
+ Gem) and a Merb application, reaping the benefits of both.
110
+
111
+ A host application can 'mount' a Slice inside the router, which means you have
112
+ full over control how it integrates. By default a Slice's routes are prefixed
113
+ by its name (a router :namespace), but you can easily provide your own prefix
114
+ or leave it out, mounting it at the root of your url-schema. You can even
115
+ mount a Slice multiple times and give extra parameters to customize an
116
+ instance's behaviour.
117
+
118
+ A Slice's Application controller uses controller_for_slice to setup slice
119
+ specific behaviour, which mainly affects cascaded view handling. Additionaly,
120
+ this method is available to any kind of controller, so it can be used for
121
+ Merb Mailer too for example.
122
+
123
+ There are many ways which let you customize a Slice's functionality and
124
+ appearance without ever touching the Gem-level code itself. It's not only easy
125
+ to add template/layout overrides, you can also add/modify controllers, models
126
+ and other runtime code from within the host application.
127
+
128
+ To create your own Slice run this (somewhere outside of your merb app):
129
+
130
+ $ merb-gen slice <your-lowercase-slice-name>
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'merb-core/version'
4
+ require 'merb-core/tasks/merb_rake_helper'
5
+
6
+ NAME = "<%= base_name %>"
7
+ AUTHOR = "Your Name"
8
+ EMAIL = "Your Email"
9
+ HOMEPAGE = "http://merbivore.com/"
10
+ SUMMARY = "Merb Slice that provides ..."
11
+ GEM_VERSION = "<%= Merb::VERSION %>"
12
+
13
+ spec = Gem::Specification.new do |s|
14
+ s.rubyforge_project = 'merb'
15
+ s.name = NAME
16
+ s.version = GEM_VERSION
17
+ s.platform = Gem::Platform::RUBY
18
+ s.has_rdoc = true
19
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
20
+ s.summary = SUMMARY
21
+ s.description = s.summary
22
+ s.author = AUTHOR
23
+ s.email = EMAIL
24
+ s.homepage = HOMEPAGE
25
+ s.add_dependency('merb-slices', '>= <%= Merb::VERSION %>')
26
+ s.require_path = 'lib'
27
+ s.files = %w(LICENSE README Rakefile TODO application.rb) + Dir.glob("{lib,public,views,stubs}/**/*")
28
+ end
29
+
30
+ Rake::GemPackageTask.new(spec) do |pkg|
31
+ pkg.gem_spec = spec
32
+ end
33
+
34
+ desc "Install <%= module_name %> as a gem"
35
+ task :install => [:package] do
36
+ sh %{#{sudo} gem install pkg/#{NAME}-#{GEM_VERSION} --no-update-sources}
37
+ end
38
+
39
+ namespace :jruby do
40
+
41
+ desc "Run :package and install the resulting .gem with jruby"
42
+ task :install => :package do
43
+ sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
44
+ end
45
+
46
+ end