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.
Files changed (116) hide show
  1. data/README +6 -3
  2. data/Rakefile +6 -4
  3. data/bin/merb-gen +1 -23
  4. data/lib/generators/controller.rb +4 -2
  5. data/lib/generators/helper.rb +0 -5
  6. data/lib/generators/merb/merb_core.rb +95 -0
  7. data/lib/generators/merb/merb_flat.rb +70 -69
  8. data/lib/generators/merb/merb_stack.rb +110 -0
  9. data/lib/generators/merb/merb_very_flat.rb +61 -64
  10. data/lib/generators/merb_plugin.rb +5 -0
  11. data/lib/generators/model.rb +5 -2
  12. data/lib/generators/resource.rb +7 -2
  13. data/lib/generators/resource_controller.rb +4 -4
  14. data/lib/generators/templates/application/common/Rakefile +2 -6
  15. data/lib/generators/templates/application/common/doc.thor +149 -0
  16. data/lib/generators/templates/application/common/dothtaccess +17 -0
  17. data/lib/generators/templates/application/common/jquery.js +32 -0
  18. data/lib/generators/templates/application/common/merb.thor +1550 -861
  19. data/lib/generators/templates/application/{merb → merb_core}/app/controllers/application.rb +0 -0
  20. data/lib/generators/templates/application/{merb → merb_core}/app/controllers/exceptions.rb +0 -0
  21. data/lib/generators/templates/application/{merb → merb_core}/app/helpers/global_helpers.rb +0 -0
  22. data/lib/generators/templates/application/{merb → merb_core}/app/views/exceptions/internal_server_error.html.erb +0 -0
  23. data/lib/generators/templates/application/{merb → merb_core}/app/views/exceptions/not_acceptable.html.erb +0 -0
  24. data/lib/generators/templates/application/{merb → merb_core}/app/views/exceptions/not_found.html.erb +0 -0
  25. data/lib/generators/templates/application/{merb → merb_core}/autotest/discover.rb +0 -0
  26. data/lib/generators/templates/application/{merb → merb_core}/autotest/merb.rb +0 -0
  27. data/lib/generators/templates/application/{merb → merb_core}/autotest/merb_rspec.rb +0 -0
  28. data/lib/generators/templates/application/{merb → merb_core}/config/environments/development.rb +7 -2
  29. data/lib/generators/templates/application/{merb → merb_core}/config/environments/production.rb +5 -2
  30. data/lib/generators/templates/application/{merb → merb_core}/config/environments/rake.rb +6 -2
  31. data/lib/generators/templates/application/merb_core/config/environments/staging.rb +10 -0
  32. data/lib/generators/templates/application/merb_core/config/environments/test.rb +12 -0
  33. data/lib/generators/templates/application/{merb → merb_core}/config/init.rb +6 -6
  34. data/lib/generators/templates/application/{merb → merb_core}/config/rack.rb +0 -0
  35. data/lib/generators/templates/application/{merb → merb_core}/config/router.rb +0 -0
  36. data/lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb +1362 -0
  37. data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/api_grease.js +640 -0
  38. data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/index.html.erb +37 -0
  39. data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/merb.css +252 -0
  40. data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/merb.rb +351 -0
  41. data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
  42. data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/prototype.js +2515 -0
  43. data/lib/generators/templates/application/{merb/app/models → merb_core/lib}/merb/session.rb +0 -0
  44. data/lib/generators/templates/application/{merb → merb_core}/public/favicon.ico +0 -0
  45. data/lib/generators/templates/application/{merb → merb_core}/public/images/merb.jpg +0 -0
  46. data/lib/generators/templates/application/merb_core/public/javascripts/application.js +1 -0
  47. data/lib/generators/templates/application/{merb → merb_core}/public/merb.fcgi +0 -0
  48. data/lib/generators/templates/application/{merb → merb_core}/public/robots.txt +0 -0
  49. data/lib/generators/templates/application/{merb → merb_core}/public/stylesheets/master.css +0 -0
  50. data/lib/generators/templates/application/{merb → merb_core}/spec/spec.opts +0 -0
  51. data/lib/generators/templates/application/{merb → merb_core}/spec/spec_helper.rb +0 -0
  52. data/lib/generators/templates/application/{merb → merb_core}/test/test_helper.rb +0 -0
  53. data/lib/generators/templates/application/merb_flat/application.rbt +1 -1
  54. data/lib/generators/templates/application/merb_flat/config/init.rb +8 -3
  55. data/lib/generators/templates/application/merb_plugin/LICENSE +1 -1
  56. data/lib/generators/templates/application/merb_stack/app/controllers/application.rb +2 -0
  57. data/lib/generators/templates/application/merb_stack/app/controllers/exceptions.rb +13 -0
  58. data/lib/generators/templates/application/merb_stack/app/helpers/global_helpers.rb +5 -0
  59. data/lib/generators/templates/application/merb_stack/app/models/user.rb +17 -0
  60. data/lib/generators/templates/application/merb_stack/app/views/exceptions/internal_server_error.html.erb +216 -0
  61. data/lib/generators/templates/application/merb_stack/app/views/exceptions/not_acceptable.html.erb +63 -0
  62. data/lib/generators/templates/application/merb_stack/app/views/exceptions/not_found.html.erb +47 -0
  63. data/lib/generators/templates/application/merb_stack/autotest/discover.rb +1 -0
  64. data/lib/generators/templates/application/merb_stack/autotest/merb.rb +149 -0
  65. data/lib/generators/templates/application/merb_stack/autotest/merb_rspec.rb +165 -0
  66. data/lib/generators/templates/application/merb_stack/config/database.yml +33 -0
  67. data/lib/generators/templates/application/merb_stack/config/dependencies.rb +15 -0
  68. data/lib/generators/templates/application/merb_stack/config/environments/development.rb +15 -0
  69. data/lib/generators/templates/application/merb_stack/config/environments/production.rb +10 -0
  70. data/lib/generators/templates/application/merb_stack/config/environments/rake.rb +11 -0
  71. data/lib/generators/templates/application/merb_stack/config/environments/staging.rb +10 -0
  72. data/lib/generators/templates/application/merb_stack/config/environments/test.rb +12 -0
  73. data/lib/generators/templates/application/merb_stack/config/init.rb +24 -0
  74. data/lib/generators/templates/application/merb_stack/config/rack.rb +12 -0
  75. data/lib/generators/templates/application/merb_stack/config/router.rb +44 -0
  76. data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb +1362 -0
  77. data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/api_grease.js +640 -0
  78. data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/index.html.erb +37 -0
  79. data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/merb.css +252 -0
  80. data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/merb.rb +351 -0
  81. data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
  82. data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/prototype.js +2515 -0
  83. data/lib/generators/templates/application/merb_stack/merb/merb-auth/setup.rb +44 -0
  84. data/lib/generators/templates/application/merb_stack/merb/merb-auth/strategies.rb +11 -0
  85. data/lib/generators/templates/application/merb_stack/merb/session/session.rb +9 -0
  86. data/lib/generators/templates/application/merb_stack/public/favicon.ico +0 -0
  87. data/lib/generators/templates/application/merb_stack/public/images/merb.jpg +0 -0
  88. data/lib/generators/templates/application/merb_stack/public/javascripts/application.js +1 -0
  89. data/lib/generators/templates/application/merb_stack/public/merb.fcgi +22 -0
  90. data/lib/generators/templates/application/merb_stack/public/robots.txt +5 -0
  91. data/lib/generators/templates/application/merb_stack/public/stylesheets/master.css +119 -0
  92. data/lib/generators/templates/application/merb_stack/spec/spec.opts +0 -0
  93. data/lib/generators/templates/application/merb_stack/spec/spec_helper.rb +20 -0
  94. data/lib/generators/templates/application/merb_stack/test/test_helper.rb +19 -0
  95. data/lib/generators/templates/application/merb_very_flat/application.rbt +11 -5
  96. data/lib/generators/templates/component/layout/app/views/layout/%file_name%.html.erb +1 -0
  97. data/lib/generators/templates/component/resource_controller/spec/requests/%file_name%_spec.rb +53 -0
  98. data/lib/merb-gen/app_generator.rb +13 -0
  99. data/lib/merb-gen/generator.rb +36 -1
  100. data/lib/merb-gen/named_generator.rb +5 -2
  101. data/lib/merb-gen.rb +6 -8
  102. data/spec/controller_spec.rb +0 -20
  103. data/spec/{merb_full_spec.rb → merb_core_spec.rb} +11 -3
  104. data/spec/merb_stack_spec.rb +47 -0
  105. data/spec/part_controller_spec.rb +0 -39
  106. data/spec/resource_controller_spec.rb +1 -35
  107. data/spec/spec_helper.rb +4 -2
  108. metadata +133 -111
  109. data/lib/generators/merb/merb_full.rb +0 -85
  110. data/lib/generators/merb.rb +0 -24
  111. data/lib/generators/templates/application/merb/config/environments/staging.rb +0 -7
  112. data/lib/generators/templates/application/merb/config/environments/test.rb +0 -7
  113. data/lib/generators/templates/component/helper/spec/helpers/%file_name%_helper_spec.rb +0 -5
  114. data/lib/generators/templates/component/resource_controller/spec/controllers/%file_name%_spec.rb +0 -7
  115. data/spec/helper_spec.rb +0 -43
  116. data/spec/merb_spec.rb +0 -20
