railties 4.0.13 → 4.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +155 -385
  3. data/README.rdoc +1 -1
  4. data/bin/rails +1 -1
  5. data/lib/rails.rb +11 -13
  6. data/lib/rails/all.rb +1 -0
  7. data/lib/rails/api/task.rb +9 -12
  8. data/lib/rails/app_rails_loader.rb +2 -2
  9. data/lib/rails/application.rb +154 -149
  10. data/lib/rails/application/configuration.rb +1 -14
  11. data/lib/rails/application/default_middleware_stack.rb +99 -0
  12. data/lib/rails/application/finisher.rb +2 -0
  13. data/lib/rails/application_controller.rb +16 -0
  14. data/lib/rails/cli.rb +1 -2
  15. data/lib/rails/commands.rb +2 -94
  16. data/lib/rails/commands/application.rb +2 -28
  17. data/lib/rails/commands/commands_tasks.rb +174 -0
  18. data/lib/rails/commands/console.rb +2 -2
  19. data/lib/rails/commands/dbconsole.rb +1 -1
  20. data/lib/rails/commands/plugin.rb +23 -0
  21. data/lib/rails/commands/runner.rb +1 -1
  22. data/lib/rails/commands/server.rb +46 -30
  23. data/lib/rails/configuration.rb +4 -1
  24. data/lib/rails/console/helpers.rb +6 -0
  25. data/lib/rails/engine.rb +29 -18
  26. data/lib/rails/engine/commands.rb +1 -1
  27. data/lib/rails/engine/railties.rb +0 -8
  28. data/lib/rails/generators.rb +4 -3
  29. data/lib/rails/generators/actions.rb +1 -1
  30. data/lib/rails/generators/active_model.rb +0 -8
  31. data/lib/rails/generators/app_base.rb +213 -74
  32. data/lib/rails/generators/base.rb +17 -16
  33. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +1 -1
  34. data/lib/rails/generators/erb/scaffold/templates/index.html.erb +1 -3
  35. data/lib/rails/generators/migration.rb +18 -26
  36. data/lib/rails/generators/named_base.rb +4 -7
  37. data/lib/rails/generators/rails/app/app_generator.rb +91 -5
  38. data/lib/rails/generators/rails/app/templates/Gemfile +20 -15
  39. data/lib/rails/generators/rails/app/templates/Rakefile +1 -1
  40. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +2 -0
  41. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +5 -3
  42. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +5 -1
  43. data/lib/rails/generators/rails/app/templates/config/application.rb +2 -0
  44. data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml +7 -10
  45. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml +11 -31
  46. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +25 -29
  47. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +8 -10
  48. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +8 -11
  49. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +6 -3
  50. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +8 -22
  51. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +7 -9
  52. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +9 -12
  53. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml +8 -8
  54. data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml +7 -17
  55. data/lib/rails/generators/rails/app/templates/config/environment.rb +1 -1
  56. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +2 -5
  57. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +1 -1
  58. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +1 -4
  59. data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
  60. data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
  61. data/lib/rails/generators/rails/app/templates/config/{initializers/secret_token.rb.tt → secrets.yml} +10 -2
  62. data/lib/rails/generators/rails/app/templates/public/404.html +20 -11
  63. data/lib/rails/generators/rails/app/templates/public/422.html +20 -11
  64. data/lib/rails/generators/rails/app/templates/public/500.html +19 -10
  65. data/lib/rails/generators/rails/controller/USAGE +1 -0
  66. data/lib/rails/generators/rails/controller/controller_generator.rb +35 -1
  67. data/lib/rails/generators/rails/generator/USAGE +1 -0
  68. data/lib/rails/generators/rails/generator/generator_generator.rb +2 -0
  69. data/lib/rails/generators/rails/model/USAGE +5 -5
  70. data/lib/rails/generators/rails/{plugin_new → plugin}/USAGE +0 -0
  71. data/lib/rails/generators/rails/{plugin_new/plugin_new_generator.rb → plugin/plugin_generator.rb} +10 -4
  72. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/%name%.gemspec +1 -0
  73. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/Gemfile +16 -1
  74. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/MIT-LICENSE +0 -0
  75. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/README.rdoc +0 -0
  76. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/Rakefile +0 -0
  77. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/app/controllers/%name%/application_controller.rb.tt +0 -0
  78. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/app/helpers/%name%/application_helper.rb.tt +0 -0
  79. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/app/mailers/.empty_directory +0 -0
  80. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/app/models/.empty_directory +0 -0
  81. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/app/views/layouts/%name%/application.html.erb.tt +0 -0
  82. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/bin/rails.tt +0 -4
  83. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/config/routes.rb +0 -0
  84. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/gitignore +0 -0
  85. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/lib/%name%.rb +0 -0
  86. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/lib/%name%/engine.rb +0 -0
  87. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/lib/%name%/version.rb +0 -0
  88. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/lib/tasks/%name%_tasks.rake +0 -0
  89. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/rails/application.rb +1 -0
  90. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/rails/boot.rb +0 -0
  91. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/rails/javascripts.js +0 -0
  92. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/rails/routes.rb +0 -0
  93. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/rails/stylesheets.css +5 -3
  94. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/test/%name%_test.rb +0 -0
  95. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/test/integration/navigation_test.rb +0 -0
  96. data/lib/rails/generators/rails/{plugin_new → plugin}/templates/test/test_helper.rb +0 -0
  97. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +1 -1
  98. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +2 -2
  99. data/lib/rails/generators/resource_helpers.rb +20 -5
  100. data/lib/rails/generators/test_unit/generator/generator_generator.rb +26 -0
  101. data/lib/rails/generators/test_unit/generator/templates/generator_test.rb +16 -0
  102. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +8 -1
  103. data/lib/rails/generators/test_unit/mailer/templates/preview.rb +11 -0
  104. data/lib/rails/generators/testing/assertions.rb +1 -1
  105. data/lib/rails/generators/testing/behaviour.rb +3 -13
  106. data/lib/rails/info.rb +5 -3
  107. data/lib/rails/info_controller.rb +5 -15
  108. data/lib/rails/mailers_controller.rb +73 -0
  109. data/lib/rails/paths.rb +13 -18
  110. data/lib/rails/rack/debugger.rb +2 -2
  111. data/lib/rails/rack/logger.rb +1 -1
  112. data/lib/rails/railtie.rb +38 -2
  113. data/lib/rails/source_annotation_extractor.rb +2 -2
  114. data/lib/rails/tasks.rb +0 -2
  115. data/lib/rails/tasks/documentation.rake +0 -5
  116. data/lib/rails/tasks/engine.rake +1 -1
  117. data/lib/rails/tasks/framework.rake +2 -12
  118. data/lib/rails/templates/layouts/application.html.erb +2 -2
  119. data/lib/rails/templates/rails/mailers/email.html.erb +98 -0
  120. data/lib/rails/templates/rails/mailers/index.html.erb +8 -0
  121. data/lib/rails/templates/rails/mailers/mailer.html.erb +6 -0
  122. data/lib/rails/test_help.rb +4 -1
  123. data/lib/rails/test_unit/sub_test_task.rb +44 -3
  124. data/lib/rails/test_unit/testing.rake +9 -111
  125. data/lib/rails/version.rb +3 -3
  126. data/lib/rails/welcome_controller.rb +4 -3
  127. metadata +99 -76
  128. data/lib/rails/commands/plugin_new.rb +0 -9
  129. data/lib/rails/generators/actions/create_migration.rb +0 -68
