merb-slices 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/Generators +4 -0
  2. data/LICENSE +20 -0
  3. data/README +102 -0
  4. data/Rakefile +65 -0
  5. data/TODO +0 -0
  6. data/lib/generators/base.rb +21 -0
  7. data/lib/generators/full.rb +21 -0
  8. data/lib/generators/templates/full/LICENSE +20 -0
  9. data/lib/generators/templates/full/README +170 -0
  10. data/lib/generators/templates/full/Rakefile +48 -0
  11. data/lib/generators/templates/full/TODO +15 -0
  12. data/lib/generators/templates/full/app/controllers/application.rb +5 -0
  13. data/lib/generators/templates/full/app/controllers/main.rb +7 -0
  14. data/lib/generators/templates/full/app/helpers/application_helper.rb +64 -0
  15. data/lib/generators/templates/full/app/views/layout/%symbol_name%.html.erb +16 -0
  16. data/lib/generators/templates/full/app/views/main/index.html.erb +1 -0
  17. data/lib/generators/templates/full/lib/%base_name%.rb +78 -0
  18. data/lib/generators/templates/full/lib/%base_name%/merbtasks.rb +166 -0
  19. data/lib/generators/templates/full/lib/%base_name%/slicetasks.rb +18 -0
  20. data/lib/generators/templates/full/public/javascripts/master.js +0 -0
  21. data/lib/generators/templates/full/public/stylesheets/master.css +2 -0
  22. data/lib/generators/templates/full/spec/%base_name%_spec.rb +130 -0
  23. data/lib/generators/templates/full/spec/controllers/main_spec.rb +61 -0
  24. data/lib/generators/templates/full/spec/spec_helper.rb +44 -0
  25. data/lib/generators/templates/full/stubs/app/controllers/application.rb +2 -0
  26. data/lib/generators/templates/full/stubs/app/controllers/main.rb +2 -0
  27. data/lib/generators/templates/thin/LICENSE +20 -0
  28. data/lib/generators/templates/thin/README +130 -0
  29. data/lib/generators/templates/thin/Rakefile +46 -0
  30. data/lib/generators/templates/thin/TODO +7 -0
  31. data/lib/generators/templates/thin/application.rb +36 -0
  32. data/lib/generators/templates/thin/lib/%base_name%.rb +93 -0
  33. data/lib/generators/templates/thin/lib/%base_name%/merbtasks.rb +106 -0
  34. data/lib/generators/templates/thin/lib/%base_name%/slicetasks.rb +18 -0
  35. data/lib/generators/templates/thin/public/javascripts/master.js +0 -0
  36. data/lib/generators/templates/thin/public/stylesheets/master.css +2 -0
  37. data/lib/generators/templates/thin/stubs/application.rb +9 -0
  38. data/lib/generators/templates/thin/views/layout/%symbol_name%.html.erb +16 -0
  39. data/lib/generators/templates/thin/views/main/index.html.erb +1 -0
  40. data/lib/generators/templates/very_thin/LICENSE +20 -0
  41. data/lib/generators/templates/very_thin/README +110 -0
  42. data/lib/generators/templates/very_thin/Rakefile +46 -0
  43. data/lib/generators/templates/very_thin/TODO +7 -0
  44. data/lib/generators/templates/very_thin/application.rb +36 -0
  45. data/lib/generators/templates/very_thin/lib/%base_name%.rb +89 -0
  46. data/lib/generators/templates/very_thin/lib/%base_name%/merbtasks.rb +106 -0
  47. data/lib/generators/templates/very_thin/lib/%base_name%/slicetasks.rb +18 -0
  48. data/lib/generators/thin.rb +21 -0
  49. data/lib/generators/very_thin.rb +21 -0
  50. data/lib/merb-slices.rb +126 -0
  51. data/lib/merb-slices/controller_mixin.rb +129 -0
  52. data/lib/merb-slices/merbtasks.rb +19 -0
  53. data/lib/merb-slices/module.rb +338 -0
  54. data/lib/merb-slices/module_mixin.rb +535 -0
  55. data/lib/merb-slices/router_ext.rb +75 -0
  56. data/spec/full_slice_generator_spec.rb +21 -0
  57. data/spec/merb-slice_spec.rb +7 -0
  58. data/spec/slice_generator_spec.rb +22 -0
  59. data/spec/spec_helper.rb +9 -0
  60. data/spec/thin_slice_generator_spec.rb +21 -0
  61. data/spec/very_thin_slice_generator_spec.rb +21 -0
  62. metadata +157 -0