@@ -0,0 +1,44 @@
1
+ # This file is specifically setup for use with the merb-auth plugin.
2
+ # This file should be used to setup and configure your authentication stack.
3
+ # It is not required and may safely be deleted.
4
+ #
5
+ # To change the parameter names for the password or login field you may set either of these two options
6
+ #
7
+ # Merb::Plugins.config[:"merb-auth"][:login_param] = :email
8
+ # Merb::Plugins.config[:"merb-auth"][:password_param] = :my_password_field_name
9
+
10
+ begin
11
+ # Sets the default class ofr authentication. This is primarily used for
12
+ # Plugins and the default strategies
13
+ Merb::Authentication.user_class = User
14
+
15
+
16
+ # Mixin the salted user mixin
17
+ require 'merb-auth-more/mixins/salted_user'
18
+ Merb::Authentication.user_class.class_eval{ include Merb::Authentication::Mixins::SaltedUser }
19
+
20
+ # Setup the session serialization
21
+ class Merb::Authentication
22
+
23
+ def fetch_user(session_user_id)
24
+ Merb::Authentication.user_class.get(session_user_id)
25
+ end
26
+
27
+ def store_user(user)
28
+ user.nil? ? user : user.id
29
+ end
30
+ end
31
+
32
+ rescue
33
+ Merb.logger.error <<-TEXT
34
+
35
+ You need to setup some kind of user class with merb-auth.
36
+ Merb::Authentication.user_class = User
37
+
38
+ If you want to fully customize your authentication you should use merb-core directly.
39
+
40
+ See lib/authentication/setup.rb and strategies.rb to customize your setup
41
+
42
+ TEXT
43
+ end
44
+
@@ -0,0 +1,11 @@
1
+ # This file is specifically for you to define your strategies
2
+ #
3
+ # You should declare you strategies directly and/or use
4
+ # Merb::Authentication.activate!(:label_of_strategy)
5
+ #
6
+ # To load and set the order of strategy processing
7
+
8
+ Merb::Slices::config[:"merb-auth-slice-password"][:no_default_strategies] = true
9
+
10
+ Merb::Authentication.activate!(:default_password_form)
11
+ Merb::Authentication.activate!(:default_basic_auth)
@@ -0,0 +1,9 @@
1
+ module Merb
2
+ module Session
3
+
4
+ # The Merb::Session module gets mixed into Merb::SessionContainer to allow
5
+ # app-level functionality; it will be included and methods will be available
6
+ # through request.session as instance methods.
7
+
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ // Common JavaScript code across your application goes here.
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'merb-core'
5
+
6
+ # this is Merb.root, change this if you have some funky setup.
7
+ merb_root = File.expand_path(File.dirname(__FILE__) / '../')
8
+
9
+ # If the fcgi process runs as apache, make sure
10
+ # we have an inlinedir set for Rubyinline action-args to work
11
+ unless ENV["INLINEDIR"] || ENV["HOME"]
12
+ tmpdir = merb_root / "tmp"
13
+ unless File.directory?(tmpdir)
14
+ Dir.mkdir(tmpdir)
15
+ end
16
+ ENV["INLINEDIR"] = tmpdir
17
+ end
18
+
19
+ # start merb with the fcgi adapter, add options or change the log dir here
20
+ Merb.start(:adapter => 'fcgi',
21
+ :merb_root => merb_root,
22
+ :log_file => merb_root /'log'/'merb.log')
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -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,20 @@
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)
7
+ end
8
+
9
+ require "merb-core"
10
+ require "spec" # Satisfies Autotest and anyone else not using the Rake tasks
11
+
12
+ # this loads all plugins required in your init file so don't add them
13
+ # here again, Merb will do it for you
14
+ Merb.start_environment(:testing => true, :adapter => 'runner', :environment => ENV['MERB_ENV'] || 'test')
15
+
16
+ Spec::Runner.configure do |config|
17
+ config.include(Merb::Test::ViewHelper)
18
+ config.include(Merb::Test::RouteHelper)
19
+ config.include(Merb::Test::ControllerHelper)
20
+ end
@@ -0,0 +1,19 @@
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)
7
+ end
8
+
9
+ require "merb-core"
10
+
11
+ # TODO: Boot Merb, via the Test Rack adapter
12
+ Merb.start :environment => (ENV['MERB_ENV'] || 'test'),
13
+ :merb_root => File.join(File.dirname(__FILE__), ".." )
14
+
15
+
16
+ class Test::Unit::TestCase
17
+ include Merb::Test::RequestHelper
18
+ # Add more helper methods to be used by all tests here...
19
+ end
@@ -34,20 +34,26 @@
34
34
  <%= "# " unless template_engine == :haml %>use_template_engine :haml
