merb-gen 1.0.15 → 1.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/Rakefile +59 -69
  2. data/bin/merb-gen +14 -2
  3. data/lib/generators/fcgi.rb +16 -0
  4. data/lib/generators/merb/merb_core.rb +14 -12
  5. data/lib/generators/merb/merb_flat.rb +11 -6
  6. data/lib/generators/merb/merb_stack.rb +14 -22
  7. data/lib/generators/merb/merb_very_flat.rb +32 -11
  8. data/lib/generators/passenger.rb +15 -0
  9. data/lib/generators/resource_controller.rb +1 -1
  10. data/lib/generators/templates/application/common/Gemfile +12 -0
  11. data/lib/generators/templates/application/common/Rakefile +10 -1
  12. data/lib/generators/templates/application/common/dotgitignore +3 -3
  13. data/lib/generators/templates/application/common/merb +20 -0
  14. data/lib/generators/templates/application/merb_core/autotest/merb_rspec.rb +9 -9
  15. data/lib/generators/templates/application/merb_core/config/init.rb +3 -5
  16. data/lib/generators/templates/application/merb_core/spec/spec.opts +1 -1
  17. data/lib/generators/templates/application/merb_core/spec/spec_helper.rb +9 -7
  18. data/lib/generators/templates/application/merb_core/test/test_helper.rb +9 -7
  19. data/lib/generators/templates/application/merb_flat/application.rbt +3 -0
  20. data/lib/generators/templates/application/merb_flat/config/init.rb +23 -19
  21. data/lib/generators/templates/application/merb_flat/spec/spec_helper.rb +8 -6
  22. data/lib/generators/templates/application/merb_flat/test/test_helper.rb +9 -7
  23. data/lib/generators/templates/application/merb_plugin/Rakefile +35 -4
  24. data/lib/generators/templates/application/merb_stack/Gemfile +48 -0
  25. data/lib/generators/templates/application/merb_stack/autotest/merb_rspec.rb +7 -7
  26. data/lib/generators/templates/application/merb_stack/config/init.rb +2 -2
  27. data/lib/generators/templates/application/merb_stack/config.ru +23 -0
  28. data/lib/generators/templates/application/merb_stack/spec/spec.opts +1 -1
  29. data/lib/generators/templates/application/merb_stack/spec/spec_helper.rb +9 -7
  30. data/lib/generators/templates/application/merb_stack/test/test_helper.rb +9 -7
  31. data/lib/generators/templates/application/merb_very_flat/application.rbt +1 -8
  32. data/lib/generators/templates/application/merb_very_flat/spec/spec_helper.rb +8 -6
  33. data/lib/generators/templates/application/merb_very_flat/test/test_helper.rb +9 -7
  34. data/lib/generators/templates/{application/common → component/fcgi}/dothtaccess +1 -2
  35. data/lib/generators/templates/{application/merb_stack/public → component/fcgi}/merb.fcgi +10 -4
  36. data/lib/generators/templates/component/model/spec/models/%file_name%_spec.rb +1 -1
  37. data/lib/merb-gen/app_generator.rb +58 -0
  38. data/lib/merb-gen/generator.rb +1 -1
  39. data/lib/merb-gen/version.rb +17 -0
  40. data/lib/merb-gen.rb +27 -25
  41. data/spec/controller_spec.rb +1 -1
  42. data/spec/fcgi_spec.rb +24 -0
  43. data/spec/generator_spec.rb +1 -1
  44. data/spec/layout_spec.rb +1 -1
  45. data/spec/merb_core_spec.rb +17 -5
  46. data/spec/merb_flat_spec.rb +10 -1
  47. data/spec/merb_plugin_spec.rb +3 -3
  48. data/spec/merb_stack_spec.rb +23 -10
  49. data/spec/merb_very_flat_spec.rb +13 -2
  50. data/spec/migration_spec.rb +1 -1
  51. data/spec/model_spec.rb +1 -1
  52. data/spec/named_generator_spec.rb +1 -1
  53. data/spec/namespaced_generator_spec.rb +1 -1
  54. data/spec/part_controller_spec.rb +1 -1
  55. data/spec/passenger_spec.rb +20 -0
  56. data/spec/resource_controller_spec.rb +1 -1
  57. data/spec/resource_spec.rb +1 -1
  58. data/spec/session_migration_spec.rb +1 -1
  59. data/spec/spec.opts +2 -0
  60. data/spec/spec_helper.rb +53 -4
  61. metadata +78 -45
  62. data/lib/generators/templates/application/common/doc.thor +0 -149
  63. data/lib/generators/templates/application/common/merb_thor/app_script.rb +0 -31
  64. data/lib/generators/templates/application/common/merb_thor/common.rb +0 -68
  65. data/lib/generators/templates/application/common/merb_thor/gem_ext.rb +0 -125
  66. data/lib/generators/templates/application/common/merb_thor/main.thor +0 -151
  67. data/lib/generators/templates/application/common/merb_thor/ops.rb +0 -93
  68. data/lib/generators/templates/application/common/merb_thor/utils.rb +0 -40
  69. data/lib/generators/templates/application/merb_core/public/merb.fcgi +0 -22
  70. data/lib/generators/templates/application/merb_stack/config/dependencies.rb +0 -34
  71. data/lib/generators/thor.rb +0 -33