@@ -1,4 +1,4 @@
1
- <%= app_const %>.configure do
1
+ Rails.application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # In the development environment your application's code is reloaded on
@@ -20,7 +20,7 @@
20
20
  config.active_support.deprecation = :log
21
21
 
22
22
  <%- unless options.skip_active_record? -%>
23
- # Raise an error on page load if there are pending migrations
23
+ # Raise an error on page load if there are pending migrations.
24
24
  config.active_record.migration_error = :page_load
25
25
 
26
26
  <%- end -%>
@@ -30,7 +30,4 @@
30
30
  # number of complex assets.
31
31
  config.assets.debug = true
32
32
  <%- end -%>
33
-
34
- # Raises error for missing translations
35
- # config.action_view.raise_on_missing_translations = true
36
33
  end
@@ -1,4 +1,4 @@
1
- <%= app_const %>.configure do
1
+ Rails.application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # Code is not reloaded between requests.
@@ -1,4 +1,4 @@
1
- <%= app_const %>.configure do
1
+ Rails.application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # The test environment is used exclusively to run your application's
@@ -33,7 +33,4 @@
33
33
 
34
34
  # Print deprecation notices to the stderr.
35
35
  config.active_support.deprecation = :stderr
36
-
37
- # Raises error for missing translations
38
- # config.action_view.raise_on_missing_translations = true
39
36
  end
