merb-slices 0.9.7 → 0.9.8
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/README +4 -4
- data/Rakefile +27 -13
- data/TODO +1 -2
- data/bin/slice +77 -0
- data/lib/generators/templates/common/Rakefile +16 -12
- data/lib/generators/templates/full/README +4 -4
- data/lib/generators/templates/full/Rakefile +32 -13
- data/lib/generators/templates/full/config/init.rb +43 -0
- data/lib/generators/templates/full/lib/%base_name%.rb +3 -1
- data/lib/generators/templates/full/spec/%base_name%_spec.rb +10 -121
- data/lib/generators/templates/full/spec/controllers/main_spec.rb +18 -8
- data/lib/generators/templates/thin/README +4 -4
- data/lib/generators/templates/very_thin/README +4 -4
- data/lib/merb-slices.rb +3 -3
- data/lib/merb-slices/controller_mixin.rb +34 -7
- data/lib/merb-slices/merbtasks.rb +5 -34
- data/lib/merb-slices/module.rb +9 -3
- data/lib/merb-slices/module_mixin.rb +19 -31
- data/lib/merb-slices/router_ext.rb +10 -7
- data/spec/full_slice_generator_spec.rb +31 -2
- data/spec/full_slice_spec.rb +162 -0
- data/spec/merb-slice_spec.rb +97 -3
- data/spec/slice_generator_spec.rb +15 -3
- data/spec/slices/full-test-slice/LICENSE +20 -0
- data/spec/slices/full-test-slice/README +170 -0
- data/spec/slices/full-test-slice/Rakefile +67 -0
- data/spec/slices/full-test-slice/TODO +15 -0
- data/spec/slices/full-test-slice/app/controllers/application.rb +5 -0
- data/spec/slices/full-test-slice/app/controllers/main.rb +7 -0
- data/spec/slices/full-test-slice/app/helpers/application_helper.rb +64 -0
- data/spec/slices/full-test-slice/app/views/layout/full_test_slice.html.erb +16 -0
- data/spec/slices/full-test-slice/app/views/main/index.html.erb +1 -0
- data/spec/slices/full-test-slice/config/init.rb +43 -0
- data/spec/slices/full-test-slice/lib/full-test-slice.rb +80 -0
- data/spec/slices/full-test-slice/lib/full-test-slice/merbtasks.rb +103 -0
- data/spec/slices/full-test-slice/lib/full-test-slice/slicetasks.rb +18 -0
- data/spec/slices/full-test-slice/lib/full-test-slice/spectasks.rb +65 -0
- data/spec/slices/full-test-slice/public/javascripts/master.js +0 -0
- data/spec/slices/full-test-slice/public/stylesheets/master.css +2 -0
- data/spec/slices/full-test-slice/stubs/app/controllers/application.rb +2 -0
- data/spec/slices/full-test-slice/stubs/app/controllers/main.rb +2 -0
- data/spec/slices/thin-test-slice/LICENSE +20 -0
- data/spec/slices/thin-test-slice/README +130 -0
- data/spec/slices/thin-test-slice/Rakefile +43 -0
- data/spec/slices/thin-test-slice/TODO +7 -0
- data/spec/slices/thin-test-slice/application.rb +36 -0
- data/spec/slices/thin-test-slice/lib/thin-test-slice.rb +93 -0
- data/spec/slices/thin-test-slice/lib/thin-test-slice/merbtasks.rb +103 -0
- data/spec/slices/thin-test-slice/lib/thin-test-slice/slicetasks.rb +18 -0
- data/spec/slices/thin-test-slice/public/javascripts/master.js +0 -0
- data/spec/slices/thin-test-slice/public/stylesheets/master.css +2 -0
- data/spec/slices/thin-test-slice/stubs/application.rb +9 -0
- data/spec/slices/thin-test-slice/views/layout/thin_test_slice.html.erb +16 -0
- data/spec/slices/thin-test-slice/views/main/index.html.erb +1 -0
- data/spec/slices/very-thin-test-slice/LICENSE +20 -0
- data/spec/slices/very-thin-test-slice/README +110 -0
- data/spec/slices/very-thin-test-slice/Rakefile +43 -0
- data/spec/slices/very-thin-test-slice/TODO +7 -0
- data/spec/slices/very-thin-test-slice/application.rb +36 -0
- data/spec/slices/very-thin-test-slice/lib/very-thin-test-slice.rb +89 -0
- data/spec/slices/very-thin-test-slice/lib/very-thin-test-slice/merbtasks.rb +103 -0
- data/spec/slices/very-thin-test-slice/lib/very-thin-test-slice/slicetasks.rb +18 -0
- data/spec/spec_helper.rb +27 -2
- data/spec/thin_slice_generator_spec.rb +24 -2
- data/spec/thin_slice_spec.rb +139 -0
- data/spec/very_thin_slice_generator_spec.rb +22 -2
- data/spec/very_thin_slice_spec.rb +119 -0
- metadata +79 -5
data/spec/merb-slice_spec.rb
CHANGED
@@ -1,7 +1,101 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
3
|
+
describe Merb::Slices do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
# Add the slice to the search path
|
7
|
+
Merb::Plugins.config[:merb_slices][:auto_register] = true
|
8
|
+
Merb::Plugins.config[:merb_slices][:search_path] = File.dirname(__FILE__) / 'slices'
|
9
|
+
|
10
|
+
Merb.start(
|
11
|
+
:testing => true,
|
12
|
+
:adapter => 'runner',
|
13
|
+
:environment => ENV['MERB_ENV'] || 'test',
|
14
|
+
:merb_root => Merb.root
|
15
|
+
)
|
6
16
|
end
|
17
|
+
|
18
|
+
before :all do
|
19
|
+
Merb::Router.prepare do
|
20
|
+
all_slices
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
after :all do
|
25
|
+
Merb::Router.reset!
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be registered in Merb::Slices.slices" do
|
29
|
+
Merb::Slices.slices.should include(FullTestSlice)
|
30
|
+
Merb::Slices.slices.should include(ThinTestSlice)
|
31
|
+
Merb::Slices.slices.should include(VeryThinTestSlice)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "The Merb::Router::Behavior methods" do
|
37
|
+
|
38
|
+
before(:all) do
|
39
|
+
# Add the slice to the search path
|
40
|
+
Merb::Plugins.config[:merb_slices][:auto_register] = true
|
41
|
+
Merb::Plugins.config[:merb_slices][:search_path] = File.dirname(__FILE__) / 'slices'
|
42
|
+
|
43
|
+
Merb.start(
|
44
|
+
:testing => true,
|
45
|
+
:adapter => 'runner',
|
46
|
+
:environment => ENV['MERB_ENV'] || 'test',
|
47
|
+
:merb_root => Merb.root
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
before :all do
|
52
|
+
Merb::Router.prepare do
|
53
|
+
add_slice(:FullTestSlice, :path_prefix => 'full') do |scope|
|
54
|
+
scope.match('/dashboard').to(:controller => 'main', :action => 'index').name(:dashboard)
|
55
|
+
end
|
56
|
+
add_slice(:thin_test_slice, 'thin') # shortcut for :path => 'thin'
|
57
|
+
slice(:very_thin_test_slice, :name_prefix => 'awesome', :params => { :foo => 'bar' })
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
after :all do
|
62
|
+
Merb::Router.reset!
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should add a slice's routes and provide access to the namespace through a block using #add_slice" do
|
66
|
+
Merb::Router.named_routes[:full_test_slice_default].inspect.should == '/full/:controller(/:action(/:id))(.:format)'
|
67
|
+
Merb::Router.named_routes[:full_test_slice_home].inspect.should == '/full/'
|
68
|
+
Merb::Router.named_routes[:full_test_slice_index].inspect.should == '/full/index(.:format)'
|
69
|
+
Merb::Router.named_routes[:full_test_slice_dashboard].inspect.should == '/full/dashboard'
|
70
|
+
|
71
|
+
Merb::Router.named_routes[:full_test_slice_default].should == FullTestSlice.named_routes[:default]
|
72
|
+
Merb::Router.named_routes[:full_test_slice_index].should == FullTestSlice.named_routes[:index]
|
73
|
+
Merb::Router.named_routes[:full_test_slice_dashboard].should == FullTestSlice.named_routes[:dashboard]
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should add a slice's routes and provide a shortcut for setting the url prefix/path using #add_slice" do
|
77
|
+
Merb::Router.named_routes[:thin_test_slice_default].inspect.should == '/thin/:controller(/:action(/:id))(.:format)'
|
78
|
+
Merb::Router.named_routes[:thin_test_slice_default].should == ThinTestSlice.named_routes[:default]
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should mount a slice directly at the root using #slice" do
|
82
|
+
Merb::Router.named_routes[:awesome_default].inspect.should == '/:controller(/:action(/:id))(.:format)'
|
83
|
+
Merb::Router.named_routes[:awesome_default].should == VeryThinTestSlice.named_routes[:default]
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should allow default params to be set on a route" do
|
87
|
+
Merb::Router.named_routes[:awesome_default].params[:foo].should == '"bar"'
|
88
|
+
end
|
89
|
+
|
90
|
+
it "enable url() and slice_url() respectively" do
|
91
|
+
controller = dispatch_to(FullTestSlice::Main, 'index')
|
92
|
+
controller.url(:full_test_slice_index, :format => 'html').should == '/full/index.html'
|
93
|
+
controller.slice_url(:full_test_slice, :index, :format => 'html').should == '/full/index.html'
|
94
|
+
controller.slice_url(:index, :format => 'html').should == '/full/index.html'
|
95
|
+
|
96
|
+
controller.url(:full_test_slice_dashboard).should == '/full/dashboard'
|
97
|
+
controller.slice_url(:full_test_slice, :dashboard).should == '/full/dashboard'
|
98
|
+
controller.slice_url(:dashboard).should == '/full/dashboard'
|
99
|
+
end
|
100
|
+
|
7
101
|
end
|
@@ -2,10 +2,22 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
|
3
3
|
describe Merb::Generators::SliceGenerator do
|
4
4
|
|
5
|
-
it "should invoke the full generator by default"
|
5
|
+
it "should invoke the full generator by default" do
|
6
|
+
generator = Merb::Generators::SliceGenerator.new('/tmp', { :pretend => true }, 'testing')
|
7
|
+
generator.invoke!
|
8
|
+
generator.invocations.first.class.should == Merb::Generators::FullSliceGenerator
|
9
|
+
end
|
6
10
|
|
7
|
-
it "should invoke the flat generator if
|
11
|
+
it "should invoke the flat generator if --thin is set" do
|
12
|
+
generator = Merb::Generators::SliceGenerator.new('/tmp', { :pretend => true, :thin => true }, 'testing')
|
13
|
+
generator.invoke!
|
14
|
+
generator.invocations.first.class.should == Merb::Generators::ThinSliceGenerator
|
15
|
+
end
|
8
16
|
|
9
|
-
it "should invoke the very flat generator if very
|
17
|
+
it "should invoke the very flat generator if --very-thin is set" do
|
18
|
+
generator = Merb::Generators::SliceGenerator.new('/tmp', { :pretend => true, :very_thin => true }, 'testing')
|
19
|
+
generator.invoke!
|
20
|
+
generator.invocations.first.class.should == Merb::Generators::VeryThinSliceGenerator
|
21
|
+
end
|
10
22
|
|
11
23
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 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,170 @@
|
|
1
|
+
FullTestSlice
|
2
|
+
=============
|
3
|
+
|
4
|
+
A slice for the Merb framework.
|
5
|
+
|
6
|
+
------------------------------------------------------------------------------
|
7
|
+
|
8
|
+
full-test-slice
|
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
|
+
| | `-- full-test-slice.html.erb [3]
|
22
|
+
| `-- main
|
23
|
+
| `-- index.html.erb
|
24
|
+
|-- lib
|
25
|
+
| |-- full-test-slice
|
26
|
+
| | |-- merbtasks.rb [4]
|
27
|
+
| | `-- slicetasks.rb [5]
|
28
|
+
| `-- full-test-slice.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
|
+
| |-- full-test-slice_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[:full_test_slice][: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:full_test_slice: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:full_test_slice:stubs to
|
59
|
+
get started with the override stubs. Also, slices:full_test_slice: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 FullTestSlice run:
|
64
|
+
|
65
|
+
rake -T slices:full_test_slice
|
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 'full-test-slice'
|
76
|
+
|
77
|
+
# if needed, configure which slices to load and in which order
|
78
|
+
|
79
|
+
Merb::Plugins.config[:merb_slices] = { :queue => ["FullTestSlice", ...] }
|
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[:full_test_slice][:option] = value
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
file: config/router.rb
|
90
|
+
|
91
|
+
# example: /full_test_slice/:controller/:action/:id
|
92
|
+
|
93
|
+
add_slice(:FullTestSlice)
|
94
|
+
|
95
|
+
# example: /foo/:controller/:action/:id
|
96
|
+
|
97
|
+
add_slice(:FullTestSlice, 'foo') # same as :path => 'foo'
|
98
|
+
|
99
|
+
# example: /:lang/:controller/:action/:id (with :a param set)
|
100
|
+
|
101
|
+
add_slice(:FullTestSlice, :path => ':lang', :params => { :a => 'b' })
|
102
|
+
|
103
|
+
# example: /:controller/:action/:id
|
104
|
+
|
105
|
+
slice(:FullTestSlice)
|
106
|
+
|
107
|
+
Normally you should also run the following rake task:
|
108
|
+
|
109
|
+
rake slices:full_test_slice:install
|
110
|
+
|
111
|
+
------------------------------------------------------------------------------
|
112
|
+
|
113
|
+
You can put your application-level overrides in:
|
114
|
+
|
115
|
+
host-app/slices/full-test-slice/app - controllers, models, views ...
|
116
|
+
|
117
|
+
Templates are located in this order:
|
118
|
+
|
119
|
+
1. host-app/slices/full-test-slice/app/views/*
|
120
|
+
2. gems/full-test-slice/app/views/*
|
121
|
+
3. host-app/app/views/*
|
122
|
+
|
123
|
+
You can use the host application's layout by configuring the
|
124
|
+
full-test-slice slice in a before_app_loads block:
|
125
|
+
|
126
|
+
Merb::Slices.config[:full_test_slice] = { :layout => :application }
|
127
|
+
|
128
|
+
By default :full_test_slice 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/full-test-slice.
|
132
|
+
|
133
|
+
In any case don't edit those files directly as they may be clobbered any time
|
134
|
+
rake full_test_slice: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>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'spec/rake/spectask'
|
4
|
+
|
5
|
+
require 'merb-core'
|
6
|
+
require 'merb-core/tasks/merb'
|
7
|
+
require 'merb-core/test/tasks/spectasks'
|
8
|
+
|
9
|
+
GEM_NAME = "full-test-slice"
|
10
|
+
AUTHOR = "Your Name"
|
11
|
+
EMAIL = "Your Email"
|
12
|
+
HOMEPAGE = "http://merbivore.com/"
|
13
|
+
SUMMARY = "Merb Slice that provides ..."
|
14
|
+
GEM_VERSION = "0.9.8"
|
15
|
+
|
16
|
+
spec = Gem::Specification.new do |s|
|
17
|
+
s.rubyforge_project = 'merb'
|
18
|
+
s.name = GEM_NAME
|
19
|
+
s.version = GEM_VERSION
|
20
|
+
s.platform = Gem::Platform::RUBY
|
21
|
+
s.has_rdoc = true
|
22
|
+
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
23
|
+
s.summary = SUMMARY
|
24
|
+
s.description = s.summary
|
25
|
+
s.author = AUTHOR
|
26
|
+
s.email = EMAIL
|
27
|
+
s.homepage = HOMEPAGE
|
28
|
+
s.add_dependency('merb-slices', '>= 0.9.8')
|
29
|
+
s.require_path = 'lib'
|
30
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec,app,public,stubs}/**/*")
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
34
|
+
pkg.gem_spec = spec
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Install the gem"
|
38
|
+
task :install do
|
39
|
+
Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Uninstall the gem"
|
43
|
+
task :uninstall do
|
44
|
+
Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Create a gemspec file"
|
48
|
+
task :gemspec do
|
49
|
+
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
50
|
+
file.puts spec.to_ruby
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "Run all examples (or a specific spec with TASK=xxxx)"
|
55
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
56
|
+
t.spec_opts = ["-cfs"]
|
57
|
+
t.spec_files = begin
|
58
|
+
if ENV["TASK"]
|
59
|
+
ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
|
60
|
+
else
|
61
|
+
FileList['spec/**/*_spec.rb']
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
desc 'Default: run spec examples'
|
67
|
+
task :default => 'spec'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
TODO:
|
2
|
+
|
3
|
+
- Fix FullTestSlice.description and FullTestSlice.version
|
4
|
+
- Fix LICENSE with your name
|
5
|
+
- Fix Rakefile with your name and contact info
|
6
|
+
- Add your code to lib/full-test-slice.rb
|
7
|
+
- Add your Merb rake tasks to lib/full-test-slice/merbtasks.rb
|
8
|
+
|
9
|
+
Remove anything that you don't need:
|
10
|
+
|
11
|
+
- app/controllers/main.rb FullTestSlice::Main controller
|
12
|
+
- app/views/layout/full-test-slice.html.erb
|
13
|
+
- spec/controllers/main_spec.rb controller specs
|
14
|
+
- public/* any public files
|
15
|
+
- stubs/* any stub files
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Merb
|
2
|
+
module FullTestSlice
|
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
|
+
::FullTestSlice.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
|
+
::FullTestSlice.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
|
+
::FullTestSlice.slice_path_for(type, *segments)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|