35
35
 
36
36
  Merb::Config.use { |c|
37
- c[:framework] = { :public => [Merb.root / "public", nil] },
38
- c[:session_store] = 'none',
37
+ c[:framework] = { :public => [Merb.root / "public", nil] }
38
+ c[:session_store] = 'none'
39
39
  c[:exception_details] = true
40
40
  c[:log_level] = :debug # or error, warn, info or fatal
41
+ c[:log_stream] = STDOUT
42
+ # or use file for loggine:
43
+ # c[:log_file] = Merb.root / "log" / "merb.log"
44
+
45
+ c[:reload_classes] = true
46
+ c[:reload_templates] = true
41
47
  }
42
48
 
43
49
 
44
50
 
45
- Merb::Router.prepare do |r|
46
- r.match('/').to(:controller => '<%= base_name %>', :action =>'index')
51
+ Merb::Router.prepare do
52
+ match('/').to(:controller => '<%= base_name %>', :action =>'index')
47
53
  end
48
54
 
49
55
  class <%= class_name %> < Merb::Controller
50
56
  def index
51
- "hi"
57
+ "Hi, I am 'very flat' Merb application. I have everything in one single file and well suited for dynamic stub pages."
52
58
  end
53
59
  end
@@ -6,6 +6,7 @@
6
6
  <link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8" />