@@ -1,15 +1,10 @@
1
1
  # Go to http://wiki.merbivore.com/pages/init-rb
2
2
 
3
- <%= "# " unless orm != :none %> use_orm :<%= orm %>
3
+ <%= "use_orm :#{orm}" unless orm == :none %>
4
4
  use_test :<%= testing_framework %>
5
5
  use_template_engine :<%= template_engine %>
6
6
 
7
- # If you need to use dependency immediately in this file you must add :immediate => true
8
- # to dependency definition:
9
- # dependency "merb-slices", :immediate => true
10
- #
11
- # Specify a specific version of a dependency
12
- # dependency "RedCloth", "> 3.0"
7
+ # Specify your dependencies in the Gemfile
13
8
 
14
9
  Merb::BootLoader.before_app_loads do
15
10
  # This will get executed after dependencies have been loaded but before your app's classes have loaded.
@@ -29,16 +24,25 @@ end
29
24
  Merb::Config.use { |c|
30
25
  c[:environment] = 'production',
31
26
  c[:framework] = {},
32
- c[:log_level] = :debug,
33
- c[:log_stream] = STDOUT,
34
- # or use file for logging:
35
- # c[:log_file] = Merb.root / "log" / "merb.log",
36
- c[:use_mutex] = false,
37
- c[:session_store] = 'cookie',
38
- c[:session_id_key] = '_<%= base_name %>_session_id',
39
- c[:session_secret_key] = '<%= Digest::SHA1.hexdigest(rand(100000000000).to_s).to_s %>',
40
- c[:exception_details] = true,
41
- c[:reload_classes] = true,
42
- c[:reload_templates] = true,
43
- c[:reload_time] = 0.5
27
+ c[:use_mutex] = false
28
+ c[:session_store] = 'cookie'
29
+ c[:session_id_key] = '_<%= base_name %>_session_id'
30
+ c[:session_secret_key] = '<%= Digest::SHA1.hexdigest(rand(100000000000).to_s).to_s %>'
31
+
32
+ if Merb.env?(:production)
33
+ # edit production settings
34
+ c[:log_level] = :error
35
+ c[:log_file] = Merb.root / "log" / "production.log"
36
+ c[:exception_details] = false
37
+ c[:reload_classes] = false
38
+ c[:reload_templates] = false
39
+ else
40
+ # edit development/test settings
41
+ c[:log_level] = :debug
42
+ c[:log_stream] = STDOUT
43
+ c[:exception_details] = true
44
+ c[:reload_classes] = true
45
+ c[:reload_templates] = true
46
+ c[:reload_time] = 0.5
47
+ end
44
48
  }
@@ -1,9 +1,11 @@
1
- require "rubygems"
2
-
3
- # Add the local gems dir if found within the app root; any dependencies loaded
4
- # hereafter will try to load from the local gems before loading system gems.
5
- if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
6
- $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require File.expand_path('../.bundle/environment', __FILE__)
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
7
9
  end
8
10
 
9
11
  require "spec"