@@ -0,0 +1,15 @@
1
+ TODO:
2
+
3
+ - Fix <%= module_name %>.description and <%= module_name %>.version
4
+ - Fix LICENSE with your name
5
+ - Fix Rakefile with your name and contact info
6
+ - Add your code to lib/<%= base_name %>.rb
7
+ - Add your Merb rake tasks to lib/<%= base_name %>/merbtasks.rb
8
+
9
+ Remove anything that you don't need:
10
+
11
+ - app/controllers/main.rb <%= module_name %>::Main controller
12
+ - app/views/layout/<%= base_name %>.html.erb
13
+ - spec/controllers/main_spec.rb controller specs
14
+ - public/* any public files
15
+ - stubs/* any stub files
@@ -0,0 +1,5 @@
1
+ class <%= module_name %>::Application < Merb::Controller
2
+
3
+ controller_for_slice
4
+
5
+ end
@@ -0,0 +1,7 @@
1
+ class <%= module_name %>::Main < <%= module_name %>::Application
2
+
3
+ def index
4
+ render
5
+ end
6
+
7
+ end
@@ -0,0 +1,64 @@
1
+ module Merb
2
+ module <%= module_name %>
3
+ module ApplicationHelper
4
+
5
+ # @param *segments<Array[#to_s]> Path segments to append.
6
+ #
7
+ # @return <String>
8
+ # A path relative to the public directory, with added segments.
9
+ def image_path(*segments)
10
+ public_path_for(:image, *segments)
11
+ end
12
+
13
+ # @param *segments<Array[#to_s]> Path segments to append.
14
+ #
15
+ # @return <String>
16
+ # A path relative to the public directory, with added segments.
17
+ def javascript_path(*segments)
18
+ public_path_for(:javascript, *segments)
19
+ end
20
+
21
+ # @param *segments<Array[#to_s]> Path segments to append.
22
+ #
23
+ # @return <String>
24
+ # A path relative to the public directory, with added segments.
25
+ def stylesheet_path(*segments)
26
+ public_path_for(:stylesheet, *segments)
27
+ end
28
+
29
+ # Construct a path relative to the public directory
30
+ #
31
+ # @param <Symbol> The type of component.
32
+ # @param *segments<Array[#to_s]> Path segments to append.
33
+ #
34
+ # @return <String>
35
+ # A path relative to the public directory, with added segments.
36
+ def public_path_for(type, *segments)
37
+ ::<%= module_name %>.public_path_for(type, *segments)
38
+ end
39
+
40
+ # Construct an app-level path.
41
+ #
42
+ # @param <Symbol> The type of component.
43
+ # @param *segments<Array[#to_s]> Path segments to append.
44
+ #
45
+ # @return <String>
46
+ # A path within the host application, with added segments.
47
+ def app_path_for(type, *segments)
48
+ ::<%= module_name %>.app_path_for(type, *segments)
49
+ end
50
+
51
+ # Construct a slice-level path.
52
+ #
53
+ # @param <Symbol> The type of component.
54
+ # @param *segments<Array[#to_s]> Path segments to append.
55
+ #
56
+ # @return <String>
57
+ # A path within the slice source (Gem), with added segments.
58
+ def slice_path_for(type, *segments)
59
+ ::<%= module_name %>.slice_path_for(type, *segments)
60
+ end
61
+
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
+ <title>Fresh <%= module_name %> Slice</title>
6
+ <link href="<%%= public_path_for :stylesheet, 'master.css' %>" type="text/css" charset="utf-8" rel="stylesheet" media="all" />
7
+ <script src="<%%= public_path_for :javascript, 'master.js' %>" type="text/javascript" charset="utf-8"></script>
8
+ </head>
9
+ <!-- you can override this layout at slices/<%= base_name %>/app/views/layout/<%= base_name %>.html.erb -->
10
+ <body class="<%= base_name %>-slice">
11
+ <div id="container">
12
+ <h1><%= module_name %> Slice</h1>
13
+ <div id="main"><%%= catch_content :for_layout %></div>
14
+ </div>
15
+ </body>
16
+ </html>
@@ -0,0 +1 @@
1
+ <strong><%%= slice.description %></strong> (v. <%%= slice.version %>)
@@ -0,0 +1,78 @@
1
+ if defined?(Merb::Plugins)
2
+
3
+ $:.unshift File.dirname(__FILE__)
4
+
5
+ load_dependency 'merb-slices'
6
+ Merb::Plugins.add_rakefiles "<%= base_name %>/merbtasks", "<%= base_name %>/slicetasks"
7
+
8
+ # Register the Slice for the current host application
9
+ Merb::Slices::register(__FILE__)
10
+
11
+ # Slice configuration - set this in a before_app_loads callback.
12
+ # By default a Slice uses its own layout, so you can swicht to
13
+ # the main application layout or no layout at all if needed.
14
+ #
15
+ # Configuration options:
16
+ # :layout - the layout to use; defaults to :<%= base_name %>
17
+ # :mirror - which path component types to use on copy operations; defaults to all
18
+ Merb::Slices::config[:<%= symbol_name %>][:layout] ||= :<%= symbol_name %>
19
+
20
+ # All Slice code is expected to be namespaced inside a module
21
+ module <%= module_name %>
22
+
23
+ # Slice metadata
24
+ self.description = "<%= module_name %> is a chunky Merb slice!"
25
+ self.version = "0.0.1"
26
+ self.author = "YOUR NAME"
27
+
28
+ # Stub classes loaded hook - runs before LoadClasses BootLoader
29
+ # right after a slice's classes have been loaded internally.
30
+ def self.loaded
31
+ end
32
+
33
+ # Initialization hook - runs before AfterAppLoads BootLoader
34
+ def self.init
35
+ end
36
+
37
+ # Activation hook - runs after AfterAppLoads BootLoader
38
+ def self.activate
39
+ end
40
+
41
+ # Deactivation hook - triggered by Merb::Slices.deactivate(<%= module_name %>)
42
+ def self.deactivate
43
+ end
44
+
45
+ # Setup routes inside the host application
46
+ #
47
+ # @param scope<Merb::Router::Behaviour>
48
+ # Routes will be added within this scope (namespace). In fact, any
49
+ # router behaviour is a valid namespace, so you can attach
50
+ # routes at any level of your router setup.
51
+ #
52
+ # @note prefix your named routes with :<%= symbol_name %>_
53
+ # to avoid potential conflicts with global named routes.
54
+ def self.setup_router(scope)
55
+ # example of a named route
56
+ scope.match('/index.:format').to(:controller => 'main', :action => 'index').name(:<%= symbol_name %>_index)
57
+ end
58
+
59
+ end
60
+
61
+ # Setup the slice layout for <%= module_name %>
62
+ #
63
+ # Use <%= module_name %>.push_path and <%= module_name %>.push_app_path
64
+ # to set paths to <%= base_name %>-level and app-level paths. Example:
65
+ #
66
+ # <%= module_name %>.push_path(:application, <%= module_name %>.root)
67
+ # <%= module_name %>.push_app_path(:application, Merb.root / 'slices' / '<%= base_name %>')
68
+ # ...
69
+ #
70
+ # Any component path that hasn't been set will default to <%= module_name %>.root
71
+ #
72
+ # Or just call setup_default_structure! to setup a basic Merb MVC structure.
73
+ <%= module_name %>.setup_default_structure!
74
+
75
+ # Add dependencies for other <%= module_name %> classes below. Example:
76
+ # dependency "<%= base_name %>/other"
77
+
78
+ end
@@ -0,0 +1,166 @@
1
+ namespace :slices do
2
+ namespace :<%= symbol_name %> do
3
+
4
+ desc "Install <%= module_name %>"
5
+ task :install => [:preflight, :setup_directories, :copy_assets, :migrate]
6
+
7
+ desc "Test for any dependencies"
8
+ task :preflight do # see slicetasks.rb
9
+ end
10
+
11
+ desc "Setup directories"
12
+ task :setup_directories do
13
+ puts "Creating directories for host application"
14
+ <%= module_name %>.mirrored_components.each do |type|
15
+ if File.directory?(<%= module_name %>.dir_for(type))
16
+ if !File.directory?(dst_path = <%= module_name %>.app_dir_for(type))
17
+ relative_path = dst_path.relative_path_from(Merb.root)
18
+ puts "- creating directory :#{type} #{File.basename(Merb.root) / relative_path}"
19
+ mkdir_p(dst_path)
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ desc "Copy stub files to host application"
26
+ task :stubs do
27
+ puts "Copying stubs for <%= module_name %> - resolves any collisions"
28
+ copied, preserved = <%= module_name %>.mirror_stubs!
29
+ puts "- no files to copy" if copied.empty? && preserved.empty?
30
+ copied.each { |f| puts "- copied #{f}" }
31
+ preserved.each { |f| puts "! preserved override as #{f}" }
32
+ end
33
+
34
+ desc "Copy stub files and views to host application"
35
+ task :patch => [ "stubs", "freeze:views" ]
36
+
37
+ desc "Copy public assets to host application"
38
+ task :copy_assets do
39
+ puts "Copying assets for <%= module_name %> - resolves any collisions"
40
+ copied, preserved = <%= module_name %>.mirror_public!
41
+ puts "- no files to copy" if copied.empty? && preserved.empty?
42
+ copied.each { |f| puts "- copied #{f}" }
43
+ preserved.each { |f| puts "! preserved override as #{f}" }
44
+ end
45
+
46
+ desc "Migrate the database"
47
+ task :migrate do # see slicetasks.rb
48
+ end
49
+
50
+ desc "Freeze <%= module_name %> into your app (only <%= base_name %>/app)"
51
+ task :freeze => [ "freeze:app" ]
52
+
53
+ namespace :freeze do
54
+
55
+ desc "Freezes <%= module_name %> by installing the gem into application/gems using merb-freezer"
56
+ task :gem do
57
+ begin
58
+ Object.const_get(:Freezer).freeze(ENV["GEM"] || "<%= base_name %>", ENV["UPDATE"], ENV["MODE"] || 'rubygems')
59
+ rescue NameError
60
+ puts "! dependency 'merb-freezer' missing"
61
+ end
62
+ end
63
+
64
+ desc "Freezes <%= module_name %> by copying all files from <%= base_name %>/app to your application"
65
+ task :app do
66
+ puts "Copying all <%= base_name %>/app files to your application - resolves any collisions"
67
+ copied, preserved = <%= module_name %>.mirror_app!
68
+ puts "- no files to copy" if copied.empty? && preserved.empty?
69
+ copied.each { |f| puts "- copied #{f}" }
70
+ preserved.each { |f| puts "! preserved override as #{f}" }
71
+ end
72
+
73
+ desc "Freeze all views into your application for easy modification"
74
+ task :views do
75
+ puts "Copying all view templates to your application - resolves any collisions"
76
+ copied, preserved = <%= module_name %>.mirror_files_for :view
77
+ puts "- no files to copy" if copied.empty? && preserved.empty?
78
+ copied.each { |f| puts "- copied #{f}" }
79
+ preserved.each { |f| puts "! preserved override as #{f}" }
80
+ end
81
+
82
+ desc "Freeze all models into your application for easy modification"
83
+ task :models do
84
+ puts "Copying all models to your application - resolves any collisions"
85
+ copied, preserved = <%= module_name %>.mirror_files_for :model
86
+ puts "- no files to copy" if copied.empty? && preserved.empty?
87
+ copied.each { |f| puts "- copied #{f}" }
88
+ preserved.each { |f| puts "! preserved override as #{f}" }
89
+ end
90
+
91
+ desc "Freezes <%= module_name %> as a gem and copies over <%= base_name %>/app"
92
+ task :app_with_gem => [:gem, :app]
93
+
94
+ desc "Freezes <%= module_name %> by unpacking all files into your application"
95
+ task :unpack do
96
+ puts "Unpacking <%= module_name %> files to your application - resolves any collisions"
97
+ copied, preserved = <%= module_name %>.unpack_slice!
98
+ puts "- no files to copy" if copied.empty? && preserved.empty?
99
+ copied.each { |f| puts "- copied #{f}" }
100
+ preserved.each { |f| puts "! preserved override as #{f}" }
101
+ end
102
+
103
+ end
104
+
105
+ desc "Run slice specs within the host application context"
106
+ task :spec => [ "spec:explain", "spec:default" ]
107
+
108
+ namespace :spec do
109
+
110
+ slice_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
111
+
112
+ task :explain do
113
+ puts "\nNote: By running <%= module_name %> specs inside the application context any\n" +
114
+ "overrides could break existing specs. This isn't always a problem,\n" +
115
+ "especially in the case of views. Use these spec tasks to check how\n" +
116
+ "well your application conforms to the original slice implementation."
117
+ end
118
+
119
+ Spec::Rake::SpecTask.new('default') do |t|
120
+ t.spec_opts = ["--format", "specdoc", "--colour"]
121
+ t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
122
+ end
123
+
124
+ desc "Run all model specs, run a spec for a specific Model with MODEL=MyModel"
125
+ Spec::Rake::SpecTask.new('model') do |t|
126
+ t.spec_opts = ["--format", "specdoc", "--colour"]
127
+ if(ENV['MODEL'])
128
+ t.spec_files = Dir["#{slice_root}/spec/models/**/#{ENV['MODEL']}_spec.rb"].sort
129
+ else
130
+ t.spec_files = Dir["#{slice_root}/spec/models/**/*_spec.rb"].sort
131
+ end
132
+ end
133
+
134
+ desc "Run all controller specs, run a spec for a specific Controller with CONTROLLER=MyController"
135
+ Spec::Rake::SpecTask.new('controller') do |t|
136
+ t.spec_opts = ["--format", "specdoc", "--colour"]
137
+ if(ENV['CONTROLLER'])
138
+ t.spec_files = Dir["#{slice_root}/spec/controllers/**/#{ENV['CONTROLLER']}_spec.rb"].sort
139
+ else
140
+ t.spec_files = Dir["#{slice_root}/spec/controllers/**/*_spec.rb"].sort
141
+ end
142
+ end
143
+
144
+ desc "Run all view specs, run specs for a specific controller (and view) with CONTROLLER=MyController (VIEW=MyView)"
145
+ Spec::Rake::SpecTask.new('view') do |t|
146
+ t.spec_opts = ["--format", "specdoc", "--colour"]
147
+ if(ENV['CONTROLLER'] and ENV['VIEW'])
148
+ t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/#{ENV['VIEW']}*_spec.rb"].sort
149
+ elsif(ENV['CONTROLLER'])
150
+ t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/*_spec.rb"].sort
151
+ else
152
+ t.spec_files = Dir["#{slice_root}/spec/views/**/*_spec.rb"].sort
153
+ end
154
+ end
155
+
156
+ desc "Run all specs and output the result in html"
157
+ Spec::Rake::SpecTask.new('html') do |t|
158
+ t.spec_opts = ["--format", "html"]
159
+ t.libs = ['lib', 'server/lib' ]
160
+ t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
161
+ end
162
+
163
+ end
164
+
165
+ end
166
+ end
@@ -0,0 +1,18 @@
1
+ namespace :slices do
2
+ namespace :<%= symbol_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 == :<%= symbol_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[:<%= base_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(:<%= symbol_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 == :<%= symbol_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