7
7
  </head>
8
8
  <body>
9
+ <%%#= message[:notice] %>
9
10
  <%%= catch_content :for_layout %>
10
11
  </body>
11
12
  </html>
@@ -0,0 +1,53 @@
1
+ require File.join(File.dirname(__FILE__), <%= go_up(modules.size + 1) %>, 'spec_helper.rb')
2
+
3
+ given "a <%= singular_model %> exists" do
4
+ request(resource(:<%= plural_model %>), :method => "POST",
5
+ :params => { :<%= singular_model %> => { }})
6
+ end
7
+
8
+ describe "resource(:<%= plural_model %>)" do
9
+ describe "GET" do
10
+
11
+ before(:each) do
12
+ @response = request(resource(:<%= singular_model %>s))
13
+ end
14
+
15
+ it "responds successfully" do
16
+ @response.should be_successful
17
+ end
18
+
19
+ it "contains a list of speakers" do
20
+ pending
21
+ @response.should have_xpath("//ul")
22
+ end
23
+
24
+ end
25
+
26
+ describe "GET", :given => "a <%= singular_model %> exists" do
27
+ before(:each) do
28
+ @response = request(resource(:<%= plural_model %>))
29
+ end
30
+
31
+ it "has a list of <%= plural_model %>" do
32
+ pending
33
+ @response.should have_xpath("//ul/li")
34
+ end
35
+ end
36
+
37
+ describe "a successful POST" do
38
+ before(:each) do
39
+ @response = request(resource(:<%= plural_model %>), :method => "POST",
40
+ :params => { :<%= singular_model %> => { }})
41
+ end
42
+
43
+ it "redirects to resource(:<%= plural_model %>)" do
44
+ <%- if orm.to_sym == :datamapper -%>
45
+ @response.should redirect_to(resource(<%= singular_model.capitalize %>.first), :message => {:notice => "<%= singular_model %> was successfully created"})
46
+ <%- elsif orm.to_sym == :activerecord -%>
47
+ @response.should redirect_to(resource(<%= singular_model.capitalize %>.first), :message => {:notice => "<%= singular_model %> was successfully created"})
48
+ <% end -%>
49
+ end
50
+
51
+ end
52
+ end
53
+
@@ -0,0 +1,13 @@
1
+ module Merb
2
+ module Generators
3
+
4
+ class AppGenerator < NamedGenerator
5
+
6
+ def initialize(*args)
7
+ Merb.disable(:initfile)
8
+ super
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -1,4 +1,21 @@
1
1
  module Merb