@@ -1,3 +1,3 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- <%= app_const %>.config.session_store :cookie_store, key: <%= "'_#{app_name}_session'" %>
3
+ Rails.application.config.session_store :cookie_store, key: <%= "'_#{app_name}_session'" %>
@@ -1,4 +1,4 @@
1
- <%= app_const %>.routes.draw do
1
+ Rails.application.routes.draw do
2
2
  # The priority is based upon order of creation: first created -> highest priority.
3
3
  # See how all your routes lay out with "rake routes".
4
4
 
@@ -7,6 +7,14 @@
7
7
  # no regular words or you'll be exposed to dictionary attacks.
8
8
  # You can use `rake secret` to generate a secure secret key.
9
9
 
10
- # Make sure your secret_key_base is kept private
10
+ # Make sure the secrets in this file are kept private
11
11
  # if you're sharing your code publicly.
12
- <%= app_const %>.config.secret_key_base = '<%= app_secret %>'
12
+
13
+ development:
14
+ secret_key_base: <%= app_secret %>
15
+
16
+ test:
17
+ secret_key_base: <%= app_secret %>
18
+
19
+ production:
20
+ secret_key_base: <%= app_secret %>
@@ -2,17 +2,23 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
5
6
  <style>
6
7
  body {
7
8
  background-color: #EFEFEF;
8
9
  color: #2E2F30;
9
10
  text-align: center;
10
11
  font-family: arial, sans-serif;
12
+ margin: 0;
11
13
  }
12
14
 
13
15
  div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
16
22
  border: 1px solid #CCC;
17
23
  border-right-color: #999;
18
24
  border-left-color: #999;
@@ -21,7 +27,8 @@
21
27
  border-top-left-radius: 9px;
22
28
  border-top-right-radius: 9px;
23
29
  background-color: white;
24
- padding: 7px 4em 0 4em;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
25
32
  }
26
33
 
27
34
  h1 {
@@ -30,19 +37,19 @@
30
37
  line-height: 1.5em;
31
38
  }
32
39
 
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
37
43
  background-color: #F7F7F7;
38
44
  border: 1px solid #CCC;
39
45
  border-right-color: #999;
46
+ border-left-color: #999;
40
47
  border-bottom-color: #999;
41
48
  border-bottom-left-radius: 4px;
42
49
  border-bottom-right-radius: 4px;
43
50
  border-top-color: #DADADA;
44
51
  color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
46
53
  }
47
54
  </style>
48
55
  </head>
@@ -50,9 +57,11 @@
50
57
  <body>
51
58
  <!-- This file lives in public/404.html -->
52
59
  <div class="dialog">
53
- <h1>The page you were looking for doesn't exist.</h1>
54
- <p>You may have mistyped the address or the page may have moved.</p>
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
55
65
  </div>
56
- <p>If you are the application owner check the logs for more information.</p>
57
66
  </body>
58
67
  </html>
@@ -2,17 +2,23 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
5
6
  <style>
6
7
  body {
7
8
  background-color: #EFEFEF;
8
9
  color: #2E2F30;
9
10
  text-align: center;
10
11
  font-family: arial, sans-serif;
12
+ margin: 0;
11
13
  }
12
14
 
13
15
  div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
16
22
  border: 1px solid #CCC;
17
23
  border-right-color: #999;
18
24
  border-left-color: #999;
@@ -21,7 +27,8 @@
21
27
  border-top-left-radius: 9px;
22
28
  border-top-right-radius: 9px;
23
29
  background-color: white;
24
- padding: 7px 4em 0 4em;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
25
32
  }
26
33
 
27
34
  h1 {
@@ -30,19 +37,19 @@
30
37
  line-height: 1.5em;
31
38
  }
32
39
 
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
37
43
  background-color: #F7F7F7;
38
44
  border: 1px solid #CCC;
39
45
  border-right-color: #999;
46
+ border-left-color: #999;
40
47
  border-bottom-color: #999;
41
48
  border-bottom-left-radius: 4px;
42
49
  border-bottom-right-radius: 4px;
43
50
  border-top-color: #DADADA;
44
51
  color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
