merb 0.3.7 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +25 -26
- data/Rakefile +48 -36
- data/app_generators/merb/USAGE +5 -0
- data/app_generators/merb/merb_generator.rb +107 -0
- data/app_generators/merb/templates/Rakefile +99 -0
- data/{examples/skeleton/dist → app_generators/merb/templates}/app/controllers/application.rb +1 -1
- data/app_generators/merb/templates/app/controllers/exceptions.rb +13 -0
- data/{examples/skeleton/dist → app_generators/merb/templates}/app/helpers/global_helper.rb +0 -0
- data/{examples/skeleton/dist/app/mailers → app_generators/merb/templates/app/mailers/views}/layout/application.erb +0 -0
- data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +207 -0
- data/app_generators/merb/templates/app/views/exceptions/not_acceptable.html.erb +38 -0
- data/app_generators/merb/templates/app/views/exceptions/not_found.html.erb +40 -0
- data/app_generators/merb/templates/app/views/layout/application.html.erb +11 -0
- data/app_generators/merb/templates/config/boot.rb +11 -0
- data/app_generators/merb/templates/config/dependencies.rb +41 -0
- data/{examples/skeleton/dist/conf → app_generators/merb/templates/config}/environments/development.rb +0 -0
- data/{examples/skeleton/dist/conf → app_generators/merb/templates/config}/environments/production.rb +0 -0
- data/{examples/skeleton/dist/conf → app_generators/merb/templates/config}/environments/test.rb +0 -0
- data/app_generators/merb/templates/config/merb.yml +64 -0
- data/app_generators/merb/templates/config/merb_init.rb +16 -0
- data/app_generators/merb/templates/config/plugins.yml +1 -0
- data/app_generators/merb/templates/config/router.rb +32 -0
- data/{lib/merb/core_ext/merb_array.rb → app_generators/merb/templates/config/upload.conf} +0 -0
- data/app_generators/merb/templates/public/images/merb.jpg +0 -0
- data/app_generators/merb/templates/public/merb.fcgi +6 -0
- data/app_generators/merb/templates/public/stylesheets/master.css +119 -0
- data/app_generators/merb/templates/script/destroy +28 -0
- data/app_generators/merb/templates/script/generate +28 -0
- data/{examples/skeleton → app_generators/merb/templates}/script/stop_merb +0 -0
- data/app_generators/merb/templates/script/win_script.cmd +1 -0
- data/app_generators/merb/templates/spec/spec.opts +6 -0
- data/app_generators/merb/templates/spec/spec_helper.rb +10 -0
- data/app_generators/merb/templates/test/test_helper.rb +13 -0
- data/app_generators/merb_plugin/USAGE +5 -0
- data/app_generators/merb_plugin/merb_plugin_generator.rb +64 -0
- data/app_generators/merb_plugin/templates/LICENSE +20 -0
- data/app_generators/merb_plugin/templates/README +4 -0
- data/app_generators/merb_plugin/templates/Rakefile +35 -0
- data/app_generators/merb_plugin/templates/TODO +5 -0
- data/app_generators/merb_plugin/templates/merbtasks.rb +6 -0
- data/app_generators/merb_plugin/templates/sampleplugin.rb +10 -0
- data/app_generators/merb_plugin/templates/sampleplugin_spec.rb +7 -0
- data/app_generators/merb_plugin/templates/spec_helper.rb +2 -0
- data/bin/merb +1 -1
- data/lib/autotest/discover.rb +3 -0
- data/lib/autotest/merb_rspec.rb +79 -0
- data/lib/merb.rb +72 -93
- data/lib/merb/{merb_abstract_controller.rb → abstract_controller.rb} +28 -5
- data/lib/merb/caching/action_cache.rb +65 -29
- data/lib/merb/caching/fragment_cache.rb +9 -4
- data/lib/merb/caching/store/file_cache.rb +22 -14
- data/lib/merb/caching/store/memory_cache.rb +26 -8
- data/lib/merb/{merb_constants.rb → constants.rb} +9 -7
- data/lib/merb/controller.rb +178 -0
- data/lib/merb/core_ext.rb +13 -11
- data/lib/merb/core_ext/array.rb +0 -0
- data/lib/merb/core_ext/{merb_class.rb → class.rb} +0 -0
- data/lib/merb/core_ext/{merb_enumerable.rb → enumerable.rb} +0 -0
- data/lib/merb/core_ext/get_args.rb +52 -0
- data/lib/merb/core_ext/{merb_hash.rb → hash.rb} +40 -11
- data/lib/merb/core_ext/{merb_inflections.rb → inflections.rb} +0 -0
- data/lib/merb/core_ext/{merb_inflector.rb → inflector.rb} +1 -1
- data/lib/merb/core_ext/{merb_kernel.rb → kernel.rb} +56 -3
- data/lib/merb/core_ext/mash.rb +88 -0
- data/lib/merb/core_ext/{merb_module.rb → module.rb} +0 -0
- data/lib/merb/core_ext/{merb_numeric.rb → numeric.rb} +0 -0
- data/lib/merb/core_ext/{merb_object.rb → object.rb} +10 -47
- data/lib/merb/core_ext/string.rb +56 -0
- data/lib/merb/core_ext/{merb_symbol.rb → symbol.rb} +0 -0
- data/lib/merb/dispatcher.rb +109 -0
- data/lib/merb/{merb_drb_server.rb → drb_server.rb} +0 -0
- data/lib/merb/erubis_ext.rb +10 -0
- data/lib/merb/exceptions.rb +173 -0
- data/lib/merb/generators/merb_app/merb_app.rb +5 -25
- data/lib/merb/generators/merb_generator_helpers.rb +317 -0
- data/lib/merb/generators/merb_plugin.rb +19 -0
- data/lib/merb/logger.rb +65 -0
- data/lib/merb/{merb_mail_controller.rb → mail_controller.rb} +102 -49
- data/lib/merb/{merb_mailer.rb → mailer.rb} +31 -27
- data/lib/merb/mixins/{basic_authentication_mixin.rb → basic_authentication.rb} +3 -3
- data/lib/merb/mixins/{controller_mixin.rb → controller.rb} +131 -112
- data/lib/merb/mixins/{erubis_capture_mixin.rb → erubis_capture.rb} +12 -21
- data/lib/merb/mixins/{form_control_mixin.rb → form_control.rb} +6 -12
- data/lib/merb/mixins/render.rb +401 -0
- data/lib/merb/mixins/responder.rb +378 -0
- data/lib/merb/mixins/{view_context_mixin.rb → view_context.rb} +65 -10
- data/lib/merb/mixins/web_controller.rb +29 -0
- data/lib/merb/{merb_handler.rb → mongrel_handler.rb} +59 -38
- data/lib/merb/part_controller.rb +19 -0
- data/lib/merb/plugins.rb +16 -0
- data/lib/merb/rack_adapter.rb +37 -0
- data/lib/merb/request.rb +421 -0
- data/lib/merb/router.rb +576 -0
- data/lib/merb/{merb_server.rb → server.rb} +275 -71
- data/lib/merb/session.rb +10 -10
- data/lib/merb/session/cookie_store.rb +125 -0
- data/lib/merb/session/{merb_mem_cache_session.rb → mem_cache_session.rb} +22 -9
- data/lib/merb/session/{merb_memory_session.rb → memory_session.rb} +15 -11
- data/lib/merb/template.rb +35 -8
- data/lib/merb/template/erubis.rb +16 -10
- data/lib/merb/template/haml.rb +33 -20
- data/lib/merb/template/markaby.rb +16 -14
- data/lib/merb/template/xml_builder.rb +8 -4
- data/lib/merb/test/{merb_fake_request.rb → fake_request.rb} +11 -5
- data/lib/merb/test/helper.rb +31 -0
- data/lib/merb/test/hpricot.rb +136 -0
- data/lib/merb/test/{merb_multipart.rb → multipart.rb} +1 -1
- data/lib/merb/test/rspec.rb +93 -0
- data/lib/merb/{merb_upload_handler.rb → upload_handler.rb} +5 -6
- data/lib/merb/{merb_upload_progress.rb → upload_progress.rb} +1 -1
- data/lib/merb/{merb_view_context.rb → view_context.rb} +27 -42
- data/lib/{merb_tasks.rb → tasks.rb} +0 -0
- data/lib/tasks/merb.rake +21 -11
- data/merb_default_generators/model/USAGE +0 -0
- data/merb_default_generators/model/model_generator.rb +16 -0
- data/merb_default_generators/model/templates/new_model_template.erb +5 -0
- data/merb_default_generators/resource_controller/USAGE +0 -0
- data/merb_default_generators/resource_controller/resource_controller_generator.rb +26 -0
- data/merb_default_generators/resource_controller/templates/controller.rb +30 -0
- data/merb_default_generators/resource_controller/templates/edit.html.erb +1 -0
- data/merb_default_generators/resource_controller/templates/helper.rb +5 -0
- data/merb_default_generators/resource_controller/templates/index.html.erb +1 -0
- data/merb_default_generators/resource_controller/templates/new.html.erb +1 -0
- data/merb_default_generators/resource_controller/templates/show.html.erb +1 -0
- data/merb_generators/controller/USAGE +5 -0
- data/merb_generators/controller/controller_generator.rb +16 -0
- data/merb_generators/controller/templates/controller.rb +8 -0
- data/merb_generators/controller/templates/helper.rb +5 -0
- data/merb_generators/controller/templates/index.html.erb +3 -0
- data/merb_generators/resource/USAGE +0 -0
- data/merb_generators/resource/resource_generator.rb +60 -0
- data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +67 -0
- data/rspec_generators/merb_controller_test/templates/controller_spec.rb +8 -0
- data/rspec_generators/merb_controller_test/templates/edit_spec.rb +12 -0
- data/rspec_generators/merb_controller_test/templates/helper_spec.rb +5 -0
- data/rspec_generators/merb_controller_test/templates/index_spec.rb +12 -0
- data/rspec_generators/merb_controller_test/templates/new_spec.rb +12 -0
- data/rspec_generators/merb_controller_test/templates/show_spec.rb +5 -0
- data/rspec_generators/merb_model_test/merb_model_test_generator.rb +26 -0
- data/rspec_generators/merb_model_test/templates/model_spec_template.erb +7 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test_unit_generators/merb_controller_test/merb_controller_test_generator.rb +53 -0
- data/test_unit_generators/merb_controller_test/templates/functional_test.rb +17 -0
- data/test_unit_generators/merb_controller_test/templates/helper_test.rb +9 -0
- data/test_unit_generators/merb_model_test/merb_model_test_generator.rb +29 -0
- data/test_unit_generators/merb_model_test/templates/model_test_unit_template.erb +9 -0
- metadata +172 -94
- data/examples/README_EXAMPLES +0 -10
- data/examples/skeleton/Rakefile +0 -68
- data/examples/skeleton/dist/app/views/layout/application.herb +0 -12
- data/examples/skeleton/dist/conf/database.yml +0 -23
- data/examples/skeleton/dist/conf/merb.yml +0 -57
- data/examples/skeleton/dist/conf/merb_init.rb +0 -24
- data/examples/skeleton/dist/conf/router.rb +0 -22
- data/examples/skeleton/dist/conf/upload.conf +0 -5
- data/examples/skeleton/dist/schema/migrations/001_add_sessions_table.rb +0 -14
- data/examples/skeleton/script/new_migration +0 -21
- data/lib/merb/core_ext/merb_string.rb +0 -18
- data/lib/merb/merb_controller.rb +0 -206
- data/lib/merb/merb_dispatcher.rb +0 -87
- data/lib/merb/merb_exceptions.rb +0 -319
- data/lib/merb/merb_part_controller.rb +0 -42
- data/lib/merb/merb_plugins.rb +0 -293
- data/lib/merb/merb_request.rb +0 -165
- data/lib/merb/merb_router.rb +0 -309
- data/lib/merb/merb_yaml_store.rb +0 -31
- data/lib/merb/mixins/render_mixin.rb +0 -283
- data/lib/merb/mixins/responder_mixin.rb +0 -159
- data/lib/merb/session/merb_ar_session.rb +0 -131
- data/lib/merb/vendor/paginator/README.txt +0 -84
- data/lib/merb/vendor/paginator/paginator.rb +0 -124
- data/lib/tasks/db.rake +0 -55
@@ -0,0 +1,16 @@
|
|
1
|
+
# Add your own ruby code here for app specific stuff. This file gets loaded
|
2
|
+
# after the framework is loaded.
|
3
|
+
puts "Started merb_init.rb ..."
|
4
|
+
|
5
|
+
# Your app's dependencies, including your database layer (if any) are defined
|
6
|
+
# in config/dependencies.rb
|
7
|
+
require File.join(MERB_ROOT, 'config', 'dependencies')
|
8
|
+
|
9
|
+
# Here's where your controllers, helpers, and models, etc. get loaded. If you
|
10
|
+
# need to change the order of things, just move the call to 'load_application'
|
11
|
+
# around this file.
|
12
|
+
puts "Loading Application..."
|
13
|
+
Merb::Server.load_application
|
14
|
+
|
15
|
+
# Load environment-specific configuration
|
16
|
+
require File.join(MERB_ROOT, 'config', 'environments', MERB_ENV)
|
@@ -0,0 +1 @@
|
|
1
|
+
# This is for configuring plugins, not installing them
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Merb::Router is the request routing mapper for the merb framework.
|
2
|
+
#
|
3
|
+
# You can route a specific URL to a controller / action pair:
|
4
|
+
#
|
5
|
+
# r.match("/contact").
|
6
|
+
# to(:controller => "info", :action => "contact")
|
7
|
+
#
|
8
|
+
# You can define placeholder parts of the url with the :symbol notation. These
|
9
|
+
# placeholders will be available in the params hash of your controllers. For example:
|
10
|
+
#
|
11
|
+
# r.match("/books/:book_id/:action").
|
12
|
+
# to(:controller => "books")
|
13
|
+
#
|
14
|
+
# Or, use placeholders in the "to" results for more complicated routing, e.g.:
|
15
|
+
#
|
16
|
+
# r.match("/admin/:module/:controller/:action/:id").
|
17
|
+
# to(:controller => ":module/:controller")
|
18
|
+
#
|
19
|
+
# You can also use regular expressions, deferred routes, and many other options.
|
20
|
+
# See merb/specs/merb/router.rb for a fairly complete usage sample.
|
21
|
+
|
22
|
+
puts "Compiling routes.."
|
23
|
+
Merb::Router.prepare do |r|
|
24
|
+
# RESTful routes
|
25
|
+
# r.resources :posts
|
26
|
+
|
27
|
+
# Default route, usually you don't want to change this
|
28
|
+
r.default_routes
|
29
|
+
|
30
|
+
# Change this for your home page to be available at /
|
31
|
+
# r.match('/').to(:controller => 'whatever', :action =>'index')
|
32
|
+
end
|
File without changes
|
Binary file
|
@@ -0,0 +1,119 @@
|
|
1
|
+
body {
|
2
|
+
font-family: Arial, Verdana, sans-serif;
|
3
|
+
font-size: 12px;
|
4
|
+
background-color: #fff;
|
5
|
+
}
|
6
|
+
* {
|
7
|
+
margin: 0px;
|
8
|
+
padding: 0px;
|
9
|
+
text-decoration: none;
|
10
|
+
}
|
11
|
+
html {
|
12
|
+
height: 100%;
|
13
|
+
margin-bottom: 1px;
|
14
|
+
}
|
15
|
+
#container {
|
16
|
+
width: 80%;
|
17
|
+
text-align: left;
|
18
|
+
background-color: #fff;
|
19
|
+
margin-right: auto;
|
20
|
+
margin-left: auto;
|
21
|
+
}
|
22
|
+
#header-container {
|
23
|
+
width: 100%;
|
24
|
+
padding-top: 15px;
|
25
|
+
}
|
26
|
+
#header-container h1, #header-container h2 {
|
27
|
+
margin-left: 6px;
|
28
|
+
margin-bottom: 6px;
|
29
|
+
}
|
30
|
+
.spacer {
|
31
|
+
width: 100%;
|
32
|
+
height: 15px;
|
33
|
+
}
|
34
|
+
hr {
|
35
|
+
border: 0px;
|
36
|
+
color: #ccc;
|
37
|
+
background-color: #cdcdcd;
|
38
|
+
height: 1px;
|
39
|
+
width: 100%;
|
40
|
+
text-align: left;
|
41
|
+
}
|
42
|
+
h1 {
|
43
|
+
font-size: 28px;
|
44
|
+
color: #c55;
|
45
|
+
background-color: #fff;
|
46
|
+
font-family: Arial, Verdana, sans-serif;
|
47
|
+
font-weight: 300;
|
48
|
+
}
|
49
|
+
h2 {
|
50
|
+
font-size: 15px;
|
51
|
+
color: #999;
|
52
|
+
font-family: Arial, Verdana, sans-serif;
|
53
|
+
font-weight: 300;
|
54
|
+
background-color: #fff;
|
55
|
+
}
|
56
|
+
h3 {
|
57
|
+
color: #4d9b12;
|
58
|
+
font-size: 15px;
|
59
|
+
text-align: left;
|
60
|
+
font-weight: 300;
|
61
|
+
padding: 5px;
|
62
|
+
margin-top: 5px;
|
63
|
+
}
|
64
|
+
|
65
|
+
#left-container {
|
66
|
+
float: left;
|
67
|
+
width: 250px;
|
68
|
+
background-color: #FFFFFF;
|
69
|
+
color: black;
|
70
|
+
}
|
71
|
+
|
72
|
+
#left-container h3 {
|
73
|
+
color: #c55;
|
74
|
+
}
|
75
|
+
|
76
|
+
#main-container {
|
77
|
+
margin: 5px 5px 5px 260px;
|
78
|
+
padding: 15px;
|
79
|
+
border-left: 1px solid silver;
|
80
|
+
min-height: 400px;
|
81
|
+
}
|
82
|
+
p {
|
83
|
+
color: #000;
|
84
|
+
background-color: #fff;
|
85
|
+
line-height: 20px;
|
86
|
+
padding: 5px;
|
87
|
+
}
|
88
|
+
a {
|
89
|
+
color: #4d9b12;
|
90
|
+
background-color: #fff;
|
91
|
+
text-decoration: none;
|
92
|
+
}
|
93
|
+
a:hover {
|
94
|
+
color: #4d9b12;
|
95
|
+
background-color: #fff;
|
96
|
+
text-decoration: underline;
|
97
|
+
}
|
98
|
+
#footer-container {
|
99
|
+
clear: both;
|
100
|
+
font-size: 12px;
|
101
|
+
font-family: Verdana, Arial, sans-serif;
|
102
|
+
}
|
103
|
+
.right {
|
104
|
+
float: right;
|
105
|
+
font-size: 100%;
|
106
|
+
margin-top: 5px;
|
107
|
+
color: #999;
|
108
|
+
background-color: #fff;
|
109
|
+
}
|
110
|
+
.left {
|
111
|
+
float: left;
|
112
|
+
font-size: 100%;
|
113
|
+
margin-top: 5px;
|
114
|
+
color: #999;
|
115
|
+
background-color: #fff;
|
116
|
+
}
|
117
|
+
#main-container ul {
|
118
|
+
margin-left: 3.0em;
|
119
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
|
11
|
+
require File.join(File.dirname(__FILE__), "..", 'config', 'boot')
|
12
|
+
require (APP_ROOT / "config" / "merb_init" )
|
13
|
+
module Kernel
|
14
|
+
undef dependency if defined?(Kernel.dependency)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Make the App's local gems available
|
18
|
+
Gem.clear_paths
|
19
|
+
Gem.path.unshift(APP_ROOT / "gems")
|
20
|
+
|
21
|
+
require 'rubigen/scripts/destroy'
|
22
|
+
|
23
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
24
|
+
|
25
|
+
# Default is to use rspec generators in gems. To change this to
|
26
|
+
# Test::Unit use [:merb, :test_unit]
|
27
|
+
RubiGen::Base.use_component_sources! Merb::GENERATOR_SCOPE
|
28
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
|
11
|
+
require File.join(File.dirname(__FILE__), "..", 'config', 'boot')
|
12
|
+
require (APP_ROOT / "config" / "merb_init" )
|
13
|
+
module Kernel
|
14
|
+
undef dependency if defined?(Kernel.dependency)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Make the App's local gems available
|
18
|
+
Gem.clear_paths
|
19
|
+
Gem.path.unshift(APP_ROOT / "gems")
|
20
|
+
|
21
|
+
require 'rubigen/scripts/generate'
|
22
|
+
|
23
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
24
|
+
|
25
|
+
# Default is to use rspec generators in gems. To change this to
|
26
|
+
# Test::Unit use [:merb, :test_unit]
|
27
|
+
RubiGen::Base.use_component_sources! Merb::GENERATOR_SCOPE
|
28
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
@ruby <%= File.join("script", filename) %> %*
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", 'config', 'boot')
|
2
|
+
|
3
|
+
$TESTING=true
|
4
|
+
|
5
|
+
require File.join(MERB_ROOT, 'config', 'merb_init')
|
6
|
+
|
7
|
+
require 'merb/test/helper'
|
8
|
+
require 'merb/test/rspec'
|
9
|
+
|
10
|
+
### METHODS BELOW THIS LINE SHOULD BE EXTRACTED TO MERB ITSELF
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", 'config', 'boot')
|
2
|
+
|
3
|
+
$TESTING=true
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'test/unit'
|
7
|
+
require File.join(MERB_ROOT, 'config', 'merb_init')
|
8
|
+
|
9
|
+
require 'merb/test/helper'
|
10
|
+
|
11
|
+
class Test::Unit::TestCase
|
12
|
+
# Add more helper methods to be used by all tests here...
|
13
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class MerbPluginGenerator < RubiGen::Base
|
2
|
+
attr_reader :name
|
3
|
+
|
4
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
5
|
+
Config::CONFIG['ruby_install_name'])
|
6
|
+
|
7
|
+
|
8
|
+
def initialize(args, runtime_options = {})
|
9
|
+
super
|
10
|
+
usage if args.empty?
|
11
|
+
@name = args.shift.gsub(/-/,"_")
|
12
|
+
@destination_root = File.expand_path(@name)
|
13
|
+
extract_options
|
14
|
+
end
|
15
|
+
|
16
|
+
def manifest
|
17
|
+
record do |m|
|
18
|
+
# Ensure appropriate folder(s) exists
|
19
|
+
m.directory ''
|
20
|
+
m.directory "lib/#{name}"
|
21
|
+
m.directory "spec"
|
22
|
+
|
23
|
+
m.template "Rakefile", "Rakefile", :assigns => {:name => name}
|
24
|
+
m.template "README", "README", :assigns => {:name => name}
|
25
|
+
|
26
|
+
m.template "LICENSE", "LICENSE"
|
27
|
+
m.template "TODO", "TODO", :assigns => {:name => name}
|
28
|
+
|
29
|
+
m.file "spec_helper.rb", "spec/spec_helper.rb"
|
30
|
+
|
31
|
+
m.template "sampleplugin_spec.rb", "spec/#{name}_spec.rb", :assigns => {:name => name}
|
32
|
+
m.template "sampleplugin.rb", "lib/#{name}.rb", :assigns => {:name => name}
|
33
|
+
m.template "merbtasks.rb", "lib/#{name}/merbtasks.rb", :assigns => {:name => name}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
def banner
|
39
|
+
<<-EOS
|
40
|
+
Creates a Merb plugin stub.
|
41
|
+
|
42
|
+
USAGE: #{spec.name} --generate-plugin path"
|
43
|
+
EOS
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_options!(opts)
|
47
|
+
# opts.separator ''
|
48
|
+
# opts.separator 'Options:'
|
49
|
+
# # For each option below, place the default
|
50
|
+
# # at the top of the file next to "default_options"
|
51
|
+
# opts.on("-r", "--ruby=path", String,
|
52
|
+
# "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
|
53
|
+
# "Default: #{DEFAULT_SHEBANG}") { |options[:shebang]| }
|
54
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
55
|
+
end
|
56
|
+
|
57
|
+
def extract_options
|
58
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
59
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
60
|
+
# raw instance variable value.
|
61
|
+
# @author = options[:author]
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) <%= Time.now.year %> YOUR NAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
PLUGIN = "<%= name %>"
|
5
|
+
NAME = "<%= name %>"
|
6
|
+
VERSION = "0.0.1"
|
7
|
+
AUTHOR = "Your Name"
|
8
|
+
EMAIL = "Your Email"
|
9
|
+
HOMEPAGE = "http://merb-plugins.rubyforge.org/<%= name %>/"
|
10
|
+
SUMMARY = "Merb plugin that provides ..."
|
11
|
+
|
12
|
+
spec = Gem::Specification.new do |s|
|
13
|
+
s.name = NAME
|
14
|
+
s.version = VERSION
|
15
|
+
s.platform = Gem::Platform::RUBY
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
18
|
+
s.summary = SUMMARY
|
19
|
+
s.description = s.summary
|
20
|
+
s.author = AUTHOR
|
21
|
+
s.email = EMAIL
|
22
|
+
s.homepage = HOMEPAGE
|
23
|
+
s.add_dependency('merb', '>= 0.4.0')
|
24
|
+
s.require_path = 'lib'
|
25
|
+
s.autorequire = PLUGIN
|
26
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
30
|
+
pkg.gem_spec = spec
|
31
|
+
end
|
32
|
+
|
33
|
+
task :install => [:package] do
|
34
|
+
sh %{sudo gem install pkg/#{NAME}-#{VERSION}}
|
35
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# make sure we're running inside Merb
|
2
|
+
if defined?(Merb::Plugins)
|
3
|
+
|
4
|
+
# Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
|
5
|
+
Merb::Plugins.config[:<%= name %>] = {
|
6
|
+
:chickens => false
|
7
|
+
}
|
8
|
+
|
9
|
+
Merb::Plugins.add_rakefiles "<%= name %>/merbtasks"
|
10
|
+
end
|