2
+
3
+ module ColorfulMessages
4
+ # red
5
+ def error(*messages)
6
+ puts messages.map { |msg| "\033[1;31m#{msg}\033[0m" }
7
+ end
8
+ # yellow
9
+ def warning(*messages)
10
+ puts messages.map { |msg| "\033[1;33m#{msg}\033[0m" }
11
+ end
12
+ # green
13
+ def success(*messages)
14
+ puts messages.map { |msg| "\033[1;32m#{msg}\033[0m" }
15
+ end
16
+
17
+ alias_method :message, :success
18
+ end
2
19
 
3
20
  module Generators
4
21
 
@@ -10,7 +27,25 @@ module Merb
10
27
 
11
28
  class Generator < Templater::Generator
12
29
 
30
+ include Merb::ColorfulMessages
31
+
13
32
  def initialize(*args)
33
+ Merb::Config.setup({
34
+ :log_level => :fatal,
35
+ :log_delimiter => " ~ ",
36
+ :log_auto_flush => false,
37
+ :reload_templates => false,
38
+ :reload_classes => false
39
+ })
40
+
41
+ Merb::BootLoader::Logger.run
42
+ Merb::BootLoader::BuildFramework.run
43
+ Merb::BootLoader::Dependencies.run
44
+
45
+ Merb::BootLoader::BeforeAppLoads.run
46
+ Merb::BootLoader::ReloadClasses.run
47
+ Merb::BootLoader::AfterAppLoads.run
48
+
14
49
  super
15
50
  options[:orm] ||= Merb.orm
16
51
  options[:testing_framework] ||= Merb.test_framework
@@ -50,4 +85,4 @@ module Merb
50
85
 
51
86
  end
52
87
 
53
- end
88
+ end
@@ -2,11 +2,14 @@ module Merb
2
2
  module Generators
3
3
 
4
4
  class NamedGenerator < Generator
5
-
6
5
  # NOTE: Currently this is not inherited, it will have to be declared in each generator
7
6
  # that inherits from this.
8
7
  first_argument :name, :required => true
9
8
 
9
+ def initialize(*args)
10
+ super
11
+ end
12
+
10
13
  def class_name