@@ -1,9 +1,11 @@
1
- require "rubygems"
2
-
3
- # Add the local gems dir if found within the app root; any dependencies loaded
4
- # hereafter will try to load from the local gems before loading system gems.
5
- if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
6
- $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require File.expand_path('../.bundle/environment', __FILE__)
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
7
9
  end
8
10
 
9
11
  require "merb-core"
@@ -16,4 +18,4 @@ Merb.start :environment => (ENV['MERB_ENV'] || 'test'),
16
18
  class Test::Unit::TestCase
17
19
  include Merb::Test::RequestHelper
18
20
  # Add more helper methods to be used by all tests here...
19
- end
21
+ end
@@ -1,4 +1,12 @@
1
- require 'rubygems'
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require '.bundle/environment'
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
9
+ end
2
10
  require 'rake/gempackagetask'
3
11
 
4
12
  require 'merb-core'
@@ -17,13 +25,13 @@ spec = Gem::Specification.new do |s|
17
25
  s.version = GEM_VERSION
18
26
  s.platform = Gem::Platform::RUBY
19
27
  s.has_rdoc = true
20
- s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
28
+ s.extra_rdoc_files = ["README", "LICENSE", "TODO"]
21
29
  s.summary = SUMMARY
22
30
  s.description = s.summary
23
31
  s.author = AUTHOR
24
32
  s.email = EMAIL
25
33
  s.homepage = HOMEPAGE
26
- s.add_dependency('merb', '>= <%= Merb::VERSION %>')
34
+ s.add_dependency('merb-core', '>= <%= Merb::VERSION %>')
27
35
  s.require_path = 'lib'
28
36
  s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec<%= bin ? ',bin' : '' %>}/**/*")
29
37
  <% if bin %>
@@ -51,4 +59,27 @@ task :gemspec do
51
59
  File.open("#{GEM_NAME}.gemspec", "w") do |file|
52
60
  file.puts spec.to_ruby
53
61
  end
54
- end
62
+ end
63
+
64
+ begin
65
+ require 'spec'
66
+ require 'spec/rake/spectask'
67
+
68
+ task :default => [ :spec ]
69
+
70
+ desc 'Run specifications'
71
+ Spec::Rake::SpecTask.new(:spec) do |t|
72
+ t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
73
+ t.spec_opts << '--color' << '--format' << 'specdoc'
74
+ begin
75
+ require 'rcov'
76
+ t.rcov_opts << '--exclude' << 'spec'
77
+ t.rcov_opts << '--text-summary'
78
+ t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
79
+ rescue LoadError
80
+ # rcov not installed
81
+ end
82
+ end
83
+ rescue LoadError
84
+ # rspec not installed
85
+ end
@@ -0,0 +1,48 @@
1
+ # Dependencies are generated using a strict version,
2
+ # Don't forget to edit the dependency versions when upgrading.
3
+
4
+ merb_gems_version = "<%= merb_gems_version %>"
5
+ dm_gems_version = "<%= dm_gems_version %>"
6
+ do_gems_version = "<%= do_gems_version %>"
7
+
8
+ # If you did disable json for Merb, comment out this line.
9
+ # Don't use json gem version lower than 1.1.7! Older version have a security bug
10
+
11
+ gem "json_pure", ">= 1.1.7", :require => "json"
12
+
13
+ # For more information about each component,
14
+ # please read http://wiki.merbivore.com/faqs/merb_components
15
+
16
+ gem "merb-core", merb_gems_version
17
+ gem "merb-action-args", merb_gems_version
18
+ gem "merb-assets", merb_gems_version
19
+ gem "merb-helpers", merb_gems_version
20
+ gem "merb-mailer", merb_gems_version
21
+ gem "merb-slices", merb_gems_version
22
+ gem "merb-auth-core", merb_gems_version
23
+ gem "merb-auth-more", merb_gems_version
24
+ gem "merb-auth-slice-password", merb_gems_version
25
+ gem "merb-param-protection", merb_gems_version
26
+ gem "merb-exceptions", merb_gems_version
27
+ gem "merb-gen", merb_gems_version
28
+
29
+ gem("merb-cache", merb_gems_version) do
30
+ Merb::Cache.setup do
31
+ register(Merb::Cache::FileStore) unless Merb.cache
32
+ end
33
+ end
34
+
35
+ gem "data_objects", do_gems_version
36
+ gem "do_sqlite3", do_gems_version # If using another database, replace this
37
+ gem "dm-core", dm_gems_version
38
+ gem "dm-aggregates", dm_gems_version
39
+ gem "dm-migrations", dm_gems_version
40
+ gem "dm-timestamps", dm_gems_version
41
+ gem "dm-types", dm_gems_version
42
+ gem "dm-validations", dm_gems_version
43
+ gem "dm-serializer", dm_gems_version
44
+ gem "dm-constraints", dm_gems_version
45
+
46
+ gem "merb_datamapper", merb_gems_version
47
+ <%= gems_for_template_engine(template_engine) %>
48
+ <%= gems_for_testing_framework(testing_framework) %>
@@ -54,7 +54,7 @@ class Autotest::MerbRspec < Autotest
54
54
 