46
53
  }
47
54
  </style>
48
55
  </head>
@@ -50,9 +57,11 @@
50
57
  <body>
51
58
  <!-- This file lives in public/422.html -->
52
59
  <div class="dialog">
53
- <h1>The change you wanted was rejected.</h1>
54
- <p>Maybe you tried to change something you didn't have access to.</p>
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
55
65
  </div>
56
- <p>If you are the application owner check the logs for more information.</p>
57
66
  </body>
58
67
  </html>
@@ -2,17 +2,23 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
5
6
  <style>
6
7
  body {
7
8
  background-color: #EFEFEF;
8
9
  color: #2E2F30;
9
10
  text-align: center;
10
11
  font-family: arial, sans-serif;
12
+ margin: 0;
11
13
  }
12
14
 
13
15
  div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
16
22
  border: 1px solid #CCC;
17
23
  border-right-color: #999;
18
24
  border-left-color: #999;
@@ -21,7 +27,8 @@
21
27
  border-top-left-radius: 9px;
22
28
  border-top-right-radius: 9px;
23
29
  background-color: white;
24
- padding: 7px 4em 0 4em;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
25
32
  }
26
33
 
27
34
  h1 {
@@ -30,19 +37,19 @@
30
37
  line-height: 1.5em;
31
38
  }
32
39
 
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
37
43
  background-color: #F7F7F7;
38
44
  border: 1px solid #CCC;
39
45
  border-right-color: #999;
46
+ border-left-color: #999;
40
47
  border-bottom-color: #999;
41
48
  border-bottom-left-radius: 4px;
42
49
  border-bottom-right-radius: 4px;
43
50
  border-top-color: #DADADA;
44
51
  color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
46
53
  }
47
54
  </style>
48
55
  </head>
@@ -50,8 +57,10 @@
50
57
  <body>
51
58
  <!-- This file lives in public/500.html -->
52
59
  <div class="dialog">
53
- <h1>We're sorry, but something went wrong.</h1>
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
54
64
  </div>
55
- <p>If you are the application owner check the logs for more information.</p>
56
65
  </body>
57
66
  </html>
@@ -16,3 +16,4 @@ Example:
16
16
  Test: test/controllers/credit_cards_controller_test.rb
17
17
  Views: app/views/credit_cards/debit.html.erb [...]
18
18
  Helper: app/helpers/credit_cards_helper.rb
19
+ Test: test/helpers/credit_cards_helper_test.rb
@@ -10,11 +10,45 @@ module Rails
10
10
 
11
11
  def add_routes
12
12
  actions.reverse.each do |action|
13
- route %{get "#{file_name}/#{action}"}
13
+ route generate_routing_code(action)
14
14
  end
15
15
  end
16
16
 
17
17
  hook_for :template_engine, :test_framework, :helper, :assets
18
+
19
+ private
20
+
21
+ # This method creates nested route entry for namespaced resources.
22
+ # For eg. rails g controller foo/bar/baz index
23
+ # Will generate -
24
+ # namespace :foo do
25
+ # namespace :bar do
26
+ # get "baz/index"
27
+ # end
28
+ # end
29
+ def generate_routing_code(action)
30
+ depth = class_path.length
31
+ # Create 'namespace' ladder
32
+ # namespace :foo do
33
+ # namespace :bar do
34
+ namespace_ladder = class_path.each_with_index.map do |ns, i|
35
+ indent("namespace :#{ns} do\n", i * 2)
36
+ end.join
37
+
38
+ # Create route
39
+ # get "baz/index"
40
+ route = indent(%{get "#{file_name}/#{action}"\n}, depth * 2)
41
+
42
+ # Create `end` ladder
43
+ # end
44
+ # end
45
+ end_ladder = (1..depth).reverse_each.map do |i|
46
+ indent("end\n", i * 2)
47
+ end.join
48
+
49
+ # Combine the 3 parts to generate complete route entry
50
+ namespace_ladder + route + end_ladder
51
+ end
18
52
  end
19
53
  end
20
54
  end
@@ -10,3 +10,4 @@ Example:
10
10
  lib/generators/awesome/awesome_generator.rb
11
11
  lib/generators/awesome/USAGE
12
12
  lib/generators/awesome/templates/
13
+ test/lib/generators/awesome_generator_test.rb
@@ -10,6 +10,8 @@ module Rails
10
10
  directory '.', generator_dir