11
14
  name.gsub('-', '_').camel_case
12
15
  end
@@ -30,4 +33,4 @@ module Merb
30
33
  end
31
34
 
32
35
  end
33
- end
36
+ end
data/lib/merb-gen.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'merb-core'
3
3
  require 'sha1'
4
- gem 'templater', '>= 0.2.0'
4
+ gem 'templater', '>= 0.3.2'
5
5
  require 'templater'
6
6
 
7
7
  path = File.join(File.dirname(__FILE__))
@@ -9,8 +9,9 @@ path = File.join(File.dirname(__FILE__))
9
9
  require path / "merb-gen" / "generator"
10
10
  require path / "merb-gen" / "named_generator"
11
11
  require path / "merb-gen" / "namespaced_generator"
12
- require path / "generators" / "merb"
13
- require path / "generators" / "merb" / "merb_full"
12
+ require path / "merb-gen" / "app_generator"
13
+ require path / "generators" / "merb" / "merb_stack"
14
+ require path / "generators" / "merb" / "merb_core"
14
15
  require path / "generators" / "merb" / "merb_flat"
15
16
  require path / "generators" / "merb" / "merb_very_flat"
16
17
  require path / "generators" / "merb_plugin"
@@ -26,9 +27,6 @@ require path / "generators" / "layout"
26
27
 
27
28
  Templater::Discovery.discover!("merb-gen")
28
29
 
29
- # Require all generators that plugins have added to merb, after the app has loaded.
30
- Merb::BootLoader.after_app_loads do
31
- Merb.generators.each do |file|
32
- require file
33
- end
30
+ Merb.generators.each do |file|
31
+ require file
34
32
  end
@@ -16,19 +16,11 @@ describe Merb::Generators::ControllerGenerator do
16
16
  @generator.should create('/tmp/app/views/stuff/index.html.erb')
17
17
  end
18
18
 
19
- it "should create a helper" do
20
- @generator.should create('/tmp/app/helpers/stuff_helper.rb')
21
- end
22
-
23
19
  describe "with rspec" do
24
20
 
25
21
  it "should create a controller spec" do
26
22
  @generator.should create('/tmp/spec/controllers/stuff_spec.rb')
27
23
  end
28
-
29
- it "should create a helper spec" do
30
- @generator.should create('/tmp/spec/helpers/stuff_helper_spec.rb')
31
- end
32
24
 
33
25
  it "should render templates successfully" do
34
26
  lambda { @generator.render! }.should_not raise_error
@@ -71,14 +63,6 @@ describe Merb::Generators::ControllerGenerator do
71
63
  end
72
64
 
73
65
  describe "with rspec" do
74
-
75
- it "should create a controller spec" do
76
- @generator.should create('/tmp/spec/controllers/john/monkey/stuff_spec.rb')
77
- end
78
-
79
- it "should create a helper spec" do
80
- @generator.should create('/tmp/spec/helpers/john/monkey/stuff_helper_spec.rb')
81
- end
82
66
 
83
67
  it "should render templates successfully" do
84
68
  lambda { @generator.render! }.should_not raise_error
@@ -91,10 +75,6 @@ describe Merb::Generators::ControllerGenerator do
91
75
  before do
92
76
  @generator = Merb::Generators::ControllerGenerator.new('/tmp', { :testing_framework => :test_unit }, 'John::Monkey::Stuff')
93
77
  end
94
-
95
- it "should create a controller test" do
96
- @generator.should create('/tmp/test/controllers/john/monkey/stuff_test.rb')
97
- end
98
78
 
99
79
  it "should render templates successfully" do
100
80
  lambda { @generator.render! }.should_not raise_error
@@ -1,11 +1,11 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- describe Merb::Generators::MerbFullGenerator do
3
+ describe Merb::Generators::MerbCoreGenerator do
4
4
 
5
5
  describe "templates" do
6
6
 
7
7
  before do
8
- @generator = Merb::Generators::MerbFullGenerator.new('/tmp', {}, 'testing')
8
+ @generator = Merb::Generators::MerbCoreGenerator.new('/tmp', {}, 'testing')
9
9
  end
