merb-gen 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README +6 -3
- data/Rakefile +6 -4
- data/bin/merb-gen +1 -23
- data/lib/generators/controller.rb +4 -2
- data/lib/generators/helper.rb +0 -5
- data/lib/generators/merb/merb_core.rb +95 -0
- data/lib/generators/merb/merb_flat.rb +70 -69
- data/lib/generators/merb/merb_stack.rb +110 -0
- data/lib/generators/merb/merb_very_flat.rb +61 -64
- data/lib/generators/merb_plugin.rb +5 -0
- data/lib/generators/model.rb +5 -2
- data/lib/generators/resource.rb +7 -2
- data/lib/generators/resource_controller.rb +4 -4
- data/lib/generators/templates/application/common/Rakefile +2 -6
- data/lib/generators/templates/application/common/doc.thor +149 -0
- data/lib/generators/templates/application/common/dothtaccess +17 -0
- data/lib/generators/templates/application/common/jquery.js +32 -0
- data/lib/generators/templates/application/common/merb.thor +1550 -861
- data/lib/generators/templates/application/{merb → merb_core}/app/controllers/application.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/app/controllers/exceptions.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/app/helpers/global_helpers.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/app/views/exceptions/internal_server_error.html.erb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/app/views/exceptions/not_acceptable.html.erb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/app/views/exceptions/not_found.html.erb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/autotest/discover.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/autotest/merb.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/autotest/merb_rspec.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/config/environments/development.rb +7 -2
- data/lib/generators/templates/application/{merb → merb_core}/config/environments/production.rb +5 -2
- data/lib/generators/templates/application/{merb → merb_core}/config/environments/rake.rb +6 -2
- data/lib/generators/templates/application/merb_core/config/environments/staging.rb +10 -0
- data/lib/generators/templates/application/merb_core/config/environments/test.rb +12 -0
- data/lib/generators/templates/application/{merb → merb_core}/config/init.rb +6 -6
- data/lib/generators/templates/application/{merb → merb_core}/config/rack.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/config/router.rb +0 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb +1362 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/api_grease.js +640 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/index.html.erb +37 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/merb.css +252 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/merb.rb +351 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/prototype.js +2515 -0
- data/lib/generators/templates/application/{merb/app/models → merb_core/lib}/merb/session.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/public/favicon.ico +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/public/images/merb.jpg +0 -0
- data/lib/generators/templates/application/merb_core/public/javascripts/application.js +1 -0
- data/lib/generators/templates/application/{merb → merb_core}/public/merb.fcgi +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/public/robots.txt +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/public/stylesheets/master.css +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/spec/spec.opts +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/spec/spec_helper.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/test/test_helper.rb +0 -0
- data/lib/generators/templates/application/merb_flat/application.rbt +1 -1
- data/lib/generators/templates/application/merb_flat/config/init.rb +8 -3
- data/lib/generators/templates/application/merb_plugin/LICENSE +1 -1
- data/lib/generators/templates/application/merb_stack/app/controllers/application.rb +2 -0
- data/lib/generators/templates/application/merb_stack/app/controllers/exceptions.rb +13 -0
- data/lib/generators/templates/application/merb_stack/app/helpers/global_helpers.rb +5 -0
- data/lib/generators/templates/application/merb_stack/app/models/user.rb +17 -0
- data/lib/generators/templates/application/merb_stack/app/views/exceptions/internal_server_error.html.erb +216 -0
- data/lib/generators/templates/application/merb_stack/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/lib/generators/templates/application/merb_stack/app/views/exceptions/not_found.html.erb +47 -0
- data/lib/generators/templates/application/merb_stack/autotest/discover.rb +1 -0
- data/lib/generators/templates/application/merb_stack/autotest/merb.rb +149 -0
- data/lib/generators/templates/application/merb_stack/autotest/merb_rspec.rb +165 -0
- data/lib/generators/templates/application/merb_stack/config/database.yml +33 -0
- data/lib/generators/templates/application/merb_stack/config/dependencies.rb +15 -0
- data/lib/generators/templates/application/merb_stack/config/environments/development.rb +15 -0
- data/lib/generators/templates/application/merb_stack/config/environments/production.rb +10 -0
- data/lib/generators/templates/application/merb_stack/config/environments/rake.rb +11 -0
- data/lib/generators/templates/application/merb_stack/config/environments/staging.rb +10 -0
- data/lib/generators/templates/application/merb_stack/config/environments/test.rb +12 -0
- data/lib/generators/templates/application/merb_stack/config/init.rb +24 -0
- data/lib/generators/templates/application/merb_stack/config/rack.rb +12 -0
- data/lib/generators/templates/application/merb_stack/config/router.rb +44 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb +1362 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/api_grease.js +640 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/index.html.erb +37 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/merb.css +252 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/merb.rb +351 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/prototype.js +2515 -0
- data/lib/generators/templates/application/merb_stack/merb/merb-auth/setup.rb +44 -0
- data/lib/generators/templates/application/merb_stack/merb/merb-auth/strategies.rb +11 -0
- data/lib/generators/templates/application/merb_stack/merb/session/session.rb +9 -0
- data/lib/generators/templates/application/merb_stack/public/favicon.ico +0 -0
- data/lib/generators/templates/application/merb_stack/public/images/merb.jpg +0 -0
- data/lib/generators/templates/application/merb_stack/public/javascripts/application.js +1 -0
- data/lib/generators/templates/application/merb_stack/public/merb.fcgi +22 -0
- data/lib/generators/templates/application/merb_stack/public/robots.txt +5 -0
- data/lib/generators/templates/application/merb_stack/public/stylesheets/master.css +119 -0
- data/lib/generators/templates/application/merb_stack/spec/spec.opts +0 -0
- data/lib/generators/templates/application/merb_stack/spec/spec_helper.rb +20 -0
- data/lib/generators/templates/application/merb_stack/test/test_helper.rb +19 -0
- data/lib/generators/templates/application/merb_very_flat/application.rbt +11 -5
- data/lib/generators/templates/component/layout/app/views/layout/%file_name%.html.erb +1 -0
- data/lib/generators/templates/component/resource_controller/spec/requests/%file_name%_spec.rb +53 -0
- data/lib/merb-gen/app_generator.rb +13 -0
- data/lib/merb-gen/generator.rb +36 -1
- data/lib/merb-gen/named_generator.rb +5 -2
- data/lib/merb-gen.rb +6 -8
- data/spec/controller_spec.rb +0 -20
- data/spec/{merb_full_spec.rb → merb_core_spec.rb} +11 -3
- data/spec/merb_stack_spec.rb +47 -0
- data/spec/part_controller_spec.rb +0 -39
- data/spec/resource_controller_spec.rb +1 -35
- data/spec/spec_helper.rb +4 -2
- metadata +133 -111
- data/lib/generators/merb/merb_full.rb +0 -85
- data/lib/generators/merb.rb +0 -24
- data/lib/generators/templates/application/merb/config/environments/staging.rb +0 -7
- data/lib/generators/templates/application/merb/config/environments/test.rb +0 -7
- data/lib/generators/templates/component/helper/spec/helpers/%file_name%_helper_spec.rb +0 -5
- data/lib/generators/templates/component/resource_controller/spec/controllers/%file_name%_spec.rb +0 -7
- data/spec/helper_spec.rb +0 -43
- data/spec/merb_spec.rb +0 -20
@@ -0,0 +1,165 @@
|
|
1
|
+
# Adapted from Autotest::Rails, RSpec's autotest class, as well as merb-core's.
|
2
|
+
require 'autotest'
|
3
|
+
|
4
|
+
class RspecCommandError < StandardError; end
|
5
|
+
|
6
|
+
# This class maps your application's structure so Autotest can understand what
|
7
|
+
# specs to run when files change.
|
8
|
+
#
|
9
|
+
# Fixtures are _not_ covered by this class. If you change a fixture file, you
|
10
|
+
# will have to run your spec suite manually, or, better yet, provide your own
|
11
|
+
# Autotest map explaining how your fixtures are set up.
|
12
|
+
class Autotest::MerbRspec < Autotest
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
|
16
|
+
# Ignore any happenings in these directories
|
17
|
+
add_exception %r%^\./(?:doc|log|public|tmp|\.git|\.hg|\.svn|framework|gems|schema|\.DS_Store|autotest|bin|.*\.sqlite3)%
|
18
|
+
# Ignore SCM directories and custom Autotest mappings
|
19
|
+
%w[.svn .hg .git .autotest].each { |exception| add_exception(exception) }
|
20
|
+
|
21
|
+
# Ignore any mappings that Autotest may have already set up
|
22
|
+
clear_mappings
|
23
|
+
|
24
|
+
# Anything in /lib could have a spec anywhere, if at all. So, look for
|
25
|
+
# files with roughly the same name as the file in /lib
|
26
|
+
add_mapping %r%^lib\/(.*)\.rb% do |_, m|
|
27
|
+
files_matching %r%^spec\/#{m[1]}%
|
28
|
+
end
|
29
|
+
|
30
|
+
add_mapping %r%^spec/(spec_helper|shared/.*)\.rb$% do
|
31
|
+
all_specs
|
32
|
+
end
|
33
|
+
|
34
|
+
# Changing a spec will cause it to run itself
|
35
|
+
add_mapping %r%^spec/.*\.rb$% do |filename, _|
|
36
|
+
filename
|
37
|
+
end
|
38
|
+
|
39
|
+
# Any change to a model will cause it's corresponding test to be run
|
40
|
+
add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
|
41
|
+
spec_for(m[1], 'model')
|
42
|
+
end
|
43
|
+
|
44
|
+
# Any change to global_helpers will result in all view and controller
|
45
|
+
# tests being run
|
46
|
+
add_mapping %r%^app/helpers/global_helpers\.rb% do
|
47
|
+
files_matching %r%^spec/(views|controllers|helpers)/.*_spec\.rb$%
|
48
|
+
end
|
49
|
+
|
50
|
+
# Any change to a helper will cause its spec to be run
|
51
|
+
add_mapping %r%^app/helpers/((.*)_helper(s)?)\.rb% do |_, m|
|
52
|
+
spec_for(m[1], 'helper')
|
53
|
+
end
|
54
|
+
|
55
|
+
# Changes to a view cause its spec to be run
|
56
|
+
add_mapping %r%^app/views/(.*)/% do |_, m|
|
57
|
+
spec_for(m[1], 'view')
|
58
|
+
end
|
59
|
+
|
60
|
+
# Changes to a controller result in its corresponding spec being run. If
|
61
|
+
# the controller is the exception or application controller, all
|
62
|
+
# controller specs are run.
|
63
|
+
add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
|
64
|
+
if ["application", "exception"].include?(m[1])
|
65
|
+
files_matching %r%^spec/controllers/.*_spec\.rb$%
|
66
|
+
else
|
67
|
+
spec_for(m[1], 'controller')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# If a change is made to the router, run controller, view and helper specs
|
72
|
+
add_mapping %r%^config/router.rb$% do
|
73
|
+
files_matching %r%^spec/(controllers|views|helpers)/.*_spec\.rb$%
|
74
|
+
end
|
75
|
+
|
76
|
+
# If any of the major files governing the environment are altered, run
|
77
|
+
# everything
|
78
|
+
add_mapping %r%^config/(init|rack|environments/test).*\.rb|database\.yml% do
|
79
|
+
all_specs
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def failed_results(results)
|
84
|
+
results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
|
85
|
+
end
|
86
|
+
|
87
|
+
def handle_results(results)
|
88
|
+
@failures = failed_results(results)
|
89
|
+
@files_to_test = consolidate_failures(@failures)
|
90
|
+
@files_to_test.empty? && !$TESTING ? hook(:green) : hook(:red)
|
91
|
+
@tainted = !@files_to_test.empty?
|
92
|
+
end
|
93
|
+
|
94
|
+
def consolidate_failures(failed)
|
95
|
+
filters = Hash.new { |h,k| h[k] = [] }
|
96
|
+
failed.each do |spec, failed_trace|
|
97
|
+
if f = test_files_for(failed).find { |f| f =~ /spec\// }
|
98
|
+
filters[f] << spec
|
99
|
+
break
|
100
|
+
end
|
101
|
+
end
|
102
|
+
filters
|
103
|
+
end
|
104
|
+
|
105
|
+
def make_test_cmd(specs_to_runs)
|
106
|
+
[
|
107
|
+
ruby,
|
108
|
+
"-S",
|
109
|
+
spec_command,
|
110
|
+
add_options_if_present,
|
111
|
+
files_to_test.keys.flatten.join(' ')
|
112
|
+
].join(' ')
|
113
|
+
end
|
114
|
+
|
115
|
+
def add_options_if_present
|
116
|
+
File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
|
117
|
+
end
|
118
|
+
|
119
|
+
# Finds the proper spec command to use. Precendence is set in the
|
120
|
+
# lazily-evaluated method spec_commands. Alias + Override that in
|
121
|
+
# ~/.autotest to provide a different spec command then the default
|
122
|
+
# paths provided.
|
123
|
+
def spec_command(separator=File::ALT_SEPARATOR)
|
124
|
+
unless defined?(@spec_command)
|
125
|
+
@spec_command = spec_commands.find { |cmd| File.exists?(cmd) }
|
126
|
+
|
127
|
+
raise RspecCommandError, "No spec command could be found" unless @spec_command
|
128
|
+
|
129
|
+
@spec_command.gsub!(File::SEPARATOR, separator) if separator
|
130
|
+
end
|
131
|
+
@spec_command
|
132
|
+
end
|
133
|
+
|
134
|
+
# Autotest will look for spec commands in the following
|
135
|
+
# locations, in this order:
|
136
|
+
#
|
137
|
+
# * default spec bin/loader installed in Rubygems
|
138
|
+
# * any spec command found in PATH
|
139
|
+
def spec_commands
|
140
|
+
[File.join(Config::CONFIG['bindir'], 'spec'), 'spec']
|
141
|
+
end
|
142
|
+
|
143
|
+
private
|
144
|
+
|
145
|
+
# Runs +files_matching+ for all specs
|
146
|
+
def all_specs
|
147
|
+
files_matching %r%^spec/.*_spec\.rb$%
|
148
|
+
end
|
149
|
+
|
150
|
+
# Generates a path to some spec given its kind and the match from a mapping
|
151
|
+
#
|
152
|
+
# ==== Arguments
|
153
|
+
# match<String>:: the match from a mapping
|
154
|
+
# kind<String>:: the kind of spec that the match represents
|
155
|
+
#
|
156
|
+
# ==== Returns
|
157
|
+
# String
|
158
|
+
#
|
159
|
+
# ==== Example
|
160
|
+
# > spec_for('post', :view')
|
161
|
+
# => "spec/views/post_spec.rb"
|
162
|
+
def spec_for(match, kind)
|
163
|
+
File.join("spec", kind + 's', "#{match}_spec.rb")
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
# This is a sample database file for the DataMapper ORM
|
3
|
+
development: &defaults
|
4
|
+
# These are the settings for repository :default
|
5
|
+
adapter: sqlite3
|
6
|
+
database: sample_development.db
|
7
|
+
|
8
|
+
# Add more repositories
|
9
|
+
# repositories:
|
10
|
+
# repo1:
|
11
|
+
# adapter: sqlite3
|
12
|
+
# database: sample_1_development.db
|
13
|
+
# repo2:
|
14
|
+
# ...
|
15
|
+
|
16
|
+
test:
|
17
|
+
<<: *defaults
|
18
|
+
database: sample_test.db
|
19
|
+
|
20
|
+
# repositories:
|
21
|
+
# repo1:
|
22
|
+
# database: sample_1_test.db
|
23
|
+
|
24
|
+
production:
|
25
|
+
<<: *defaults
|
26
|
+
database: production.db
|
27
|
+
|
28
|
+
# repositories:
|
29
|
+
# repo1:
|
30
|
+
# database: sample_production.db
|
31
|
+
|
32
|
+
rake:
|
33
|
+
<<: *defaults
|
@@ -0,0 +1,15 @@
|
|
1
|
+
dependency "merb-action-args", "0.9.9" # Provides support for querystring arguments to be passed in to controller actions
|
2
|
+
dependency "merb-assets", "0.9.9" # Provides link_to, asset_path, auto_link, image_tag methods (and lots more)
|
3
|
+
dependency "merb-cache", "0.9.9" # Provides your application with caching functions
|
4
|
+
dependency "merb-helpers", "0.9.9" # Provides the form, date/time, and other helpers
|
5
|
+
dependency "merb-mailer", "0.9.9" # Integrates mail support via Merb Mailer
|
6
|
+
dependency "merb-slices", "0.9.9" # Provides a mechanism for letting plugins provide controllers, views, etc. to your app
|
7
|
+
dependency "merb-auth", "0.9.9" # An authentication slice (Merb's equivalent to Rails' restful authentication)
|
8
|
+
dependency "merb-param-protection", "0.9.9"
|
9
|
+
|
10
|
+
dependency "dm-core", "0.9.6" # The datamapper ORM
|
11
|
+
dependency "dm-aggregates", "0.9.6" # Provides your DM models with count, sum, avg, min, max, etc.
|
12
|
+
dependency "dm-migrations", "0.9.6" # Make incremental changes to your database.
|
13
|
+
dependency "dm-timestamps", "0.9.6" # Automatically populate created_at, created_on, etc. when those properties are present.
|
14
|
+
dependency "dm-types", "0.9.6" # Provides additional types, including csv, json, yaml.
|
15
|
+
dependency "dm-validations", "0.9.6" # Validation framework
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Merb.logger.info("Loaded DEVELOPMENT Environment...")
|
2
|
+
Merb::Config.use { |c|
|
3
|
+
c[:exception_details] = true
|
4
|
+
c[:reload_templates] = true
|
5
|
+
c[:reload_classes] = true
|
6
|
+
c[:reload_time] = 0.5
|
7
|
+
c[:ignore_tampered_cookies] = true
|
8
|
+
c[:log_auto_flush ] = true
|
9
|
+
c[:log_level] = :debug
|
10
|
+
|
11
|
+
c[:log_stream] = STDOUT
|
12
|
+
c[:log_file] = nil
|
13
|
+
# Or redirect logging into a file:
|
14
|
+
# c[:log_file] = Merb.root / "log" / "development.log"
|
15
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Merb.logger.info("Loaded PRODUCTION Environment...")
|
2
|
+
Merb::Config.use { |c|
|
3
|
+
c[:exception_details] = false
|
4
|
+
c[:reload_classes] = false
|
5
|
+
c[:log_level] = :error
|
6
|
+
|
7
|
+
c[:log_file] = Merb.root / "log" / "production.log"
|
8
|
+
# or redirect logger using IO handle
|
9
|
+
# c[:log_stream] = STDOUT
|
10
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Merb.logger.info("Loaded RAKE Environment...")
|
2
|
+
Merb::Config.use { |c|
|
3
|
+
c[:exception_details] = true
|
4
|
+
c[:reload_classes] = false
|
5
|
+
c[:log_auto_flush ] = true
|
6
|
+
|
7
|
+
c[:log_stream] = STDOUT
|
8
|
+
c[:log_file] = nil
|
9
|
+
# Or redirect logging into a file:
|
10
|
+
# c[:log_file] = Merb.root / "log" / "development.log"
|
11
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Merb.logger.info("Loaded STAGING Environment...")
|
2
|
+
Merb::Config.use { |c|
|
3
|
+
c[:exception_details] = false
|
4
|
+
c[:reload_classes] = false
|
5
|
+
c[:log_level] = :error
|
6
|
+
|
7
|
+
c[:log_file] = Merb.root / "log" / "staging.log"
|
8
|
+
# or redirect logger using IO handle
|
9
|
+
# c[:log_stream] = STDOUT
|
10
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Merb.logger.info("Loaded TEST Environment...")
|
2
|
+
Merb::Config.use { |c|
|
3
|
+
c[:testing] = true
|
4
|
+
c[:exception_details] = true
|
5
|
+
c[:log_auto_flush ] = true
|
6
|
+
# log less in testing environment
|
7
|
+
c[:log_level] = :error
|
8
|
+
|
9
|
+
c[:log_file] = Merb.root / "log" / "test.log"
|
10
|
+
# or redirect logger using IO handle
|
11
|
+
# c[:log_stream] = STDOUT
|
12
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Go to http://wiki.merbivore.com/pages/init-rb
|
2
|
+
|
3
|
+
require 'config/dependencies.rb'
|
4
|
+
|
5
|
+
use_orm :datamapper
|
6
|
+
use_test :rspec
|
7
|
+
use_template_engine :erb
|
8
|
+
|
9
|
+
Merb::Config.use do |c|
|
10
|
+
c[:use_mutex] = false
|
11
|
+
c[:session_store] = 'cookie' # can also be 'memory', 'memcache', 'container', 'datamapper
|
12
|
+
|
13
|
+
# cookie session store configuration
|
14
|
+
c[:session_secret_key] = '1205346b9baa87cf8e49f78124c8d17a31ac0971' # required for cookie session store
|
15
|
+
# c[:session_id_key] = '_session_id' # cookie session id key, defaults to "_session_id"
|
16
|
+
end
|
17
|
+
|
18
|
+
Merb::BootLoader.before_app_loads do
|
19
|
+
# This will get executed after dependencies have been loaded but before your app's classes have loaded.
|
20
|
+
end
|
21
|
+
|
22
|
+
Merb::BootLoader.after_app_loads do
|
23
|
+
# This will get executed after your app's classes have been loaded.
|
24
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
# use PathPrefix Middleware if :path_prefix is set in Merb::Config
|
3
|
+
if prefix = ::Merb::Config[:path_prefix]
|
4
|
+
use Merb::Rack::PathPrefix, prefix
|
5
|
+
end
|
6
|
+
|
7
|
+
# comment this out if you are running merb behind a load balancer
|
8
|
+
# that serves static files
|
9
|
+
use Merb::Rack::Static, Merb.dir_for(:public)
|
10
|
+
|
11
|
+
# this is our main merb application
|
12
|
+
run Merb::Rack::Application.new
|
@@ -0,0 +1,44 @@
|
|
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
|
+
# 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
|
+
# 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
|
+
# match("/admin/:module/:controller/:action/:id").
|
17
|
+
# to(:controller => ":module/:controller")
|
18
|
+
#
|
19
|
+
# You can specify conditions on the placeholder by passing a hash as the second
|
20
|
+
# argument of "match"
|
21
|
+
#
|
22
|
+
# match("/registration/:course_name", :course_name => /^[a-z]{3,5}-\d{5}$/).
|
23
|
+
# to(:controller => "registration")
|
24
|
+
#
|
25
|
+
# You can also use regular expressions, deferred routes, and many other options.
|
26
|
+
# See merb/specs/merb/router.rb for a fairly complete usage sample.
|
27
|
+
|
28
|
+
Merb.logger.info("Compiling routes...")
|
29
|
+
Merb::Router.prepare do
|
30
|
+
# RESTful routes
|
31
|
+
# resources :posts
|
32
|
+
|
33
|
+
# Adds the required routes for merb-auth using the password slice
|
34
|
+
slice(:merb_auth_slice_password, :name_prefix => nil, :path_prefix => "")
|
35
|
+
|
36
|
+
# This is the default route for /:controller/:action/:id
|
37
|
+
# This is fine for most cases. If you're heavily using resource-based
|
38
|
+
# routes, you may want to comment/remove this line to prevent
|
39
|
+
# clients from calling your create or destroy actions with a GET
|
40
|
+
default_routes
|
41
|
+
|
42
|
+
# Change this for your home page to be available at /
|
43
|
+
# match('/').to(:controller => 'whatever', :action =>'index')
|
44
|
+
end
|