11
11
  end
12
12
 
13
+ hook_for :test_framework
14
+
13
15
  protected
14
16
 
15
17
  def generator_dir
@@ -46,18 +46,18 @@ Available field types:
46
46
 
47
47
  `rails generate model photo title:string album:references`
48
48
 
49
- It will generate an album_id column. You should generate this kind of fields when
50
- you will use a `belongs_to` association for instance. `references` also support
51
- the polymorphism, you could enable the polymorphism like this:
49
+ It will generate an `album_id` column. You should generate these kinds of fields when
50
+ you will use a `belongs_to` association, for instance. `references` also supports
51
+ polymorphism, you can enable polymorphism like this:
52
52
 
53
53
  `rails generate model product supplier:references{polymorphic}`
54
54
 
55
- For integer, string, text and binary fields an integer in curly braces will
55
+ For integer, string, text and binary fields, an integer in curly braces will
56
56
  be set as the limit:
57
57
 
58
58
  `rails generate model user pseudo:string{30}`
59
59
 
60
- For decimal two integers separated by a comma in curly braces will be used
60
+ For decimal, two integers separated by a comma in curly braces will be used
61
61
  for precision and scale:
62
62
 
63
63
  `rails generate model product 'price:decimal{10,2}'`
@@ -154,7 +154,7 @@ task default: :test
154
154
  end
155
155
 
156
156
  module Generators
157
- class PluginNewGenerator < AppBase # :nodoc:
157
+ class PluginGenerator < AppBase # :nodoc:
158
158
  add_shared_options_for "plugin"
159
159
 
160
160
  alias_method :plugin_path, :app_path
@@ -176,12 +176,16 @@ task default: :test
176
176
  "skip adding entry to Gemfile"
177
177
 
178
178
  def initialize(*args)
179
- raise Error, "Options should be given after the plugin name. For details run: rails plugin new --help" if args[0].blank?
180
-
181
179
  @dummy_path = nil
182
180
  super
181
+
182
+ unless plugin_path
183
+ raise Error, "Plugin name should be provided in arguments. For details run: rails plugin new --help"
184
+ end
183
185
  end
184
186
 
187
+ public_task :set_default_accessors!
188
+ public_task :apply_rails_template
185
189
  public_task :create_root
186
190
 
187
191
  def create_root_files
@@ -238,7 +242,6 @@ task default: :test
238
242
  build(:leftovers)
239
243
  end
240
244
 
241
- public_task :apply_rails_template, :run_bundle
242
245
 
243
246
  def name
244
247
  @name ||= begin
@@ -252,6 +255,9 @@ task default: :test
252
255
  end
253
256
  end
254
257
 
258
+ public_task :run_bundle
259
+ public_task :replay_template
260
+
255
261
  protected
256
262
 
257
263
  def app_templates_dir
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.homepage = "TODO"
13
13
  s.summary = "TODO: Summary of <%= camelized %>."
14
14
  s.description = "TODO: Description of <%= camelized %>."
15
+ s.license = "MIT"
15
16
 
16
17
  s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
17
18
  <% unless options.skip_test_unit? -%>
@@ -23,8 +23,23 @@ end
23
23
  <% if options.dev? || options.edge? -%>
24
24
  # Your gem is dependent on dev or edge Rails. Once you can lock this
25
25
  # dependency down to a specific version, move it to your gemspec.
26
- <%= rails_gemfile_entry -%>
26
+ <% max_width = gemfile_entries.map { |g| g.name.length }.max -%>
27
+ <% gemfile_entries.each do |gem| -%>
28
+ <% if gem.comment -%>
27
29
 
30
+ # <%= gem.comment %>
28
31
  <% end -%>
32
+ <%= gem.commented_out ? '# ' : '' %>gem '<%= gem.name %>'<% if gem.version -%>
33
+ , '<%= gem.version %>'
34
+ <% elsif gem.options.any? -%>
35
+ ,<%= gem.padding(max_width) %><%= gem.options.map { |k,v|
36
+ "#{k}: #{v.inspect}" }.join(', ') %>
37
+ <% else %>
38
+ <% end -%>
39
+ <% end -%>
40
+
41
+ <% end -%>
42
+ <% unless defined?(JRUBY_VERSION) -%>
29
43
  # To use debugger
30
44
  # gem 'debugger'
45
+ <% end -%>