merb-gen 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. data/Rakefile +1 -1
  2. data/lib/generators/merb/merb_stack.rb +8 -0
  3. data/lib/generators/resource.rb +1 -1
  4. data/lib/generators/resource_controller.rb +12 -0
  5. data/lib/generators/templates/application/common/merb.thor +77 -32
  6. data/lib/generators/templates/application/merb_core/app/controllers/exceptions.rb +1 -1
  7. data/lib/generators/templates/application/merb_core/config/init.rb +19 -183
  8. data/lib/generators/templates/application/merb_flat/config/init.rb +10 -112
  9. data/lib/generators/templates/application/merb_plugin/LICENSE +1 -1
  10. data/lib/generators/templates/application/merb_stack/app/controllers/exceptions.rb +1 -1
  11. data/lib/generators/templates/application/merb_stack/app/models/user.rb +1 -1
  12. data/lib/generators/templates/application/merb_stack/config/dependencies.rb +22 -14
  13. data/lib/generators/templates/application/merb_stack/config/init.rb +3 -3
  14. data/lib/generators/templates/application/merb_stack/merb/merb-auth/setup.rb +1 -1
  15. data/lib/generators/templates/component/resource_controller/app/views/%file_name%/edit.html.erb +2 -1
  16. data/lib/generators/templates/component/resource_controller/app/views/%file_name%/index.html.erb +2 -1
  17. data/lib/generators/templates/component/resource_controller/app/views/%file_name%/new.html.erb +2 -1
  18. data/lib/generators/templates/component/resource_controller/app/views/%file_name%/show.html.erb +2 -1
  19. data/lib/generators/templates/component/resource_controller/spec/requests/%file_name%_spec.rb +73 -4
  20. metadata +4 -6
  21. data/lib/generators/templates/application/merb_core/app/views/exceptions/internal_server_error.html.erb +0 -216
  22. data/lib/generators/templates/application/merb_stack/app/views/exceptions/internal_server_error.html.erb +0 -216
data/Rakefile CHANGED
@@ -40,7 +40,7 @@ spec = Gem::Specification.new do |s|
40
40
  s.bindir = "bin"
41
41
  s.executables = %w( merb-gen )
42
42
 
43
- s.add_dependency "merb-core", ">= 0.9.9"
43
+ s.add_dependency "merb-core", ">= #{Merb::VERSION}"
44
44
  s.add_dependency "templater", ">= 0.3.3"
45
45
 
46
46
  s.require_path = 'lib'
@@ -90,6 +90,14 @@ module Merb
90
90
  # ==== Layout specific things
91
91
  #
92
92
 
93
+ def merb_gems_version
94
+ "0.9.10"
95
+ end
96
+
97
+ def dm_gems_version
98
+ "0.9.6"
99
+ end
100
+
93
101
  # empty array means all files are considered to be just
94
102
  # files, not templates
95
103
  glob! "app"
@@ -29,7 +29,7 @@ module Merb::Generators
29
29
  end
30
30
 
31
31
  def after_generation
32
- STDOUT << message("Don't forget to set your resource route in config/router.rb for instance: resources :#{model_name.downcase}s ")
32
+ STDOUT << message("resources :#{model_name.pluralize.snake_case} route added to config/router.rb")
33
33
  end
34
34
  end
35
35
 
@@ -30,6 +30,8 @@ module Merb::Generators
30
30
  template :controller_none, :orm => :none do |template|
31
31
  template.source = "app/controllers/%file_name%.rb"
32
32
  template.destination = "app/controllers" / base_path / "#{file_name}.rb"
33
+
34
+ self.add_resource_route(self.plural_model)
33
35
  end
34
36
 
35
37
  [:index, :show, :edit, :new].each do |view|
@@ -49,6 +51,16 @@ module Merb::Generators
49
51
  template.destination = "test/controllers" / base_path / "#{file_name}_test.rb"
50
52
  end
51
53
 