55
55
  # Changes to a view cause its spec to be run
56
56
  add_mapping %r%^app/views/(.*)/% do |_, m|
57
- spec_for(m[1], 'view')
57
+ spec_for(m[1], 'request')
58
58
  end
59
59
 
60
60
  # Changes to a controller result in its corresponding spec being run. If
@@ -62,15 +62,15 @@ class Autotest::MerbRspec < Autotest
62
62
  # controller specs are run.
63
63
  add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
64
64
  if ["application", "exception"].include?(m[1])
65
- files_matching %r%^spec/controllers/.*_spec\.rb$%
65
+ files_matching %r%^spec/requests/.*_spec\.rb$%
66
66
  else
67
- spec_for(m[1], 'controller')
67
+ spec_for(m[1], 'request')
68
68
  end
69
69
  end
70
70
 
71
71
  # If a change is made to the router, run controller, view and helper specs
72
72
  add_mapping %r%^config/router.rb$% do
73
- files_matching %r%^spec/(controllers|views|helpers)/.*_spec\.rb$%
73
+ files_matching %r%^spec/(views|controllers|helpers|requests)/.*_spec\.rb$%
74
74
  end
75
75
 
76
76
  # If any of the major files governing the environment are altered, run
@@ -157,9 +157,9 @@ private
157
157
  # String
158
158
  #
159
159
  # ==== Example
160
- # > spec_for('post', :view')
161
- # => "spec/views/post_spec.rb"
160
+ # > spec_for('post', :model')
161
+ # => "spec/models/post_spec.rb"
162
162
  def spec_for(match, kind)
163
- File.join("spec", kind + 's', "#{match}_spec.rb")
163
+ files_matching %r%^spec/#{kind}s/#{match}(/.*)?_spec.rb$%
164
164
  end
165
165
  end
@@ -1,7 +1,7 @@
1
1
  # Go to http://wiki.merbivore.com/pages/init-rb
2
2
 
3
- require 'config/dependencies.rb'
4
-
3
+ # Specify your dependencies in the Gemfile
4
+
5
5
  use_orm :datamapper
6
6
  use_test :<%= testing_framework %>
7
7
  use_template_engine :<%= template_engine %>
@@ -0,0 +1,23 @@
1
+ begin
2
+ # Try to require the preresolved locked set of gems.
3
+ require File.expand_path('../.bundle/environment', __FILE__)
4
+ rescue LoadError
5
+ # Fall back on doing an unlocked resolve at runtime.
6
+ require "rubygems"
7
+ require "bundler"
8
+ Bundler.setup
9
+ end
10
+
11
+ require 'merb-core'
12
+
13
+ Merb::Config.setup(
14
+ :merb_root => File.expand_path(File.dirname(__FILE__)),
15
+ :environment => ENV['RACK_ENV']
16
+ )
17
+
18
+ Merb.environment = Merb::Config[:environment]
19
+ Merb.root = Merb::Config[:merb_root]
20
+
21
+ Merb::BootLoader.run
22
+
23
+ run Merb::Rack::Application.new
@@ -1,2 +1,2 @@
1
1
  --format specdoc