10
10
 
11
11
  it "should create an init.rb" do
@@ -19,6 +19,14 @@ describe Merb::Generators::MerbFullGenerator do
19
19
  it "should have an exceptions controller" do
20
20
  @generator.should create('/tmp/testing/app/controllers/exceptions.rb')
21
21
  end
22
+
23
+ it "should have a gitignore file" do
24
+ @generator.should create('/tmp/testing/.gitignore')
25
+ end
26
+
27
+ it "should have an htaccess file" do
28
+ @generator.should create('/tmp/testing/public/.htaccess')
29
+ end
22
30
 
23
31
  it "should create a number of views"
24
32
 
@@ -28,4 +36,4 @@ describe Merb::Generators::MerbFullGenerator do
28
36
 
29
37
  end
30
38
 
31
- end
39
+ end
@@ -0,0 +1,47 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe Merb::Generators::MerbStackGenerator do
4
+
5
+ describe "templates" do
6
+
7
+ before do
8
+ @generator = Merb::Generators::MerbStackGenerator.new('/tmp', {}, 'testing')
9
+ end
10
+
11
+ it "should create config/init.rb" do
12
+ @generator.should create('/tmp/testing/config/init.rb')
13
+ end
14
+
15
+ it "should create config/dependencies.rb" do
16
+ @generator.should create('/tmp/testing/config/dependencies.rb')
17
+ end
18
+
19
+ it "should create config/database.yml" do
20
+ @generator.should create('/tmp/testing/config/database.yml')
21
+ end
22
+
23
+ it "should have an application controller" do
24
+ @generator.should create('/tmp/testing/app/controllers/application.rb')
25
+ end
26
+
27
+ it "should have an exceptions controller" do
28
+ @generator.should create('/tmp/testing/app/controllers/exceptions.rb')
29
+ end
30
+
31
+ it "should have a gitignore file" do
32
+ @generator.should create('/tmp/testing/.gitignore')
33
+ end
34
+
35
+ it "should have an htaccess file" do
36
+ @generator.should create('/tmp/testing/public/.htaccess')
37
+ end
38
+
39
+ it "should create a number of views"
40
+
41
+ it "should render templates successfully" do
42
+ lambda { @generator.render! }.should_not raise_error
43
+ end
44
+
45
+ end
46
+
47
+ end
@@ -16,26 +16,6 @@ describe Merb::Generators::PartControllerGenerator do
16
16
  @generator.should create('/tmp/app/parts/views/stuff_part/index.html.erb')
17
17
  end
18
18
 
19
- it "should create a helper" do
20
- @generator.should create('/tmp/app/helpers/stuff_part_helper.rb')
21
- end
22
-
23
- describe "with rspec" do
24
-
25
- it "should create a controller spec"
26
-
27
- it "should create a helper spec" do
28
- @generator.should create('/tmp/spec/helpers/stuff_part_helper_spec.rb')
29
- end
30
-
31
- end
32
-
33
- describe "with test_unit" do
34
-
35
- it "should create a controller test"
36
-
37
- end
38
-
39
19
  describe "with a namespace" do
40
20
 
41
21
  before(:each) do
@@ -50,25 +30,6 @@ describe Merb::Generators::PartControllerGenerator do
50
30
  @generator.should create('/tmp/app/parts/views/john/monkey/stuff_part/index.html.erb')
51
31
  end
52
32
 
53
- it "should create a helper" do
54
- @generator.should create('/tmp/app/helpers/john/monkey/stuff_part_helper.rb')
55
- end
56
-
57
- describe "with rspec" do
58
-
59
- it "should create a controller spec"
60
-
61
- it "should create a helper spec" do
62
- @generator.should create('/tmp/spec/helpers/john/monkey/stuff_part_helper_spec.rb')
63
- end
64
-
65
- end
66
-
67
- describe "with test_unit" do
68
-
69
- it "should create a controller test"
70
-
71
- end
72
33
  end
73
34
 
74
35
  end