merb_screw_unit 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.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Yehuda Katz
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.
data/README ADDED
@@ -0,0 +1,170 @@
1
+ MerbScrewUnit
2
+ =============
3
+
4
+ A slice for the Merb framework.
5
+
6
+ ------------------------------------------------------------------------------
7
+
8
+ merb_screw_unit
9
+ |-- LICENSE
10
+ |-- README
11
+ |-- Rakefile [1]
12
+ |-- TODO
13
+ |-- app [2]
14
+ | |-- controllers
15
+ | | |-- application.rb
16
+ | | `-- main.rb
17
+ | |-- helpers
18
+ | | `-- application_helper.rb
19
+ | `-- views
20
+ | |-- layout
21
+ | | `-- merb_screw_unit.html.erb [3]
22
+ | `-- main
23
+ | `-- index.html.erb
24
+ |-- lib
25
+ | |-- merb_screw_unit
26
+ | | |-- merbtasks.rb [4]
27
+ | | `-- slicetasks.rb [5]
28
+ | `-- merb_screw_unit.rb [6]
29
+ |-- log
30
+ | `-- merb_test.log
31
+ |-- public [7]
32
+ | |-- javascripts
33
+ | | `-- master.js
34
+ | `-- stylesheets
35
+ | `-- master.css
36
+ |-- spec [8]
37
+ | |-- merb_screw_unit_spec.rb
38
+ | |-- controllers
39
+ | | `-- main_spec.rb
40
+ | `-- spec_helper.rb
41
+ `-- stubs [9]
42
+ `-- app
43
+ `-- controllers
44
+ |-- application.rb
45
+ `-- main.rb
46
+
47
+
48
+ 1. Rake tasks to package/install the gem - edit this to modify the manifest.
49
+ 2. The slice application: controllers, models, helpers, views.
50
+ 3. The default layout, as specified in Merb::Slices::config[:merb_screw_unit][:layout]
51
+ change this to :application to use the app's layout.
52
+ 4. Standard rake tasks available to your application.
53
+ 5. Your custom application rake tasks.
54
+ 6. The main slice file - contains all slice setup logic/config.
55
+ 7. Public assets you (optionally) install using rake slices:merb_screw_unit:install
56
+ 8. Specs for basis slice behaviour - you usually adapt these for your slice.
57
+ 9. Stubs of classes/views/files for the end-user to override - usually these
58
+ mimic the files in app/ and/or public/; use rake slices:merb_screw_unit:stubs to
59
+ get started with the override stubs. Also, slices:merb_screw_unit:patch will
60
+ copy over views to override in addition to the files found in /stubs.
61
+
62
+
63
+ To see all available tasks for MerbScrewUnit run:
64
+
65
+ rake -T slices:merb_screw_unit
66
+
67
+ ------------------------------------------------------------------------------
68
+
69
+ Instructions for installation:
70
+
71
+ file: config/init.rb
72
+
73
+ # add the slice as a regular dependency
74
+
75
+ dependency 'merb_screw_unit'
76
+
77
+ # if needed, configure which slices to load and in which order
78
+
79
+ Merb::Plugins.config[:merb_slices] = { :queue => ["MerbScrewUnit", ...] }
80
+
81
+ # optionally configure the plugins in a before_app_loads callback
82
+
83
+ Merb::BootLoader.before_app_loads do
84
+
85
+ Merb::Slices::config[:merb_screw_unit][:option] = value
86
+
87
+ end
88
+
89
+ file: config/router.rb
90
+
91
+ # example: /merb_screw_unit/:controller/:action/:id
92
+
93
+ r.add_slice(:MerbScrewUnit)
94
+
95
+ # example: /foo/:controller/:action/:id
96
+
97
+ r.add_slice(:MerbScrewUnit, 'foo') # same as :path => 'foo'
98
+
99
+ # example: /:lang/:controller/:action/:id (with :a param set)
100
+
101
+ r.add_slice(:MerbScrewUnit, :path => ':lang', :params => { :a => 'b' })
102
+
103
+ # example: /:controller/:action/:id
104
+
105
+ r.slice(:MerbScrewUnit)
106
+
107
+ Normally you should also run the following rake task:
108
+
109
+ rake slices:merb_screw_unit:install
110
+
111
+ ------------------------------------------------------------------------------
112
+
113
+ You can put your application-level overrides in:
114
+
115
+ host-app/slices/merb_screw_unit/app - controllers, models, views ...
116
+
117
+ Templates are located in this order:
118
+
119
+ 1. host-app/slices/merb_screw_unit/app/views/*
120
+ 2. gems/merb_screw_unit/app/views/*
121
+ 3. host-app/app/views/*
122
+
123
+ You can use the host application's layout by configuring the
124
+ merb_screw_unit slice in a before_app_loads block:
125
+
126
+ Merb::Slices.config[:merb_screw_unit] = { :layout => :application }
127
+
128
+ By default :merb_screw_unit is used. If you need to override
129
+ stylesheets or javascripts, just specify your own files in your layout
130
+ instead/in addition to the ones supplied (if any) in
131
+ host-app/public/slices/merb_screw_unit.
132
+
133
+ In any case don't edit those files directly as they may be clobbered any time
134
+ rake merb_screw_unit:install is run.
135
+
136
+ ------------------------------------------------------------------------------
137
+
138
+ About Slices
139
+ ============
140
+
141
+ Merb-Slices is a Merb plugin for using and creating application 'slices' which
142
+ help you modularize your application. Usually these are reuseable extractions
143
+ from your main app. In effect, a Slice is just like a regular Merb MVC
144
+ application, both in functionality as well as in structure.
145
+
146
+ When you generate a Slice stub structure, a module is setup to serve as a
147
+ namespace for your controller, models, helpers etc. This ensures maximum
148
+ encapsulation. You could say a Slice is a mixture between a Merb plugin (a
149
+ Gem) and a Merb application, reaping the benefits of both.
150
+
151
+ A host application can 'mount' a Slice inside the router, which means you have
152
+ full over control how it integrates. By default a Slice's routes are prefixed
153
+ by its name (a router :namespace), but you can easily provide your own prefix
154
+ or leave it out, mounting it at the root of your url-schema. You can even
155
+ mount a Slice multiple times and give extra parameters to customize an
156
+ instance's behaviour.
157
+
158
+ A Slice's Application controller uses controller_for_slice to setup slice
159
+ specific behaviour, which mainly affects cascaded view handling. Additionaly,
160
+ this method is available to any kind of controller, so it can be used for
161
+ Merb Mailer too for example.
162
+
163
+ There are many ways which let you customize a Slice's functionality and
164
+ appearance without ever touching the Gem-level code itself. It's not only easy
165
+ to add template/layout overrides, you can also add/modify controllers, models
166
+ and other runtime code from within the host application.
167
+
168
+ To create your own Slice run this (somewhere outside of your merb app):
169
+
170
+ $ merb-gen slice <your-lowercase-slice-name>
data/Rakefile ADDED
@@ -0,0 +1,70 @@
1
+ require 'rubygems'
2
+ require 'rubygems/specification'
3
+ require 'rake/gempackagetask'
4
+ require "extlib"
5
+ require 'merb-core/tasks/merb_rake_helper'
6
+ require "spec/rake/spectask"
7
+
8
+ ##############################################################################
9
+ # Package && release
10
+ ##############################################################################
11
+ RUBY_FORGE_PROJECT = "merb"
12
+ PROJECT_URL = "http://merbivore.com"
13
+ PROJECT_SUMMARY = "Merb Slice that provides support for Screw.Unit testing"
14
+ PROJECT_DESCRIPTION = PROJECT_SUMMARY
15
+
16
+ GEM_AUTHOR = "Yehuda Katz"
17
+ GEM_EMAIL = "ykatz@engineyard.com"
18
+
19
+ GEM_NAME = "merb_screw_unit"
20
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
21
+ GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.4") + PKG_BUILD
22
+
23
+ RELEASE_NAME = "REL #{GEM_VERSION}"
24
+
25
+ require "extlib/tasks/release"
26
+
27
+ spec = Gem::Specification.new do |s|
28
+ s.rubyforge_project = RUBY_FORGE_PROJECT
29
+ s.name = GEM_NAME
30
+ s.version = GEM_VERSION
31
+ s.platform = Gem::Platform::RUBY
32
+ s.has_rdoc = true
33
+ s.extra_rdoc_files = ["README", "LICENSE"]
34
+ s.summary = PROJECT_SUMMARY
35
+ s.description = PROJECT_DESCRIPTION
36
+ s.author = GEM_AUTHOR
37
+ s.email = GEM_EMAIL
38
+ s.homepage = PROJECT_URL
39
+ s.add_dependency('merb-core', '>= 0.9.4')
40
+ s.add_dependency('merb-slices', '>= 0.9.4')
41
+ s.require_path = 'lib'
42
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec,app,public,stubs}/**/*")
43
+ end
44
+
45
+ Rake::GemPackageTask.new(spec) do |pkg|
46
+ pkg.gem_spec = spec
47
+ end
48
+
49
+ desc "create a gemspec file"
50
+ task :make_spec do
51
+ File.open("#{NAME}.gemspec", "w") do |file|
52
+ file.puts spec.to_ruby
53
+ end
54
+ end
55
+
56
+ ##############################################################################
57
+ # Installation
58
+ ##############################################################################
59
+
60
+ desc "Install the gem"
61
+ task :install => [:package] do
62
+ sh %{#{sudo} gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}
63
+ end
64
+
65
+ namespace :jruby do
66
+ "Run :package and install the resulting .gem with jruby"
67
+ task :install => :package do
68
+ sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
69
+ end
70
+ end
data/TODO ADDED
@@ -0,0 +1,15 @@
1
+ TODO:
2
+
3
+ - Fix MerbScrewUnit.description and MerbScrewUnit.version
4
+ - Fix LICENSE with your name
5
+ - Fix Rakefile with your name and contact info
6
+ - Add your code to lib/merb_screw_unit.rb
7
+ - Add your Merb rake tasks to lib/merb_screw_unit/merbtasks.rb
8
+
9
+ Remove anything that you don't need:
10
+
11
+ - app/controllers/main.rb MerbScrewUnit::Main controller
12
+ - app/views/layout/merb_screw_unit.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 MerbScrewUnit::Application < Merb::Controller
2
+
3
+ controller_for_slice
4
+
5
+ end
@@ -0,0 +1,7 @@
1
+ class MerbScrewUnit::Main < MerbScrewUnit::Application
2
+
3
+ def index
4
+ render
5
+ end
6
+
7
+ end
@@ -0,0 +1,76 @@
1
+ module Merb
2
+ module MerbScrewUnit
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
+ def js_include_tag(*files)
22
+ files.map do |file|
23
+ super(javascript_path(file))
24
+ end.join
25
+ end
26
+
27
+ # @param *segments<Array[#to_s]> Path segments to append.
28
+ #
29
+ # @return <String>
30
+ # A path relative to the public directory, with added segments.
31
+ def stylesheet_path(*segments)
32
+ public_path_for(:stylesheet, *segments)
33
+ end
34
+
35
+ def css_include_tag(*files)
36
+ files.map do |file|
37
+ super(stylesheet_path(file))
38
+ end.join
39
+ end
40
+
41
+ # Construct a path relative to the public directory
42
+ #
43
+ # @param <Symbol> The type of component.
44
+ # @param *segments<Array[#to_s]> Path segments to append.
45
+ #
46
+ # @return <String>
47
+ # A path relative to the public directory, with added segments.
48
+ def public_path_for(type, *segments)
49
+ ::MerbScrewUnit.public_path_for(type, *segments)
50
+ end
51
+
52
+ # Construct an app-level path.
53
+ #
54
+ # @param <Symbol> The type of component.
55
+ # @param *segments<Array[#to_s]> Path segments to append.
56
+ #
57
+ # @return <String>
58
+ # A path within the host application, with added segments.
59
+ def app_path_for(type, *segments)
60
+ ::MerbScrewUnit.app_path_for(type, *segments)
61
+ end
62
+
63
+ # Construct a slice-level path.
64
+ #
65
+ # @param <Symbol> The type of component.
66
+ # @param *segments<Array[#to_s]> Path segments to append.
67
+ #
68
+ # @return <String>
69
+ # A path within the slice source (Gem), with added segments.
70
+ def slice_path_for(type, *segments)
71
+ ::MerbScrewUnit.slice_path_for(type, *segments)
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,37 @@
1
+ <html>
2
+ <head>
3
+ <%= js_include_tag "jquery-1.2.3", "jquery.fn", "jquery.print", "screw.builder",
4
+ "screw.matchers", "screw.events", "screw.behaviors",
5
+ "screw.mock" %>
6
+
7
+ <%= css_include_tag "screw.css" %>
8
+ </head>
9
+ <body>
10
+ <iframe id="dom" src="<%= @spec_url %>?<%= MD5.hexdigest(Time.now.to_s) %>" style="display: none"></iframe>
11
+ <script type="text/javascript">
12
+ Screw.Unit(function() {
13
+ iframeWindow = $("#dom").contents()[0].defaultView;
14
+ iframeWindow.XMLHttpRequest = Screw.XHR;
15
+ runLivequeries = function() {
16
+ if(iframeWindow.$.livequery) {
17
+ queries = iframeWindow.$.livequery.queries;
18
+ for(var i = 0; i<queries.length;i++) {
19
+ queries[i].run();
20
+ }
21
+ }
22
+ };
23
+
24
+ before(function() {
25
+ $ = iframeWindow.$;
26
+ $.ajaxSettings.async = false;
27
+ $.fn.fireEvent = function(event) {
28
+ runLivequeries();
29
+ this.trigger(event);
30
+ return this;
31
+ };
32
+ })
33
+ <%= catch_content :for_layout %>
34
+ });
35
+ </script>
36
+ </body>
37
+ </html>
@@ -0,0 +1 @@
1
+ <strong><%= slice.description %></strong> (v. <%= slice.version %>)
@@ -0,0 +1,166 @@
1
+ namespace :slices do
2
+ namespace :merb_screw_unit do
3
+
4
+ desc "Install MerbScrewUnit"
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
+ MerbScrewUnit.mirrored_components.each do |type|
15
+ if File.directory?(MerbScrewUnit.dir_for(type))
16
+ if !File.directory?(dst_path = MerbScrewUnit.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 MerbScrewUnit - resolves any collisions"
28
+ copied, preserved = MerbScrewUnit.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 MerbScrewUnit - resolves any collisions"
40
+ copied, preserved = MerbScrewUnit.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 MerbScrewUnit into your app (only merb_screw_unit/app)"
51
+ task :freeze => [ "freeze:app" ]
52
+
53
+ namespace :freeze do
54
+
55
+ desc "Freezes MerbScrewUnit by installing the gem into application/gems using merb-freezer"
56
+ task :gem do
57
+ begin
58
+ Object.const_get(:Freezer).freeze(ENV["GEM"] || "merb_screw_unit", ENV["UPDATE"], ENV["MODE"] || 'rubygems')
59
+ rescue NameError
60
+ puts "! dependency 'merb-freezer' missing"
61
+ end
62
+ end
63
+
64
+ desc "Freezes MerbScrewUnit by copying all files from merb_screw_unit/app to your application"
65
+ task :app do
66
+ puts "Copying all merb_screw_unit/app files to your application - resolves any collisions"
67
+ copied, preserved = MerbScrewUnit.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 = MerbScrewUnit.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 = MerbScrewUnit.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 MerbScrewUnit as a gem and copies over merb_screw_unit/app"
92
+ task :app_with_gem => [:gem, :app]
93
+
94
+ desc "Freezes MerbScrewUnit by unpacking all files into your application"
95
+ task :unpack do
96
+ puts "Unpacking MerbScrewUnit files to your application - resolves any collisions"
97
+ copied, preserved = MerbScrewUnit.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 MerbScrewUnit 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 :merb_screw_unit do
3
+
4
+ # add your own merb_screw_unit 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,84 @@
1
+ if defined?(Merb::Plugins)
2
+
3
+ module Spec; end
4
+
5
+ $:.unshift File.dirname(__FILE__)
6
+
7
+ load_dependency 'merb-slices'
8
+ load_dependency 'merb-assets'
9
+ require 'md5'
10
+
11
+ Merb::Plugins.add_rakefiles "merb_screw_unit/merbtasks", "merb_screw_unit/slicetasks"
12
+
13
+ # Register the Slice for the current host application
14
+ Merb::Slices::register(__FILE__)
15
+
16
+ # Slice configuration - set this in a before_app_loads callback.
17
+ # By default a Slice uses its own layout, so you can swicht to
18
+ # the main application layout or no layout at all if needed.
19
+ #
20
+ # Configuration options:
21
+ # :layout - the layout to use; defaults to :merb_screw_unit
22
+ # :mirror - which path component types to use on copy operations; defaults to all
23
+ Merb::Slices::config[:merb_screw_unit][:layout] ||= :merb_screw_unit
24
+
25
+ # All Slice code is expected to be namespaced inside a module
26
+ module MerbScrewUnit
27
+
28
+ # Slice metadata
29
+ self.description = "MerbScrewUnit is a chunky Merb slice!"
30
+ self.version = "0.0.1"
31
+ self.author = "YOUR NAME"
32
+
33
+ # Stub classes loaded hook - runs before LoadClasses BootLoader
34
+ # right after a slice's classes have been loaded internally.
35
+ def self.loaded
36
+ end
37
+
38
+ # Initialization hook - runs before AfterAppLoads BootLoader
39
+ def self.init
40
+ end
41
+
42
+ # Activation hook - runs after AfterAppLoads BootLoader
43
+ def self.activate
44
+ end
45
+
46
+ # Deactivation hook - triggered by Merb::Slices.deactivate(MerbScrewUnit)
47
+ def self.deactivate
48
+ end
49
+
50
+ # Setup routes inside the host application
51
+ #
52
+ # @param scope<Merb::Router::Behaviour>
53
+ # Routes will be added within this scope (namespace). In fact, any
54
+ # router behaviour is a valid namespace, so you can attach
55
+ # routes at any level of your router setup.
56
+ #
57
+ # @note prefix your named routes with :merb_screw_unit_
58
+ # to avoid potential conflicts with global named routes.
59
+ def self.setup_router(scope)
60
+ # example of a named route
61
+ scope.match('/index.:format').to(:controller => 'main', :action => 'index').name(:merb_screw_unit_index)
62
+ scope.match('/:controller/:action')
63
+ end
64
+
65
+ end
66
+
67
+ # Setup the slice layout for MerbScrewUnit
68
+ #
69
+ # Use MerbScrewUnit.push_path and MerbScrewUnit.push_app_path
70
+ # to set paths to merb_screw_unit-level and app-level paths. Example:
71
+ #
72
+ # MerbScrewUnit.push_path(:application, MerbScrewUnit.root)
73
+ # MerbScrewUnit.push_app_path(:application, Merb.root / 'slices' / 'merb_screw_unit')
74
+ # ...
75
+ #
76
+ # Any component path that hasn't been set will default to MerbScrewUnit.root
77
+ #
78
+ # Or just call setup_default_structure! to setup a basic Merb MVC structure.
79
+ MerbScrewUnit.setup_default_structure!
80
+
81
+ # Add dependencies for other MerbScrewUnit classes below. Example:
82
+ # dependency "merb_screw_unit/other"
83
+
84
+ end