2
- --colour
2
+ --colour
@@ -1,13 +1,15 @@
1
- require "rubygems"
2
-
3
- # Add the local gems dir if found within the app root; any dependencies loaded
4
- # hereafter will try to load from the local gems before loading system gems.
5
- if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
6
- $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require File.expand_path('../.bundle/environment', __FILE__)
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
7
9
  end
8
10
 
9
- require "merb-core"
10
11
  require "spec" # Satisfies Autotest and anyone else not using the Rake tasks
12
+ require "merb-core"
11
13
 
12
14
  # this loads all plugins required in your init file so don't add them
13
15
  # here again, Merb will do it for you
@@ -1,9 +1,11 @@
1
- require "rubygems"
2
-
3
- # Add the local gems dir if found within the app root; any dependencies loaded
4
- # hereafter will try to load from the local gems before loading system gems.
5
- if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
6
- $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require File.expand_path('../.bundle/environment', __FILE__)
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
7
9
  end
8
10
 
9
11
  require "merb-core"
@@ -16,4 +18,4 @@ Merb.start :environment => (ENV['MERB_ENV'] || 'test'),
16
18
  class Test::Unit::TestCase
17
19
  include Merb::Test::RequestHelper
18
20
  # Add more helper methods to be used by all tests here...
19
- end
21
+ end
@@ -33,13 +33,6 @@
33
33
  <%= "# " unless template_engine == :erb %>use_template_engine :erb
34
34
  <%= "# " unless template_engine == :haml %>use_template_engine :haml
35
35
 
36
- # If you need to use dependency immediately in this file you must add :immediate => true
37
- # to dependency definition:
38
- # dependency "merb-slices", :immediate => true
39
- #
40
- # Specify a specific version of a dependency
41
- # dependency "RedCloth", "> 3.0"
42
-
43
36
  Merb::Config.use { |c|
44
37
  c[:framework] = { :public => [Merb.root / "public", nil] }
45
38
  c[:session_store] = 'none'
@@ -63,4 +56,4 @@ class <%= class_name %> < Merb::Controller
63
56
  def index
64
57
  "Hi, I am 'very flat' Merb application. I have everything in one single file and well suited for dynamic stub pages."
65
58
  end
66
- end
59
+ end
@@ -1,9 +1,11 @@
1
- require "rubygems"
2
-
3
- # Add the local gems dir if found within the app root; any dependencies loaded
4
- # hereafter will try to load from the local gems before loading system gems.
5
- if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
6
- $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require File.expand_path('../.bundle/environment', __FILE__)
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
7
9
  end
8
10
 
9
11
  require "spec"
@@ -1,9 +1,11 @@
1
- require "rubygems"
2
-
3
- # Add the local gems dir if found within the app root; any dependencies loaded
4
- # hereafter will try to load from the local gems before loading system gems.
5
- if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
6
- $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require File.expand_path('../.bundle/environment', __FILE__)
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
7
9
  end
8
10
 
9
11
  require "merb-core"
@@ -16,4 +18,4 @@ Merb.start :environment => (ENV['MERB_ENV'] || 'test'),
16
18
  class Test::Unit::TestCase
17
19
  include Merb::Test::RequestHelper
18
20
  # Add more helper methods to be used by all tests here...
19
- end
21
+ end
@@ -13,5 +13,4 @@ RewriteRule ^([^.]+)$ $1.html [QSA]
13
13
  RewriteCond %{REQUEST_FILENAME} !-f
14
14
  RewriteRule ^(.*)$ merb.fcgi [QSA,L]
15
15
 
16
-
17
- ErrorDocument 500 "<h2>Application Error</h2>Merb could not be reached"
16
+ ErrorDocument 500 "<h2>Application Error</h2>Merb could not be reached"
@@ -1,11 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
2
+ begin
3
+ # Load the bundler environment from #{Merb.root}/gems/environment.rb
4
+ require File.join(File.dirname(__FILE__), "..", "gems", "environment")
5
+ rescue LoadError
6
+ # Default to using system rubygems if there's no bundle detected
7
+ require "rubygems"
8
+ end
9
+
4
10
  require 'merb-core'
5
11
 
6
12
  # this is Merb.root, change this if you have some funky setup.
7
13
  merb_root = File.expand_path(File.dirname(__FILE__) / '../')
8
-
14
+
9
15
  # If the fcgi process runs as apache, make sure
10
16
  # we have an inlinedir set for Rubyinline action-args to work
11
17
  unless ENV["INLINEDIR"] || ENV["HOME"]
@@ -19,4 +25,4 @@ end
19
25
  # start merb with the fcgi adapter, add options or change the log dir here
20
26
  Merb.start(:adapter => 'fcgi',
21
27
  :merb_root => merb_root,
22
- :log_file => merb_root /'log'/'merb.log')
28
+ :log_file => merb_root / 'log' / 'merb.log')
@@ -1,6 +1,6 @@
1
1
  require File.join( File.dirname(__FILE__), <%= go_up(modules.size + 1) %>, "spec_helper" )