54
+ def add_resource_route(plural_resource)
55
+ router_path = Merb.root + "/config/router.rb"
56
+ sentinel = "Merb::Router.prepare do"
57
+ to_inject = "resources :#{plural_resource}"
58
+ if File.exist?(router_path)
59
+ content = File.read(router_path).gsub(/(#{Regexp.escape(sentinel)})/mi){|match| "#{match}\n #{to_inject}"}
60
+ File.open(router_path, 'wb') { |file| file.write(content) }
61
+ end
62
+ end
63
+
52
64
  def model_class_name
53
65
  class_name.singularize
54
66
  end
@@ -5,7 +5,7 @@ require 'fileutils'
5
5
  require 'yaml'
6
6
 
7
7
  # Important - don't change this line or its position
8
- MERB_THOR_VERSION = '0.0.5'
8
+ MERB_THOR_VERSION = '0.0.52'
9
9
 
10
10
  ##############################################################################
11
11
 
@@ -198,7 +198,7 @@ module GemManagement
198
198
  options[:version] = Gem::Requirement.new ["= #{options[:version]}"]
199
199
  end
200
200
  update_source_index(options[:install_dir]) if options[:install_dir]
201
- Gem::Uninstaller.new(gem, options).uninstall
201
+ Gem::Uninstaller.new(gem, options).uninstall rescue nil
202
202
  end
203
203
 
204
204
  def clobber(source_dir)
@@ -260,7 +260,7 @@ module GemManagement
260
260
  gemspecs = ::Gem.source_index.search(dep)
261
261
  local = gemspecs.reverse.find { |s| s.loaded_from.index(gem_dir) == 0 }
262
262
  if local
263
- local_specs << local
263
+ local_specs << local
264
264
  elsif gemspecs.last
265
265
  system_specs << gemspecs.last
266
266
  else
@@ -268,6 +268,15 @@ module GemManagement
268
268
  end
269
269
  end
270
270
  ::Gem.clear_paths
271
+ else
272
+ dependencies.each do |dep|
273
+ gemspecs = ::Gem.source_index.search(dep)
274
+ if gemspecs.last
275
+ system_specs << gemspecs.last
276
+ else
277
+ missing_deps << dep
278
+ end
279
+ end
271
280
  end
272
281
  [system_specs, local_specs, missing_deps]
273
282
  end
@@ -316,9 +325,12 @@ end
316
325
  if File.directory?(gems_dir = File.join(Dir.pwd, 'gems')) ||
317
326
  File.directory?(gems_dir = File.join(File.dirname(__FILE__), '..', 'gems'))
318
327
  $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(gems_dir)
328
+ if (local_gem = Dir[File.join(gems_dir, "specifications", "#{spec.name}-*.gemspec")].last)
329
+ version = File.basename(local_gem)[/-([\\.\\d]+)\\.gemspec$/, 1]
330
+ end
319
331
  end
320
332
 
321
- version = "#{Gem::Requirement.default}"
333
+ version ||= "#{Gem::Requirement.default}"
322
334
 
323
335
  if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
324
336
  version = $1
@@ -415,17 +427,12 @@ end
415
427
 
416
428
  module MerbThorHelper
417
429
 
418
- attr_accessor :include_dependencies
430
+ attr_accessor :include_dependencies, :force_gem_dir
419
431
 
420
432
  def self.included(base)
421
433
  base.send(:include, ColorfulMessages)
422
434
  base.extend ColorfulMessages
423
435
  end
424
-
425
- def install_dependency(dependency, opts = {})
426
- opts[:version] ||= dependency.version_requirements.to_s
427
- Merb::Gem.install(dependency.name, default_install_options.merge(opts))
428
- end
429
436
 
430
437
  def source_manager
431
438
  @_source_manager ||= SourceManager.new(source_dir)
@@ -467,6 +474,11 @@ module MerbThorHelper
467
474
  end
468
475
  end
469
476
  end
477
+
478
+ def install_dependency(dependency, opts = {})
479
+ opts[:version] ||= dependency.version_requirements.to_s
480
+ Merb::Gem.install(dependency.name, default_install_options.merge(opts))
481
+ end
470
482
 
471
483
  def install_dependency_from_source(dependency, opts = {})
472
484
  matches = Dir[File.join(source_dir, "**", dependency.name, "{Rakefile,Thorfile}")]
@@ -506,7 +518,7 @@ module MerbThorHelper
506
518
  note 'Uninstalling existing local gems:'
507
519
  local.each { |gemspec| note "Uninstalled #{gemspec.name}" }
508
520
  else
509
- message 'Uninstalling existing local gems:'
521
+ message 'Uninstalling existing local gems:' if local.size > 1
510
522
  local.each do |gemspec|
511
523
  Merb::Gem.uninstall(gemspec.name, default_uninstall_options)
512
524
  end
@@ -571,6 +583,7 @@ module MerbThorHelper
571
583
 
572
584
  # If a local ./gems dir is found, return it.
573
585
  def gem_dir
586
+ return force_gem_dir if force_gem_dir
574
587
  if File.directory?(dir = default_gem_dir)
575
588
  dir
576
589
  end
@@ -605,7 +618,7 @@ module MerbThorHelper
605
618
  ENV['THOR_SUDO'] ||= "sudo"
606
619
  sudo = Gem.win_platform? ? "" : ENV['THOR_SUDO']
607
620
  end
608
-
621
+
609
622
  def local_gemspecs(directory = gem_dir)
610
623
  if File.directory?(specs_dir = File.join(directory, 'specifications'))
611
624
  Dir[File.join(specs_dir, '*.gemspec')].map do |gemspec_path|
@@ -893,10 +906,10 @@ module Merb
893
906
  if method = strategy?(strategy)
894
907
  # Clobber existing local dependencies
895
908
  clobber_dependencies!
896
-
909
+
897
910
  # Run the chosen strategy - collect files installed from stable gems
898
911
  installed_from_stable = send(method, deps).map { |d| d.name }
899
-
912
+
900
913
  # Sleep a bit otherwise the following steps won't see the new files
901
914
  sleep(deps.length) if deps.length > 0
902
915
 
@@ -910,16 +923,10 @@ module Merb
910
923
  end
911
924
  end
912
925
 
913
- # Ask for system installation of minigem - needs sudo...
914
- if deps.find { |d| d.name == 'minigems' }
915
- info "Installing minigems.rb on your system..."
916
- `#{sudo} minigem install`
917
- end
918
-
919
926
  # Add local binaries for the installed framework dependencies
920
927
  comps = Merb::Stack.all_components & deps.map { |d| d.name }
921
928
  comps << { :no_minigems => 'merb-gen' }
922
- ensure_bin_wrapper_for(*comps)
929
+ ensure_bin_wrapper_for(*comps)
923
930
  return true
924
931
  end
925
932
  false
@@ -1087,9 +1094,6 @@ module Merb
1087
1094
  rescue => e
1088
1095
  error "Couldn't extract dependencies from application!"
1089
1096
  error e.message
1090
-
1091
- p e.backtrace
1092
-
1093
1097
  puts "Make sure you're executing the task from your app (--merb-root), or"
1094
1098
  puts "specify a config option (--config or --config-file=YAML_FILE)"
1095
1099
  return []
@@ -1119,6 +1123,7 @@ module Merb
1119
1123
  # regardless of actual application dependency settings.
1120
1124
 
1121
1125
  DM_STACK = %w[
1126
+ extlib
1122
1127
  dm-core
1123
1128
  dm-aggregates
1124
1129
  dm-migrations
@@ -1127,9 +1132,8 @@ module Merb
1127
1132
  dm-validations
1128
1133
  ]
1129
1134
 
1130
- MERB_STACK = %w[
1131
- minigems
1132
-
1135
+ MERB_STACK = %w[
1136
+ extlib
1133
1137
  merb-core
1134
1138
  merb-action-args
1135
1139
  merb-assets
@@ -1140,9 +1144,8 @@ module Merb
1140
1144
  merb-auth
1141
1145
  ] + DM_STACK
1142
1146
 
1143
- MERB_BASICS = %w[
1144
- minigems
1145
-
1147
+ MERB_BASICS = %w[
1148
+ extlib
1146
1149
  merb-core
1147
1150
  merb-action-args
1148
1151
  merb-assets
@@ -1281,6 +1284,7 @@ module Merb
1281
1284
  # See also: Merb::Dependencies#uninstall
1282
1285
  #
1283
1286
  # Examples:
1287
+ #
1284
1288
  # merb:stack:uninstall # uninstall the default merb stack
1285
1289
  # merb:stack:uninstall merb-more # uninstall merb-more
1286
1290
  # merb:stack:uninstall merb-core thor merb-slices # uninstall the specified gems
@@ -1294,6 +1298,48 @@ module Merb
1294
1298
  clobber_dependencies!
1295
1299
  end
1296
1300
 
1301
+ # Install or uninstall minigems from the system.
1302
+ #
1303
+ # Due to the specific nature of MiniGems it can only be installed system-wide.
1304
+ #
1305
+ # Examples:
1306
+ #
1307
+ # merb:stack:minigems install # install minigems
1308
+ # merb:stack:minigems uninstall # uninstall minigems
1309
+
1310
+ desc 'minigems (install|uninstall)', 'Install or uninstall minigems (needs sudo privileges)'
1311
+ def minigems(action)
1312
+ case action
1313
+ when 'install'
1314
+ Kernel.system "#{sudo} thor merb:stack:install_minigems"
1315
+ when 'uninstall'
1316
+ Kernel.system "#{sudo} thor merb:stack:uninstall_minigems"
1317
+ else
1318
+ error "Invalid command: merb:stack:minigems #{action}"
1319
+ end
1320
+ end
1321
+
1322
+ # hidden minigems install task
1323
+ def install_minigems
1324
+ message "Installing MiniGems"
1325
+ mngr = self.dependency_manager
1326
+ deps = gather_dependencies('minigems')
1327
+ mngr.system, mngr.local, mngr.missing = Merb::Gem.partition_dependencies(deps, gem_dir)
1328
+ mngr.force_gem_dir = ::Gem.dir
1329
+ mngr.install_dependencies(strategy, deps)
1330
+ Kernel.system "#{sudo} minigem install"
1331
+ end
1332
+
1333
+ # hidden minigems uninstall task
1334
+ def uninstall_minigems
1335
+ message "Uninstalling MiniGems"
1336
+ Kernel.system "#{sudo} minigem uninstall"
1337
+ deps = gather_dependencies('minigems')
1338
+ self.system, self.local, self.missing = Merb::Gem.partition_dependencies(deps, gem_dir)
1339
+ # Clobber existing local dependencies - based on self.local
1340
+ clobber_dependencies!
1341
+ end
1342
+
1297
1343
  protected
1298
1344
 
1299
1345
  def gather_dependencies(comps = [])
@@ -1900,8 +1946,7 @@ module Merb
1900
1946
  'sequel' => "git://github.com/wayneeseguin/sequel.git",
1901
1947
  'do' => "git://github.com/sam/do.git",
1902
1948
  'thor' => "git://github.com/wycats/thor.git",
1903
- 'rake' => "git://github.com/jimweirich/rake.git",
1904
- 'minigems' => "git://github.com/fabien/minigems.git"
1949
+ 'rake' => "git://github.com/jimweirich/rake.git"
1905
1950
  }
1906
1951
  end
1907
1952
 
@@ -1,4 +1,4 @@
1
- class Exceptions < Application
1
+ class Exceptions < Merb::Controller
2
2
 
3
3
  # handle NotFound exceptions (404)
4
4
  def not_found
@@ -1,189 +1,25 @@
1
- #
2
- # ==== Structure of Merb initializer
3
- #
4
- # 1. Load paths.
5
- # 2. Dependencies configuration.
6
- # 3. Libraries (ORM, testing tool, etc) you use.
7
- # 4. Application-specific configuration.
8
-
9
- #
10
- # ==== Set up load paths
11
- #
12
-
13
- # Add the app's "gems" directory to the gem load path.
14
- # Note that the gems directory must mirror the structure RubyGems uses for
15
- # directories under which gems are kept.
16
- #
17
- # To conveniently set it up, use gem install -i <merb_app_root/gems>
18
- # when installing gems. This will set up the structure under /gems
19
- # automagically.
20
- #
21
- # An example:
22
- #
23
- # You want to bundle ActiveRecord and ActiveSupport with your Merb
24
- # application to be deployment environment independent. To do so,
25
- # install gems into merb_app_root/gems directory like this:
26
- #
27
- # gem install -i merb_app_root/gems activesupport-post-2.0.2.gem activerecord-post-2.0.2.gem
28
- #
29
- # Since RubyGems will search merb_app_root/gems for dependencies, order
30
- # in the statement above is important: we need to install ActiveSupport which
31
- # ActiveRecord depends on first.
32
- #
33
- # Remember that bundling of dependencies as gems with your application
34
- # makes it independent of the environment it runs in and is a very
35
- # good, encouraged practice to follow.
36
-
37
- # If you want modules and classes from libraries organized like
38
- # merbapp/lib/magicwand/lib/magicwand.rb to autoload,
39
- # uncomment this.
40
- # Merb.push_path(:lib, Merb.root / "lib") # uses **/*.rb as path glob.
41
-
42
- # ==== Dependencies
43
-
44
- # These are a few, but not all, of the standard merb-more dependencies:
45
- #
46
- # dependency "merb-action-args" # Provides support for querystring arguments to be passed in to controller actions
47
- # dependency "merb-assets" # Provides link_to, asset_path, auto_link, image_tag methods (and lots more)
48
- # dependency "merb-helpers" # Provides the form, date/time, and other helpers
49
- # dependency "merb-cache" # Provides your application with caching functions
50
- # dependency "merb-haml" # Adds rake tasks and the haml generators to your merb app
51
- # dependency "merb-jquery" # Provides a #jquery method to insert jQuery code in to a content block
52
- # dependency "merb-mailer" # Integrates mail support via Merb Mailer
53
-
54
- # These are a few, but not all, of the merb-plugin dependencies:
55
- #
56
- # dependency "merb_param_protection" # Lets you have better control over your query string params and param logging
57
- # dependency "merb_stories" # Provides rspec helper methods for your application
58
-
59
- # Miscellaneous dependencies:
60
- #
61
- # Specify more than one dependency at a time with the #dependencies method:
62
- # dependencies "RedCloth", "BlueCloth"
63
-
1
+ # Go to http://wiki.merbivore.com/pages/init-rb
2
+
64
3
  # Specify a specific version of a dependency
65
4
  # dependency "RedCloth", "> 3.0"
66
5
 
67
- # Specify more than one dependency at a time as well as the version:
68
- # dependencies "RedCloth" => "> 3.0", "BlueCloth" => "= 1.0.0"
69
-
70
- # You can also add in dependencies after your application loads.
71
- Merb::BootLoader.after_app_loads do
72
- # For example, the magic_admin gem uses the app's model classes. This requires that the models be
73
- # loaded already. So, we can put the magic_admin dependency here:
74
- # dependency "magic_admin"
75
- end
76
-
77
- #
78
- # ==== Set up your ORM of choice
79
- #
80
-
81
- # Merb doesn't come with database support by default. You need
82
- # an ORM plugin. Install one, and uncomment one of the following lines,
83
- # if you need a database.
84
-
85
- # Uncomment for DataMapper ORM
86
- <%= "# " unless orm == :datamapper %>use_orm :datamapper
87
-
88
- # Uncomment for ActiveRecord ORM
89
- <%= "# " unless orm == :activerecord %>use_orm :activerecord
90
-
91
- # Uncomment for Sequel ORM
92
- <%= "# " unless orm == :sequel %>use_orm :sequel
93
-
94
-
95
- #
96
- # ==== Pick what you test with
97
- #
98
-
99
- # This defines which test framework the generators will use.
100
- # RSpec is turned on by default.
101
- #
102
- # To use Test::Unit, you need to install the merb_test_unit gem.
103
- # To use RSpec, you don't have to install any additional gems, since
104
- # merb-core provides support for RSpec.
105
- #
106
- <%= "# " unless testing_framework == :test_unit %>use_test :test_unit
107
- <%= "# " unless testing_framework == :rspec %>use_test :rspec
108
-
109
-
110
- #
111
- # ==== Choose which template engine to use by default
112
- #
113
-
114
- # Merb can generate views for different template engines, choose your favourite as the default.
115
-
116
- <%= "# " unless template_engine == :erb %>use_template_engine :erb
117
- <%= "# " unless template_engine == :haml %>use_template_engine :haml
118
-
119
-
120
- #
121
- # ==== Set up your basic configuration
122
- #
123
-
124
- # IMPORTANT:
125
- #
126
- # early on Merb boot init file is not yet loaded.
127
- # Thus setting PORT, PID FILE and ADAPTER using init file does not
128
- # make sense and only can lead to confusion because default settings
129
- # will be used instead.
130
- #
131
- # Please use command line options for them.
132
- # See http://wiki.merbivore.com/pages/merb-core-boot-process
133
- # if you want to know more.
6
+ <%= "# " unless orm != :none %> use_orm :<%= orm %>
7
+ use_test :<%= testing_framework %>
8
+ use_template_engine :<%= template_engine %>
9
+
134
10
  Merb::Config.use do |c|
135
- # Sets up a custom session id key which is used for the session persistence
136
- # cookie name. If not specified, defaults to '_session_id'.
137
- # c[:session_id_key] = '_session_id'
11
+ c[:use_mutex] = false
12
+ c[:session_store] = 'cookie' # can also be 'memory', 'memcache', 'container', 'datamapper
138
13
 
139
- # The session_secret_key is only required for the cookie session store.
140
- c[:session_secret_key] = '<%= SHA1.new(rand(100000000000).to_s).to_s %>'
141
-
142
- # There are various options here, by default Merb comes with 'cookie',
143
- # 'memory', 'memcache' or 'container'.
144
- # You can of course use your favorite ORM instead:
145
- # 'datamapper', 'sequel' or 'activerecord'.
146
- c[:session_store] = 'cookie'
14
+ # cookie session store configuration
15
+ c[:session_secret_key] = '<%= SHA1.new(rand(100000000000).to_s).to_s %>' # required for cookie session store
16
+ # c[:session_id_key] = '_session_id' # cookie session id key, defaults to "_session_id"
147
17
  end
148
-
149
-
150
- # ==== Tune your inflector
151
-
152
- # To fine tune your inflector use the word, singular_word and plural_word
153
- # methods of Extlib::Inflection module metaclass.
154
- #
155
- # Here we define erratum/errata exception case:
156
- #
157
- # Extlib::Inflection.word "erratum", "errata"
158
- #
159
- # In case singular and plural forms are the same omit
160
- # second argument on call:
161
- #
162
- # Extlib::Inflection.word 'information'
163
- #
164
- # You can also define general, singularization and pluralization
165
- # rules:
166
- #
167
- # Once the following rule is defined:
168
- # Extlib::Inflection.rule 'y', 'ies'
169
- #
170
- # You can see the following results:
171
- # irb> "fly".plural
172
- # => flies
173
- # irb> "cry".plural
174
- # => cries
175
- #
176
- # Example for singularization rule:
177
- #
178
- # Extlib::Inflection.singular_rule 'o', 'oes'
179
- #
180
- # Works like this:
181
- # irb> "heroes".singular
182
- # => hero
183
- #
184
- # Example of pluralization rule:
185
- # Extlib::Inflection.singular_rule 'fe', 'ves'
186
- #
187
- # And the result is:
188
- # irb> "wife".plural
189
- # => wives
18
+
19
+ Merb::BootLoader.before_app_loads do
20
+ # This will get executed after dependencies have been loaded but before your app's classes have loaded.
21
+ end
22
+
23
+ Merb::BootLoader.after_app_loads do
24
+ # This will get executed after your app's classes have been loaded.
25
+ end
@@ -1,122 +1,20 @@
1
- #
2
- # ==== Structure of Merb initializer
3
- #
4
- # 1. Load paths.
5
- # 2. Dependencies configuration.
6
- # 3. Libraries (ORM, testing tool, etc) you use.
7
- # 4. Application-specific configuration.
1
+ # Go to http://wiki.merbivore.com/pages/init-rb
8
2
 
9
- #
10
- # ==== Set up load paths
11
- #
12
-
13
- # Add the app's "gems" directory to the gem load path.
14
- # Note that the gems directory must mirror the structure RubyGems uses for
15
- # directories under which gems are kept.
16
- #
17
- # To conveniently set it up, use gem install -i <merb_app_root/gems>
18
- # when installing gems. This will set up the structure under /gems
19
- # automagically.
20
- #
21
- # An example:
22
- #
23
- # You want to bundle ActiveRecord and ActiveSupport with your Merb
24
- # application to be deployment environment independent. To do so,
25
- # install gems into merb_app_root/gems directory like this:
26
- #
27
- # gem install -i merb_app_root/gems activesupport-post-2.0.2.gem activerecord-post-2.0.2.gem
28
- #
29
- # Since RubyGems will search merb_app_root/gems for dependencies, order
30
- # in the statement above is important: we need to install ActiveSupport which
31
- # ActiveRecord depends on first.
32
- #
33
- # Remember that bundling of dependencies as gems with your application
34
- # makes it independent of the environment it runs in and is a very
35
- # good, encouraged practice to follow.
36
-
37
- # If you want modules and classes from libraries organized like
38
- # merbapp/lib/magicwand/lib/magicwand.rb to autoload,
39
- # uncomment this.
40
- # Merb.push_path(:lib, Merb.root / "lib") # uses **/*.rb as path glob.
41
-
42
- # ==== Dependencies
43
-
44
- # These are a few, but not all, of the standard merb-more dependencies:
45
- #
46
- # dependency "merb-action-args" # Provides support for querystring arguments to be passed in to controller actions
47
- # dependency "merb-assets" # Provides link_to, asset_path, auto_link, image_tag methods (and lots more)
48
- # dependency "merb-helpers" # Provides the form, date/time, and other helpers
49
- # dependency "merb-cache" # Provides your application with caching functions
50
- # dependency "merb-haml" # Adds rake tasks and the haml generators to your merb app
51
- # dependency "merb-jquery" # Provides a #jquery method to insert jQuery code in to a content block
52
- # dependency "merb-mailer" # Integrates mail support via Merb Mailer
53
-
54
- # These are a few, but not all, of the merb-plugin dependencies:
55
- #
56
- # dependency "merb_param_protection" # Lets you have better control over your query string params and param logging
57
- # dependency "merb_stories" # Provides rspec helper methods for your application
58
-
59
- # Miscellaneous dependencies:
60
- #
61
- # Specify more than one dependency at a time with the #dependencies method:
62
- # dependencies "RedCloth", "BlueCloth"
3
+ <%= "# " unless orm != :none %> use_orm :<%= orm %>
4
+ use_test :<%= testing_framework %>
5
+ use_template_engine :<%= template_engine %>
63
6
 
64
7
  # Specify a specific version of a dependency
65
8
  # dependency "RedCloth", "> 3.0"
66
9
 
67
- # Specify more than one dependency at a time as well as the version:
68
- # dependencies "RedCloth" => "> 3.0", "BlueCloth" => "= 1.0.0"
69
-
70
- # You can also add in dependencies after your application loads.
10
+ Merb::BootLoader.before_app_loads do
11
+ # This will get executed after dependencies have been loaded but before your app's classes have loaded.
12
+ end
13
+
71
14
  Merb::BootLoader.after_app_loads do
72
- # For example, the magic_admin gem uses the app's model classes. This requires that the models be
73
- # loaded already. So, we can put the magic_admin dependency here:
74
- # dependency "magic_admin"
15
+ # This will get executed after your app's classes have been loaded.
75
16
  end
76
17
 
77
- #
78
- # ==== Set up your ORM of choice
79
- #
80
-
81
- # Merb doesn't come with database support by default. You need
82
- # an ORM plugin. Install one, and uncomment one of the following lines,
83
- # if you need a database.
84
-
85
- # Uncomment for DataMapper ORM
86
- <%= "# " unless orm == :datamapper %>use_orm :datamapper
87
-
88
- # Uncomment for ActiveRecord ORM
89
- <%= "# " unless orm == :activerecord %>use_orm :activerecord
90
-
91
- # Uncomment for Sequel ORM
92
- <%= "# " unless orm == :sequel %>use_orm :sequel
93
-
94
-
95
- #
96
- # ==== Pick what you test with
97
- #
98
-
99
- # This defines which test framework the generators will use.
100
- # RSpec is turned on by default.
101
- #
102
- # To use Test::Unit, you need to install the merb_test_unit gem.
103
- # To use RSpec, you don't have to install any additional gems, since
104
- # merb-core provides support for RSpec.
105
- #
106
- <%= "# " unless testing_framework == :test_unit %>use_test :test_unit
107
- <%= "# " unless testing_framework == :rspec %>use_test :rspec
108
-
109
-
110
- #
111
- # ==== Choose which template engine to use by default
112
- #
113
-
114
- # Merb can generate views for different template engines, choose your favourite as the default.
115
-
116
- <%= "# " unless template_engine == :erb %>use_template_engine :erb
117
- <%= "# " unless template_engine == :haml %>use_template_engine :haml
118
-
119
-
120
18
  # Move this to application.rb if you want it to be reloadable in dev mode.
121
19
  Merb::Router.prepare do
122
20
  match('/').to(:controller => "<%= self.name.gsub("-", "_") %>", :action =>'index')
@@ -129,7 +27,7 @@ Merb::Config.use { |c|
129
27
  c[:framework] = {},
130
28
  c[:log_level] = :debug,
131
29
  c[:log_stream] = STDOUT,
132
- # or use file for loggine:
30
+ # or use file for logging:
133
31
  # c[:log_file] = Merb.root / "log" / "merb.log",
134
32
  c[:use_mutex] = false,
135
33
  c[:session_store] = 'cookie',
@@ -1,4 +1,4 @@
1
- Copyright (c) <%= Time.now.year %> Engine Yard
1
+ Copyright (c) <%= Time.now.year %> YOUR NAME
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- class Exceptions < Application
1
+ class Exceptions < Merb::Controller
2
2
 
3
3
  # handle NotFound exceptions (404)
4
4
  def not_found