merb 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +21 -14
- data/Rakefile +157 -108
- data/SVN_REVISION +1 -0
- data/app_generators/merb/templates/Rakefile +20 -4
- data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +1 -1
- data/app_generators/merb/templates/config/boot.rb +1 -1
- data/app_generators/merb/templates/config/dependencies.rb +3 -3
- data/app_generators/merb/templates/config/merb.yml +5 -0
- data/app_generators/merb/templates/config/merb_init.rb +3 -3
- data/app_generators/merb/templates/script/destroy +3 -0
- data/app_generators/merb/templates/script/generate +1 -1
- data/app_generators/merb/templates/spec/spec_helper.rb +2 -2
- data/app_generators/merb/templates/test/test_helper.rb +1 -1
- data/app_generators/merb_plugin/merb_plugin_generator.rb +4 -0
- data/bin/merb +1 -3
- data/lib/merb.rb +144 -76
- data/lib/merb/abstract_controller.rb +6 -5
- data/lib/merb/assets.rb +119 -0
- data/lib/merb/boot_loader.rb +217 -0
- data/lib/merb/caching.rb +1 -1
- data/lib/merb/caching/action_cache.rb +1 -1
- data/lib/merb/caching/fragment_cache.rb +1 -1
- data/lib/merb/caching/store/file_cache.rb +1 -1
- data/lib/merb/config.rb +290 -0
- data/lib/merb/controller.rb +5 -5
- data/lib/merb/core_ext/get_args.rb +1 -0
- data/lib/merb/core_ext/hash.rb +182 -169
- data/lib/merb/core_ext/kernel.rb +57 -26
- data/lib/merb/dispatcher.rb +6 -6
- data/lib/merb/drb_server.rb +1 -1
- data/lib/merb/generators/merb_generator_helpers.rb +7 -6
- data/lib/merb/logger.rb +1 -1
- data/lib/merb/mail_controller.rb +3 -4
- data/lib/merb/mailer.rb +2 -2
- data/lib/merb/mixins/basic_authentication.rb +2 -2
- data/lib/merb/mixins/controller.rb +1 -1
- data/lib/merb/mixins/general_controller.rb +13 -20
- data/lib/merb/mixins/inline_partial.rb +32 -0
- data/lib/merb/mixins/render.rb +3 -3
- data/lib/merb/mixins/responder.rb +1 -1
- data/lib/merb/mixins/view_context.rb +159 -33
- data/lib/merb/mongrel_handler.rb +9 -9
- data/lib/merb/plugins.rb +1 -1
- data/lib/merb/request.rb +25 -1
- data/lib/merb/router.rb +264 -226
- data/lib/merb/server.rb +66 -560
- data/lib/merb/session/cookie_store.rb +14 -13
- data/lib/merb/session/mem_cache_session.rb +20 -10
- data/lib/merb/session/memory_session.rb +21 -11
- data/lib/merb/template.rb +2 -2
- data/lib/merb/template/erubis.rb +3 -33
- data/lib/merb/template/haml.rb +8 -3
- data/lib/merb/test/fake_request.rb +8 -3
- data/lib/merb/test/helper.rb +66 -22
- data/lib/merb/test/rspec.rb +9 -155
- data/lib/merb/test/rspec_matchers/controller_matchers.rb +117 -0
- data/lib/merb/test/rspec_matchers/markup_matchers.rb +98 -0
- data/lib/merb/upload_handler.rb +2 -1
- data/lib/merb/version.rb +38 -3
- data/lib/merb/view_context.rb +1 -2
- data/lib/tasks/merb.rake +11 -11
- data/merb_generators/part_controller/USAGE +5 -0
- data/merb_generators/part_controller/part_controller_generator.rb +27 -0
- data/merb_generators/part_controller/templates/controller.rb +8 -0
- data/merb_generators/part_controller/templates/helper.rb +5 -0
- data/merb_generators/part_controller/templates/index.html.erb +3 -0
- data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +1 -1
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/fixtures/controllers/dispatch_spec_controllers.rb +9 -1
- data/spec/fixtures/controllers/render_spec_controllers.rb +5 -5
- data/spec/fixtures/models/router_spec_models.rb +10 -0
- data/spec/merb/abstract_controller_spec.rb +2 -2
- data/spec/merb/assets_spec.rb +207 -0
- data/spec/merb/caching_spec.rb +2 -2
- data/spec/merb/controller_spec.rb +7 -2
- data/spec/merb/cookie_store_spec.rb +1 -1
- data/spec/merb/core_ext/class_spec.rb +97 -0
- data/spec/merb/core_ext/enumerable_spec.rb +27 -0
- data/spec/merb/core_ext/hash_spec.rb +251 -0
- data/spec/merb/core_ext/inflector_spec.rb +34 -0
- data/spec/merb/core_ext/kernel_spec.rb +25 -0
- data/spec/merb/core_ext/numeric_spec.rb +26 -0
- data/spec/merb/core_ext/object_spec.rb +47 -0
- data/spec/merb/core_ext/string_spec.rb +22 -0
- data/spec/merb/core_ext/symbol_spec.rb +7 -0
- data/spec/merb/dependency_spec.rb +22 -0
- data/spec/merb/dispatch_spec.rb +23 -12
- data/spec/merb/fake_request_spec.rb +8 -0
- data/spec/merb/generator_spec.rb +140 -21
- data/spec/merb/handler_spec.rb +5 -5
- data/spec/merb/mail_controller_spec.rb +3 -3
- data/spec/merb/render_spec.rb +1 -1
- data/spec/merb/responder_spec.rb +3 -3
- data/spec/merb/router_spec.rb +260 -191
- data/spec/merb/server_spec.rb +5 -5
- data/spec/merb/upload_handler_spec.rb +7 -0
- data/spec/merb/version_spec.rb +33 -0
- data/spec/merb/view_context_spec.rb +217 -59
- data/spec/spec_generator_helper.rb +15 -0
- data/spec/spec_helper.rb +5 -3
- data/spec/spec_helpers/url_shared_behaviour.rb +5 -7
- metadata +32 -7
- data/lib/merb/caching/store/memcache.rb +0 -20
- data/lib/merb/mixins/form_control.rb +0 -332
- data/lib/patch +0 -69
- data/spec/merb/core_ext_spec.rb +0 -464
- data/spec/merb/form_control_mixin_spec.rb +0 -431
data/README
CHANGED
@@ -42,14 +42,15 @@ provides a faster library but will not work with jRuby.
|
|
42
42
|
|
43
43
|
Optionally, merb can take advantage of the following gems:
|
44
44
|
|
45
|
-
* mailfactory (if you wish to use merb's mailers)
|
46
|
-
* haml (if you wish to use HAML templates, i.e. .haml files)
|
45
|
+
* mailfactory (if you wish to use merb's mailers)
|
46
|
+
* haml 1.8 or greater (if you wish to use HAML templates, i.e. .haml files)
|
47
47
|
* markaby (if you wish to use Markaby template, i.e. .mab files)
|
48
48
|
* builder (if you wish to use Builder templates, i.e. .rxml, .rerb or .builder files)
|
49
49
|
* memcache-client (for use with Danga Interactive's memcached)
|
50
50
|
* swiftiply
|
51
51
|
* eventmachine
|
52
52
|
* rcov
|
53
|
+
* ruby-debug (if you want to use debugging functionality)
|
53
54
|
|
54
55
|
You will also probably need to install your ORM of choice as well as any gem plugins you want to use (see below).
|
55
56
|
|
@@ -75,6 +76,12 @@ To start a Merb IRB console where all your models and other classes are pre load
|
|
75
76
|
use the -i flag
|
76
77
|
|
77
78
|
$ merb -i
|
79
|
+
|
80
|
+
To enable ruby-debug support, start Merb with
|
81
|
+
|
82
|
+
$ merb -D
|
83
|
+
|
84
|
+
Now you can use the +debugger+ method everywhere in your code to open an rdebug session.
|
78
85
|
|
79
86
|
To see all the available command line flags use:
|
80
87
|
|
@@ -96,11 +103,11 @@ DataMapper:: Fairly new ORM. (<tt>sudo gem install merb_datamapper</tt>)
|
|
96
103
|
Sequel:: Fairly new ORM. (<tt>sudo gem install merb_sequel</tt>)
|
97
104
|
|
98
105
|
To use your choice ORM, install the appropriate gem and uncomment the appropriate +use_orm+ line in
|
99
|
-
|
106
|
+
Merb.root/config/dependencies.rb
|
100
107
|
|
101
108
|
=== Controllers
|
102
109
|
|
103
|
-
(
|
110
|
+
(Merb.root/app/controllers/*)
|
104
111
|
|
105
112
|
Merb controllers inherit from Merb::Controller and contain built in view/template rendering.
|
106
113
|
Incoming requests are usually mapped to a specific method in a controller. For example, using
|
@@ -110,10 +117,10 @@ method of your PostsController (and params[:id] would = 1.)
|
|
110
117
|
The return value of your action function gets sent back to the client as the view. In most cases,
|
111
118
|
you are going to want to end your functions with a call to +render+. By default, +render+ will
|
112
119
|
render the view template associated with your action (in default merb that would be
|
113
|
-
|
120
|
+
Merb.root/app/views/<controller>/<action>.html.erb - see the View section for more info.)
|
114
121
|
|
115
|
-
Controllers can be generated by calling
|
116
|
-
By default, generated controllers inherit from the Application class (
|
122
|
+
Controllers can be generated by calling Merb.root/script/generate controller ControllerName.
|
123
|
+
By default, generated controllers inherit from the Application class (Merb.root/app/controllers/application.rb)
|
117
124
|
which itself inherits from Merb:Controller. Application is a good place to put code pertinent to all controllers.
|
118
125
|
An example would be setting a filter to check if a user is logged in or to preload user data for each controller.
|
119
126
|
|
@@ -171,18 +178,18 @@ After filters accept a symbol, string or Proc and call that proc with the contro
|
|
171
178
|
|
172
179
|
=== Views
|
173
180
|
|
174
|
-
(
|
181
|
+
(Merb.root/app/views/*)
|
175
182
|
|
176
183
|
A view can be loosely defined as any data sent back to the client (a "view" of your data.)
|
177
184
|
By default, Merb controllers send the return value of your controller action as the view.
|
178
185
|
The Controller#render method simply renders the specified view and returns it as a string.
|
179
186
|
By default, a call to +render+ without any options renders the view template associated
|
180
187
|
with that controller action. Using the default ERB templating system, this means that a
|
181
|
-
call to +render+ in Posts#index would render the file
|
188
|
+
call to +render+ in Posts#index would render the file Merb.root/app/views/posts/index.html.erb
|
182
189
|
|
183
190
|
==== Layouts
|
184
191
|
|
185
|
-
(
|
192
|
+
(Merb.root/app/views/layout/*)
|
186
193
|
|
187
194
|
Layouts are generic templates in which your specific view templates are rendered. A sample
|
188
195
|
layout could look like:
|
@@ -198,8 +205,8 @@ layout could look like:
|
|
198
205
|
</html>
|
199
206
|
|
200
207
|
By default, +render+ will look for a corresponding layout for your controller in the form
|
201
|
-
of
|
202
|
-
+render+ will attempt to use
|
208
|
+
of Merb.root/app/views/layout/<controller>.html.erb . If no specific layout is present,
|
209
|
+
+render+ will attempt to use Merb.root/app/view/layout/application.html.erb
|
203
210
|
|
204
211
|
<i>See #render for more details/options, as well as how to use different templating systems
|
205
212
|
in your app.</i>
|
@@ -222,7 +229,7 @@ mongrel handles calling it in a thread safe manner.
|
|
222
229
|
|
223
230
|
=== Helpers
|
224
231
|
|
225
|
-
(
|
232
|
+
(Merb.root/app/helpers/*)
|
226
233
|
|
227
234
|
app/helpers/global_helper.rb will be available to all of your views.
|
228
235
|
Helpers named after your controller plus _helper.rb will be included in the views
|
@@ -234,7 +241,7 @@ you just want to copy it to the right place on the filesystem.
|
|
234
241
|
|
235
242
|
def upload
|
236
243
|
puts params[:file].inspect
|
237
|
-
FileUtils.mv params[:file][:tempfile].path,
|
244
|
+
FileUtils.mv params[:file][:tempfile].path, Merb.root+"/uploads/#{params[:file][:filename]}"
|
238
245
|
render
|
239
246
|
end
|
240
247
|
|
data/Rakefile
CHANGED
@@ -1,188 +1,237 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
1
|
+
require "rake"
|
2
|
+
require "rake/clean"
|
3
|
+
require "rake/gempackagetask"
|
4
|
+
require "rake/rdoctask"
|
5
|
+
require "rake/testtask"
|
6
|
+
require "spec/rake/spectask"
|
7
|
+
require "fileutils"
|
8
|
+
|
8
9
|
def __DIR__
|
9
10
|
File.dirname(__FILE__)
|
10
11
|
end
|
11
12
|
|
12
|
-
require __DIR__+
|
13
|
-
require __DIR__+
|
13
|
+
require __DIR__ + "/tools/rakehelp"
|
14
|
+
require __DIR__ + "/tools/annotation_extract"
|
15
|
+
|
14
16
|
include FileUtils
|
15
17
|
|
16
18
|
NAME = "merb"
|
17
|
-
require 'lib/merb/version'
|
18
|
-
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
19
19
|
|
20
|
+
require "lib/merb/version"
|
21
|
+
|
22
|
+
##############################################################################
|
23
|
+
# Packaging & Installation
|
24
|
+
##############################################################################
|
25
|
+
CLEAN.include ["**/.*.sw?", "*.gem", ".config"]
|
20
26
|
|
21
27
|
windows = (PLATFORM =~ /win32|cygwin/)
|
22
28
|
|
23
29
|
SUDO = windows ? "" : "sudo"
|
24
30
|
|
25
|
-
setup_clean [ "pkg", "lib/*.bundle", "*.gem", "doc/rdoc", ".config",
|
26
|
-
|
31
|
+
setup_clean [ "pkg", "lib/*.bundle", "*.gem", "doc/rdoc", ".config", "coverage", "cache", "log"]
|
27
32
|
|
28
33
|
desc "Packages up Merb."
|
29
|
-
task :default =>
|
30
|
-
task :merb => [:clean, :rdoc, :package]
|
31
|
-
|
32
|
-
task :doc => [:rdoc]
|
33
|
-
|
34
|
+
task :default => :package
|
34
35
|
|
35
|
-
|
36
|
-
files = ['README', 'LICENSE', 'CHANGELOG',
|
37
|
-
'lib/**/*.rb']
|
38
|
-
rdoc.rdoc_files.add(files)
|
39
|
-
rdoc.main = 'README'
|
40
|
-
rdoc.title = 'Merb Docs'
|
41
|
-
rdoc.template = __DIR__ + '/tools/allison-2.0/lib/allison.rb'
|
42
|
-
rdoc.rdoc_dir = 'doc/rdoc'
|
43
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
44
|
-
end
|
36
|
+
task :merb => [:clean, :rdoc, :package]
|
45
37
|
|
46
38
|
spec = Gem::Specification.new do |s|
|
47
|
-
s.name
|
48
|
-
s.version
|
49
|
-
s.platform
|
50
|
-
s.
|
51
|
-
s.
|
52
|
-
|
53
|
-
|
54
|
-
s.
|
55
|
-
s.description
|
56
|
-
s.
|
57
|
-
s.email = 'ez@engineyard.com'
|
58
|
-
s.homepage = 'http://merb.devjavu.com'
|
59
|
-
s.executables = ['merb']
|
60
|
-
|
61
|
-
s.add_dependency('mongrel')
|
62
|
-
s.add_dependency('erubis')
|
63
|
-
s.add_dependency('mime-types')
|
64
|
-
s.add_dependency('rubigen')
|
65
|
-
s.add_dependency('rake')
|
66
|
-
s.add_dependency('ruby2ruby')
|
67
|
-
s.add_dependency('json_pure')
|
68
|
-
s.requirements << 'install the json gem to get faster json parsing'
|
69
|
-
s.required_ruby_version = '>= 1.8.4'
|
70
|
-
|
71
|
-
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{bin,spec,lib,examples,app_generators,merb_generators,merb_default_generators,rspec_generators,test_unit_generators,script}/**/*")
|
72
|
-
|
39
|
+
s.name = NAME
|
40
|
+
s.version = Merb::VERSION
|
41
|
+
s.platform = Gem::Platform::RUBY
|
42
|
+
s.author = "Ezra Zygmuntowicz"
|
43
|
+
s.email = "ez@engineyard.com"
|
44
|
+
s.homepage = "http://merb.devjavu.com"
|
45
|
+
s.summary = "Merb == Mongrel + Erb. Pocket rocket web framework."
|
46
|
+
s.bindir = "bin"
|
47
|
+
s.description = s.summary
|
48
|
+
s.executables = %w( merb )
|
73
49
|
s.require_path = "lib"
|
74
|
-
s.
|
50
|
+
s.files = %w( LICENSE README Rakefile TODO ) + [Merb.svn_revision_filename] + Dir["{bin,spec,lib,examples,app_generators,merb_generators,merb_default_generators,rspec_generators,test_unit_generators,script}/**/*"]
|
51
|
+
|
52
|
+
# rdoc
|
53
|
+
s.has_rdoc = true
|
54
|
+
s.extra_rdoc_files = %w( README LICENSE TODO )
|
55
|
+
#s.rdoc_options += RDOC_OPTS + ["--exclude", "^(app|uploads)"]
|
56
|
+
|
57
|
+
# Dependencies
|
58
|
+
s.add_dependency "mongrel"
|
59
|
+
s.add_dependency "erubis"
|
60
|
+
#s.add_dependency "haml", ">= 1.8"
|
61
|
+
s.add_dependency "mime-types"
|
62
|
+
s.add_dependency "rubigen"
|
63
|
+
s.add_dependency "rake"
|
64
|
+
s.add_dependency "ruby2ruby"
|
65
|
+
s.add_dependency "json_pure"
|
66
|
+
|
67
|
+
# Requirements
|
68
|
+
s.requirements << "install the json gem to get faster json parsing"
|
69
|
+
s.required_ruby_version = ">= 1.8.4"
|
75
70
|
end
|
76
71
|
|
77
|
-
Rake::GemPackageTask.new(spec) do |
|
78
|
-
#
|
79
|
-
|
72
|
+
Rake::GemPackageTask.new(spec) do |package|
|
73
|
+
# package.need_tar = true
|
74
|
+
package.gem_spec = spec
|
80
75
|
end
|
81
76
|
|
82
|
-
|
83
|
-
|
84
|
-
sh %{#{SUDO} gem install pkg/#{NAME}-#{Merb::VERSION} --no-rdoc --no-ri}
|
77
|
+
desc "Run :package and install the resulting .gem"
|
78
|
+
task :install => :package do
|
79
|
+
sh %{#{SUDO} gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
|
85
80
|
end
|
86
81
|
|
87
|
-
|
82
|
+
desc "Run :clean and uninstall the .gem"
|
83
|
+
task :uninstall => :clean do
|
88
84
|
sh %{#{SUDO} gem uninstall #{NAME}}
|
89
85
|
end
|
90
86
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
87
|
+
##############################################################################
|
88
|
+
# Documentation
|
89
|
+
##############################################################################
|
90
|
+
task :doc => [:rdoc]
|
91
|
+
namespace :doc do
|
92
|
+
|
93
|
+
Rake::RDocTask.new do |rdoc|
|
94
|
+
files = ["README", "LICENSE", "CHANGELOG", "lib/**/*.rb"]
|
95
|
+
rdoc.rdoc_files.add(files)
|
96
|
+
rdoc.main = "README"
|
97
|
+
rdoc.title = "Merb Docs"
|
98
|
+
rdoc.template = __DIR__ + "/tools/allison-2.0.2/lib/allison.rb"
|
99
|
+
rdoc.rdoc_dir = "doc/rdoc"
|
100
|
+
rdoc.options << "--line-numbers" << "--inline-source"
|
101
|
+
end
|
95
102
|
|
96
|
-
desc "
|
97
|
-
task :
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
103
|
+
desc "run webgen"
|
104
|
+
task :webgen do
|
105
|
+
sh %{cd doc/site; webgen}
|
106
|
+
end
|
107
|
+
|
108
|
+
desc "rdoc to rubyforge"
|
109
|
+
task :rubyforge do
|
110
|
+
# sh %{rake doc}
|
111
|
+
sh %{#{SUDO} chmod -R 755 doc} unless windows
|
112
|
+
sh %{/usr/bin/scp -r -p doc/rdoc/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb}
|
113
|
+
end
|
102
114
|
|
103
|
-
desc 'Run all specs and then rcov'
|
104
|
-
task :aok do
|
105
|
-
sh %{rake specs;rake rcov}
|
106
115
|
end
|
107
116
|
|
117
|
+
##############################################################################
|
118
|
+
# rSpec & rcov
|
119
|
+
##############################################################################
|
120
|
+
desc "Run :specs, :rcov"
|
121
|
+
task :aok => [:specs, :rcov]
|
122
|
+
|
108
123
|
desc "Run all specs"
|
109
|
-
Spec::Rake::SpecTask.new(
|
124
|
+
Spec::Rake::SpecTask.new("specs") do |t|
|
110
125
|
t.spec_opts = ["--format", "specdoc", "--colour"]
|
111
|
-
t.spec_files = Dir[
|
126
|
+
t.spec_files = Dir["spec/**/*_spec.rb"].sort
|
112
127
|
end
|
113
128
|
|
114
129
|
desc "Run a specific spec with TASK=xxxx"
|
115
|
-
Spec::Rake::SpecTask.new(
|
130
|
+
Spec::Rake::SpecTask.new("spec") do |t|
|
116
131
|
t.spec_opts = ["--format", "specdoc", "--colour"]
|
117
|
-
t.libs = [
|
118
|
-
t.spec_files = ["
|
132
|
+
t.libs = ["lib", "server/lib" ]
|
133
|
+
t.spec_files = (ENV["TASK"] || '').split(',').map do |task|
|
134
|
+
"spec/merb/#{task}_spec.rb"
|
135
|
+
end
|
119
136
|
end
|
120
137
|
|
121
138
|
desc "Run all specs output html"
|
122
|
-
Spec::Rake::SpecTask.new(
|
139
|
+
Spec::Rake::SpecTask.new("specs_html") do |t|
|
123
140
|
t.spec_opts = ["--format", "html"]
|
124
|
-
t.libs = [
|
125
|
-
t.spec_files = Dir[
|
141
|
+
t.libs = ["lib", "server/lib" ]
|
142
|
+
t.spec_files = Dir["spec/**/*_spec.rb"].sort
|
126
143
|
end
|
127
144
|
|
128
145
|
desc "RCov"
|
129
|
-
Spec::Rake::SpecTask.new(
|
146
|
+
Spec::Rake::SpecTask.new("rcov") do |t|
|
147
|
+
t.rcov_opts = ["--exclude", "gems", "--exclude", "spec"]
|
130
148
|
t.spec_opts = ["--format", "specdoc", "--colour"]
|
131
|
-
t.
|
132
|
-
t.
|
149
|
+
t.rcov_opts = ["--exclude","gems"]
|
150
|
+
t.spec_files = Dir["spec/**/*_spec.rb"].sort
|
151
|
+
t.libs = ["lib", "server/lib" ]
|
133
152
|
t.rcov = true
|
134
153
|
end
|
135
154
|
|
136
155
|
STATS_DIRECTORIES = [
|
137
|
-
|
138
|
-
|
139
|
-
].collect { |name, dir| [ name, "./#{dir}" ] }.
|
156
|
+
['Code', 'lib/'],
|
157
|
+
['Unit tests', 'specs']
|
158
|
+
].collect { |name, dir| [ name, "./#{dir}" ] }.
|
159
|
+
select { |name, dir| File.directory?(dir) }
|
140
160
|
|
141
161
|
desc "Report code statistics (KLOCs, etc) from the application"
|
142
162
|
task :stats do
|
143
|
-
require __DIR__ +
|
144
|
-
#require
|
163
|
+
require __DIR__ + "/tools/code_statistics"
|
164
|
+
# require "extra/stats"
|
145
165
|
verbose = true
|
146
166
|
CodeStatistics.new(*STATS_DIRECTORIES).to_s
|
147
167
|
end
|
148
168
|
|
149
169
|
task :release => :package do
|
150
|
-
if ENV[
|
151
|
-
sh %{rubyforge add_release merb merb "#{ENV[
|
170
|
+
if ENV["RELEASE"]
|
171
|
+
sh %{rubyforge add_release merb merb "#{ENV["RELEASE"]}" pkg/#{NAME}-#{Merb::VERSION}.gem}
|
152
172
|
else
|
153
|
-
puts
|
173
|
+
puts "Usage: rake release RELEASE='Clever tag line goes here'"
|
154
174
|
end
|
155
175
|
end
|
156
176
|
|
157
177
|
##############################################################################
|
158
178
|
# SVN
|
159
179
|
##############################################################################
|
180
|
+
namespace :repo do
|
181
|
+
|
182
|
+
desc "Add new files to repository"
|
183
|
+
task :add do
|
184
|
+
if File.directory?(".git")
|
185
|
+
system "git add *"
|
186
|
+
elsif File.directory?(".svn")
|
187
|
+
system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
|
188
|
+
end
|
189
|
+
end
|
160
190
|
|
161
|
-
desc "
|
162
|
-
task :
|
163
|
-
|
191
|
+
desc "Fetch changes from master repository"
|
192
|
+
task :rebase do
|
193
|
+
if File.directory?(".git")
|
194
|
+
system "git stash ; git svn rebase ; git stash apply"
|
195
|
+
elsif File.directory?(".svn")
|
196
|
+
system "svn update"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
desc "commit modified changes to the repository"
|
201
|
+
task :commit do
|
202
|
+
if File.directory?(".git")
|
203
|
+
system "git commit"
|
204
|
+
elsif File.directory?(".svn")
|
205
|
+
system "svn commit"
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
164
209
|
end
|
165
210
|
|
166
|
-
|
167
|
-
# Run specific tests or test files
|
211
|
+
# Run specific tests or test files. Searches nested spec directories as well.
|
168
212
|
#
|
169
213
|
# Based on a technique popularized by Geoffrey Grosenbach
|
170
214
|
rule "" do |t|
|
171
|
-
spec_cmd = (RUBY_PLATFORM =~ /java/) ?
|
215
|
+
spec_cmd = (RUBY_PLATFORM =~ /java/) ? "jruby -S spec" : "spec"
|
172
216
|
# spec:spec_file:spec_name
|
173
217
|
if /spec:(.*)$/.match(t.name)
|
174
|
-
arguments = t.name.split(
|
218
|
+
arguments = t.name.split(':')
|
219
|
+
|
175
220
|
file_name = arguments[1]
|
176
221
|
spec_name = arguments[2..-1]
|
177
222
|
|
178
|
-
|
179
|
-
|
180
|
-
end
|
223
|
+
spec_filename = "#{file_name}_spec.rb"
|
224
|
+
specs = Dir["spec/merb/**/#{spec_filename}"]
|
181
225
|
|
182
|
-
|
226
|
+
if path = specs.detect { |f| spec_filename == File.basename(f) }
|
227
|
+
run_file_name = path
|
228
|
+
else
|
229
|
+
puts "No specs found for #{t.name.inspect}"
|
230
|
+
exit
|
231
|
+
end
|
183
232
|
|
184
|
-
|
233
|
+
example = " -e '#{spec_name}'" unless spec_name.empty?
|
234
|
+
|
235
|
+
sh "#{spec_cmd} #{run_file_name} --format specdoc --colour #{example}"
|
185
236
|
end
|
186
237
|
end
|
187
|
-
|
188
|
-
|