2
2
 
3
- describe <%= class_name %> do
3
+ describe <%= full_class_name %> do
4
4
 
5
5
  it "should have specs"
6
6
 
@@ -8,6 +8,64 @@ module Merb
8
8
  super
9
9
  end
10
10
 
11
+ # Helper to get Merb version
12
+ #
13
+ # ==== Returns
14
+ # String:: Merb version
15
+ def merb_gems_version
16
+ Merb::VERSION
17
+ end
18
+
19
+ # ORM gem dependencies
20
+ #
21
+ # Adds ORM plugin dependency 'merb_#{orm}' if we use any ORM.
22
+ #
23
+ # ==== Params
24
+ # orm<Symbol>:: ORM to use
25
+ #
26
+ # ==== Returns
27
+ # String:: Gem dependencies
28
+ def gems_for_orm(orm)
29
+ orm.to_sym == :none ? '' : %Q{gem "merb_#{orm}"}
30
+ end
31
+
32
+ # Template enging gem dependencies
33
+ #
34
+ # When using something else than erb we add merb plugin
35
+ # dependency for the template engine.
36
+ #
37
+ # ==== Params
38
+ # template_engine<Symbol>:: Template engine to use
39
+ #
40
+ # ==== Returns
41
+ # String:: Gem dependencies
42
+ def gems_for_template_engine(template_engine)
43
+ gems = ''
44
+ if template_engine != :erb
45
+ if template_engine.in?(:haml, :builder)
46
+ template_engine_plugin = "merb-#{template_engine}"
47
+ else
48
+ template_engine_plugin = "merb_#{template_engine}"
49
+ end
50
+ gems = %Q{gem "#{template_engine_plugin}"}
51
+ end
52
+ gems
53
+ end
54
+
55
+ # Testing framework gem dependencies
56
+ #
57
+ # If we use any other test framework than RSpec we must add dependency
58
+ # to the Gemfile. Merb depends on the RSpec so it's default dependency.
59
+ #
60
+ # ==== Params
61
+ # test_framework<Symbol>:: Testing framework to use
62
+ #
63
+ # ==== Returns
64
+ # String:: Gem dependencies
65
+ def gems_for_testing_framework(testing_framework)
66
+ testing_framework == :rspec ? '' : %Q{gem "#{testing_framework}", :group => :test}
67
+ end
68
+
11
69
  end
12
70
  end
13
71
  end
@@ -58,7 +58,7 @@ module Merb
58
58
  modules.each_with_index do |mod, i|
59
59
  concat((" " * (indent + i)) + "module #{mod}\n", block.binding)
60
60
  end
61
- text = text.to_a.map{ |line| (" " * modules.size) + line }.join
61
+ text = Array(text).map{ |line| (" " * modules.size) + line }.join
62
62
  concat(text, block.binding)
63
63
  modules.reverse.each_with_index do |mod, i|
64
64
  concat((" " * (indent + modules.size - i - 1)) + "end # #{mod}\n", block.binding)
@@ -0,0 +1,17 @@
1
+ module Merb
2
+ module Generators
3
+
4
+ VERSION = '1.1.0.pre'.freeze
5
+
6
+ # Duplicated here (originally in merb_datamapper)
7
+ # This is currently the easiest way to get at the
8
+ # datamapper version requirements, and still seems
9
+ # better than specifying the datamapper version in
10
+ # merb-core itself.
11
+ DM_VERSION_REQUIREMENT = '~> 0.10'.freeze
12
+
13
+ # Necessary to supply builtin support for do_sqlite3
14
+ DO_VERSION_REQUIREMENT = '~> 0.10'.freeze
15
+
16
+ end
17
+ end
data/lib/merb-gen.rb CHANGED
@@ -1,34 +1,36 @@
1
- require 'rubygems'
2
1
  require 'merb-core'
2
+
3
3
  require 'digest/sha1'
4
- gem 'templater', '>= 0.3.2'
5
4
  require 'templater'
6
5
 
7
- path = File.join(File.dirname(__FILE__))
6
+ require 'merb-gen/templater'
7
+ require 'merb-gen/generator'
8
+ require 'merb-gen/named_generator'
9
+ require 'merb-gen/namespaced_generator'
10
+ require 'merb-gen/app_generator'
11
+
12
+ # TODO Look at how templater handles generators that don't reside
13
+ # in the toplevel rubygems 'namespace'
8
14
 
9
- require path / "merb-gen" / "templater"
10
- require path / "merb-gen" / "generator"
11
- require path / "merb-gen" / "named_generator"
12
- require path / "merb-gen" / "namespaced_generator"
13
- require path / "merb-gen" / "app_generator"
14
- require path / "generators" / "merb" / "merb_stack"
15
- require path / "generators" / "merb" / "merb_core"
16
- require path / "generators" / "merb" / "merb_flat"
17
- require path / "generators" / "merb" / "merb_very_flat"
18
- require path / "generators" / "merb_plugin"
19
- require path / "generators" / "controller"
20
- require path / "generators" / "helper"
21
- require path / "generators" / "part_controller"
22
- require path / "generators" / "migration"
23
- require path / "generators" / "session_migration"
24
- require path / "generators" / "model"
25
- require path / "generators" / "resource_controller"
26
- require path / "generators" / "resource"
27
- require path / "generators" / "layout"
28
- require path / "generators" / "thor"
15
+ require File.expand_path('../generators/merb/merb_stack', __FILE__)
16
+ require File.expand_path('../generators/merb/merb_core', __FILE__)
17
+ require File.expand_path('../generators/merb/merb_flat', __FILE__)
18
+ require File.expand_path('../generators/merb/merb_very_flat', __FILE__)
19
+ require File.expand_path('../generators/merb_plugin', __FILE__)
20
+ require File.expand_path('../generators/controller', __FILE__)
21
+ require File.expand_path('../generators/helper', __FILE__)
22
+ require File.expand_path('../generators/part_controller', __FILE__)
23
+ require File.expand_path('../generators/migration', __FILE__)
24
+ require File.expand_path('../generators/session_migration', __FILE__)
25
+ require File.expand_path('../generators/model', __FILE__)
26
+ require File.expand_path('../generators/resource_controller', __FILE__)
27
+ require File.expand_path('../generators/resource', __FILE__)
28
+ require File.expand_path('../generators/layout', __FILE__)
29
+ require File.expand_path('../generators/passenger', __FILE__)
30
+ require File.expand_path('../generators/fcgi', __FILE__)
29
31
 
30
- Templater::Discovery.discover!("merb-gen")
32
+ Templater::Discovery.discover!('merb-gen')
31
33
 
32
34
  Merb.generators.each do |file|
33
35
  require file
34
- end
36
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Merb::Generators::ControllerGenerator do
4
4
 
data/spec/fcgi_spec.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Merb::Generators::FcgiGenerator do
4
+
5
+ describe "templates" do
6
+ before(:each) do
7
+ @generator = Merb::Generators::FcgiGenerator.new('/tmp', {})
8
+ end
9
+
10
+ it "should create a .htaccess file within public/" do
11
+ @generator.should create('/tmp/public/.htaccess')
12
+ end
13
+
14
+ it "should create a merb.fcgi file within public/" do
15
+ @generator.should create('/tmp/public/.htaccess')
16
+ end
17
+
18
+ it "should render templates successfully" do
19
+ lambda { @generator.render! }.should_not raise_error
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Merb::Generators::Generator do
4
4
 
data/spec/layout_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Merb::Generators::LayoutGenerator do
4
4