vraptor-scaffold 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/.travis.yml +7 -0
  2. data/CHANGELOG.rdoc +164 -0
  3. data/Gemfile.lock +5 -8
  4. data/README.textile +20 -7
  5. data/bin/vraptor +1 -1
  6. data/index.sample.html +169 -0
  7. data/lib/vraptor-scaffold.rb +10 -29
  8. data/lib/vraptor-scaffold/configuration.rb +27 -4
  9. data/lib/vraptor-scaffold/execution.rb +24 -0
  10. data/lib/vraptor-scaffold/generators/app/app_generator.rb +196 -0
  11. data/lib/vraptor-scaffold/generators/{app_generator → app}/dependency.rb +0 -0
  12. data/lib/vraptor-scaffold/generators/app/dependency_manager.rb +53 -0
  13. data/lib/vraptor-scaffold/generators/{app_generator → app}/freemarker_template_engine.rb +0 -0
  14. data/lib/vraptor-scaffold/generators/{app_generator → app}/jsp_template_engine.rb +0 -0
  15. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.gradle.erb +19 -1
  16. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.properties.erb +0 -0
  17. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.xml +6 -2
  18. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/decorators.erb +0 -0
  19. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/classpath.erb +0 -5
  20. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/project.erb +0 -0
  21. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.jdt.core.prefs +0 -0
  22. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.common.component.tt +0 -0
  23. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.common.project.facet.core.xml +0 -0
  24. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.container +0 -0
  25. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.name +0 -0
  26. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/freemarker-web.xml +0 -0
  27. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/infrastructure/FreemarkerPathResolver.java.tt +0 -0
  28. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/macros/html.ftl +0 -0
  29. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/main.ftl +0 -0
  30. data/lib/vraptor-scaffold/generators/app/templates/heroku/Main.java +21 -0
  31. data/lib/vraptor-scaffold/generators/app/templates/heroku/Procfile +1 -0
  32. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/ivy-2.2.0.jar +0 -0
  33. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/ivy.erb +1 -1
  34. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/jsp-web.xml +0 -0
  35. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/main.jsp +2 -2
  36. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/prelude.jspf +0 -0
  37. data/lib/vraptor-scaffold/generators/{app_generator/templates/src/models/Entity.java.tt → app/templates/models/Entity.erb} +1 -1
  38. data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-hibernate.java.tt +50 -0
  39. data/lib/vraptor-scaffold/generators/{app_generator/templates/src/repositories/Repository.java.tt → app/templates/orm/Repository-jpa.java.tt} +3 -3
  40. data/lib/vraptor-scaffold/generators/app/templates/orm/hibernate.cfg.xml +7 -0
  41. data/lib/vraptor-scaffold/generators/app/templates/orm/persistence.xml +10 -0
  42. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/pom.erb +29 -13
  43. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/resources-test/.empty_directory +0 -0
  44. data/lib/vraptor-scaffold/generators/app/templates/resources/hibernate.properties +16 -0
  45. data/lib/vraptor-scaffold/generators/app/templates/resources/log4j.properties +4 -0
  46. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/resources/messages.properties +0 -0
  47. data/lib/vraptor-scaffold/generators/app/templates/vraptor-scaffold.erb +7 -0
  48. data/lib/vraptor-scaffold/generators/{app_generator/templates/webapp/WEB-INF/web.xml → app/templates/webapp/WEB-INF/web.xml.tt} +2 -2
  49. data/lib/vraptor-scaffold/generators/{app_generator/templates/src-test/controllers → app/templates/webapp/images}/.empty_directory +0 -0
  50. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/index.jsp +0 -0
  51. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/common.css +0 -0
  52. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/scaffold.css +0 -0
  53. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/stylesheets.css +0 -0
  54. data/lib/vraptor-scaffold/generators/plugin/plugin_generator.rb +42 -0
  55. data/lib/vraptor-scaffold/generators/plugin/vraptor_gem.rb +36 -0
  56. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/attribute.rb +1 -1
  57. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/base_scaffold.rb +6 -2
  58. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/controller_generator.rb +3 -3
  59. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/controller.erb +3 -3
  60. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/controller_test.erb +1 -1
  61. data/lib/vraptor-scaffold/generators/scaffold/model_generator/model_generator.rb +20 -0
  62. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/model.erb +3 -3
  63. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/model_test.erb +1 -1
  64. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator.rb +27 -0
  65. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/repository.erb +3 -3
  66. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_impl.erb +16 -0
  67. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/repository_test.erb +1 -1
  68. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/scaffold_generator.rb +0 -0
  69. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/freemarker_generator.rb +18 -0
  70. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/edit.erb +0 -0
  71. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/form.erb +4 -4
  72. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/index.erb +36 -0
  73. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/new.erb +0 -0
  74. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/show.erb +14 -0
  75. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/jsp_generator.rb +18 -0
  76. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/edit.erb +0 -0
  77. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/form.erb +4 -4
  78. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/index.erb +6 -6
  79. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/new.erb +0 -0
  80. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/templates/show.erb +14 -0
  81. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/template_engine_generator.rb +21 -0
  82. data/lib/vraptor-scaffold/load_paths.rb +13 -21
  83. data/lib/vraptor-scaffold/runner.rb +11 -0
  84. data/lib/vraptor-scaffold/runner/commands_help.rb +13 -0
  85. data/lib/vraptor-scaffold/runner/configure.rb +21 -0
  86. data/lib/vraptor-scaffold/runner/generator.rb +15 -0
  87. data/lib/vraptor-scaffold/runner/help.rb +12 -0
  88. data/lib/vraptor-scaffold/runner/plugin.rb +19 -0
  89. data/lib/vraptor-scaffold/runner/scaffold.rb +16 -0
  90. data/lib/vraptor-scaffold/version.rb +1 -1
  91. data/spec/resources/vraptor-scaffold.properties +5 -0
  92. data/spec/simple_custom_plugin.rb +10 -0
  93. data/spec/spec_helper.rb +5 -6
  94. data/spec/vraptor-scaffold/configuration_spec.rb +88 -4
  95. data/spec/vraptor-scaffold/execution_spec.rb +47 -0
  96. data/spec/vraptor-scaffold/generators/{app_generator → app}/app_generator_spec.rb +136 -54
  97. data/spec/vraptor-scaffold/generators/{app_generator → app}/dependency_manager_spec.rb +1 -1
  98. data/spec/vraptor-scaffold/generators/{app_generator → app}/dependency_spec.rb +0 -0
  99. data/spec/vraptor-scaffold/generators/{app_generator → app}/freemarker_template_engine_spec.rb +1 -1
  100. data/spec/vraptor-scaffold/generators/{app_generator → app}/jsp_template_engine_spec.rb +0 -0
  101. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/Entity.java +1 -1
  102. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/FreemarkerPathResolver.java +0 -0
  103. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/Repository.java +3 -3
  104. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/build.gradle +24 -5
  105. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/build.properties +0 -0
  106. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/decorators-jsp.xml +0 -0
  107. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/decorators.xml +0 -0
  108. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker-web.xml +2 -2
  109. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/ivy.xml +6 -5
  110. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/jsp-web.xml +1 -1
  111. data/spec/vraptor-scaffold/generators/app/templates/pom-heroku.xml +168 -0
  112. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/pom.xml +11 -14
  113. data/spec/vraptor-scaffold/generators/app/templates/vraptor-scaffold.properties +7 -0
  114. data/spec/vraptor-scaffold/generators/plugin/expected_configs/build.gradle +61 -0
  115. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_build.gradle +61 -0
  116. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_ivy.xml +40 -0
  117. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_pom.xml +147 -0
  118. data/spec/vraptor-scaffold/generators/plugin/expected_configs/ivy.xml +40 -0
  119. data/spec/vraptor-scaffold/generators/plugin/expected_configs/pom.xml +147 -0
  120. data/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb +130 -0
  121. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/attribute_spec.rb +13 -9
  122. data/spec/vraptor-scaffold/generators/scaffold/base_scaffold_spec.rb +73 -0
  123. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/controller_generator_spec.rb +18 -9
  124. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/ProductController.java +3 -3
  125. data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/freemarker_generator_spec.rb +74 -0
  126. data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/jsp_generator_spec.rb +75 -0
  127. data/spec/vraptor-scaffold/generators/scaffold/model_generator/model_generator_spec.rb +50 -0
  128. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/Product.java +6 -6
  129. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/hibernate.cfg.xml +8 -0
  130. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator_spec.rb +60 -0
  131. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepository.java +22 -0
  132. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepositoryImpl.java +16 -0
  133. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/ProductRepository.java +3 -3
  134. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/ProductRepositoryImpl.java +3 -3
  135. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/scaffold_generator_spec.rb +0 -0
  136. data/spec/vraptor-scaffold/runner/commands_help_spec.rb +12 -0
  137. data/spec/vraptor-scaffold/runner/configure_spec.rb +12 -0
  138. data/spec/vraptor-scaffold/runner/generator_spec.rb +31 -0
  139. data/spec/vraptor-scaffold/runner/help_spec.rb +29 -0
  140. data/spec/vraptor-scaffold/runner/plugin_spec.rb +45 -0
  141. data/spec/vraptor-scaffold/runner/scaffold_spec.rb +35 -0
  142. data/spec/vraptor-scaffold_spec.rb +1 -94
  143. data/vraptor-scaffold.gemspec +3 -3
  144. metadata +137 -140
  145. data/History.txt +0 -128
  146. data/lib/vraptor-scaffold/generators/app_generator/app_generator.rb +0 -102
  147. data/lib/vraptor-scaffold/generators/app_generator/dependency_manager.rb +0 -37
  148. data/lib/vraptor-scaffold/generators/app_generator/templates/ivysettings.xml +0 -9
  149. data/lib/vraptor-scaffold/generators/app_generator/templates/resources/META-INF/persistence.xml +0 -20
  150. data/lib/vraptor-scaffold/generators/app_generator/templates/resources/log4j.properties +0 -4
  151. data/lib/vraptor-scaffold/generators/app_generator/templates/src-test/models/.empty_directory +0 -0
  152. data/lib/vraptor-scaffold/generators/app_generator/templates/src-test/repositories/.empty_directory +0 -0
  153. data/lib/vraptor-scaffold/generators/app_generator/templates/src/controllers/.empty_directory +0 -0
  154. data/lib/vraptor-scaffold/generators/app_generator/templates/vraptor-scaffold.erb +0 -2
  155. data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/images/.empty_directory +0 -0
  156. data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/javascripts/application.js +0 -0
  157. data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/javascripts/jquery.min.js +0 -16
  158. data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/freemarker_generator.rb +0 -22
  159. data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/templates/index.erb +0 -36
  160. data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/templates/show.erb +0 -14
  161. data/lib/vraptor-scaffold/generators/scaffold_generator/jsp_generator/jsp_generator.rb +0 -22
  162. data/lib/vraptor-scaffold/generators/scaffold_generator/jsp_generator/templates/show.erb +0 -14
  163. data/lib/vraptor-scaffold/generators/scaffold_generator/model_generator/model_generator.rb +0 -11
  164. data/lib/vraptor-scaffold/generators/scaffold_generator/repository_generator/repository_generator.rb +0 -12
  165. data/lib/vraptor-scaffold/generators/scaffold_generator/repository_generator/templates/repository_impl.erb +0 -16
  166. data/spec/vraptor-scaffold/generators/scaffold_generator/base_scaffold_spec.rb +0 -41
  167. data/spec/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb +0 -36
  168. data/spec/vraptor-scaffold/generators/scaffold_generator/jsp_generator/jsp_generator_spec.rb +0 -34
  169. data/spec/vraptor-scaffold/generators/scaffold_generator/model_generator/model_generator_spec.rb +0 -25
  170. data/spec/vraptor-scaffold/generators/scaffold_generator/repository_generator/repository_generator_spec.rb +0 -31
@@ -1,4 +1,4 @@
1
- package <%= Configuration.package %>.models;
1
+ package <%= Configuration.full_models_package %>;
2
2
 
3
3
  import static org.junit.Assert.assertNotNull;
4
4
 
@@ -0,0 +1,27 @@
1
+ class RepositoryGenerator < BaseScaffold
2
+
3
+ def self.source_root
4
+ File.join File.dirname(__FILE__), "templates"
5
+ end
6
+
7
+ def build
8
+ template("repository.erb", Configuration.main_class_path(Configuration.repositories_package, "#{repository_interface_name}.java"))
9
+ template("repository_impl.erb", Configuration.main_class_path(Configuration.repositories_package, "#{repository_impl_name}.java"))
10
+ template("repository_test.erb", Configuration.test_class_path(Configuration.repositories_package, "#{repository_test_class_name}.java"))
11
+ end
12
+
13
+ def orm_import
14
+ return "org.hibernate.Session" if Configuration.hibernate?
15
+ "javax.persistence.EntityManager"
16
+ end
17
+
18
+ def orm_parameter_name
19
+ return "session" if Configuration.hibernate?
20
+ "entityManager"
21
+ end
22
+
23
+ def orm_class
24
+ orm_parameter_name.camelize
25
+ end
26
+
27
+ end
@@ -1,8 +1,8 @@
1
- package <%= Configuration.package %>.repositories;
1
+ package <%= Configuration.package %>.<%= Configuration.repositories_package %>;
2
2
 
3
3
  import java.util.List;
4
4
 
5
- import <%= Configuration.package %>.models.<%= class_name %>;
5
+ import <%= Configuration.full_models_package %>.<%= class_name %>;
6
6
 
7
7
  public interface <%= repository_interface_name %> {
8
8
  /*
@@ -11,7 +11,7 @@ public interface <%= repository_interface_name %> {
11
11
 
12
12
  void create(<%= class_name %> entity);
13
13
 
14
- void update(<%= class_name %> entity);
14
+ <%= class_name %> update(<%= class_name %> entity);
15
15
 
16
16
  void destroy(<%= class_name %> entity);
17
17
 
@@ -0,0 +1,16 @@
1
+ package <%= Configuration.package %>.<%= Configuration.repositories_package %>;
2
+
3
+ import <%= orm_import %>;
4
+
5
+ import br.com.caelum.vraptor.ioc.Component;
6
+ import <%= Configuration.full_models_package %>.<%= class_name %>;
7
+
8
+ @Component
9
+ public class <%= repository_impl_name %>
10
+ extends Repository<<%= class_name %>, Long>
11
+ implements <%= repository_interface_name %> {
12
+
13
+ <%= repository_impl_name %>(<%= orm_class %> <%= orm_parameter_name %>) {
14
+ super(<%= orm_parameter_name %>);
15
+ }
16
+ }
@@ -1,4 +1,4 @@
1
- package <%= Configuration.package %>.repositories;
1
+ package <%= Configuration.package %>.<%= Configuration.repositories_package %>;
2
2
 
3
3
  import static org.junit.Assert.assertNotNull;
4
4
 
@@ -0,0 +1,18 @@
1
+ class FreemarkerGenerator < TemplateEngineGenerator
2
+
3
+ def self.source_root
4
+ File.dirname(__FILE__)
5
+ end
6
+
7
+ def view_folder
8
+ "views"
9
+ end
10
+
11
+ def extension
12
+ "ftl"
13
+ end
14
+
15
+ def path
16
+ "${base}/#{base_path}"
17
+ end
18
+ end
@@ -6,15 +6,15 @@
6
6
 
7
7
  <form action="<%= path %>" method="post">
8
8
 
9
- <#if <%= "#{@model}.id" %>??>
10
- <input type="hidden" name="<%= "#{@model}.id" %>" value="<%= "${#{@model}.id}" %>"/>
9
+ <#if <%= "#{model_parameter_name}.id" %>??>
10
+ <input type="hidden" name="<%= "#{model_parameter_name}.id" %>" value="<%= "${#{model_parameter_name}.id}" %>"/>
11
11
  <input type="hidden" name="_method" value="put"/>
12
12
  </#if>
13
13
 
14
14
  <% @attributes.each do |att| -%>
15
15
  <div class="field">
16
- <%= att.name.capitalize %>:<br />
17
- <%= "<@html.#{att.html_input} \"#{@model}.#{att.name}\" #{@model}.#{att.name}/>" %>
16
+ <%= att.name.camelize %>:<br />
17
+ <%= "<@html.#{att.html_input} \"#{model_parameter_name}.#{att.name}\" #{model_parameter_name}.#{att.name}/>" %>
18
18
  </div>
19
19
  <% end -%>
20
20
  <div class="actions">
@@ -0,0 +1,36 @@
1
+ <body>
2
+ <h1>Listing <%= class_name.pluralize %></h1>
3
+
4
+ <table>
5
+ <tr>
6
+ <% @attributes.each do |att| -%>
7
+ <th><%= att.name.camelize %></th>
8
+ <% end -%>
9
+ <th></th>
10
+ <th></th>
11
+ <th></th>
12
+ </tr>
13
+
14
+ <#list <%= "#{model_parameter_name}List as #{model_parameter_name}" %>>
15
+ <tr>
16
+ <% @attributes.each do |att| -%>
17
+ <td>
18
+ <%= "${#{model_parameter_name}.#{att.name}!\"\"}" unless att.boolean? %>
19
+ <%= "${#{model_parameter_name}.#{att.name}?string}" if att.boolean? %>
20
+ </td>
21
+ <% end -%>
22
+ <td><a href="<%= "#{path}/${#{model_parameter_name}.id}" %>">show</a></td>
23
+ <td><a href="<%= "#{path}/${#{model_parameter_name}.id}/edit" %>">edit</a></td>
24
+ <td>
25
+ <form action="<%= "#{path}/${#{model_parameter_name}.id}" %>" method="post">
26
+ <input type="hidden" name="_method" value="delete"/>
27
+ <button type="submit" onclick="return confirm('Are you sure?')">destroy</button>
28
+ </form>
29
+ </td>
30
+ </tr>
31
+ </#list>
32
+ </table>
33
+
34
+ <br />
35
+ <a href="<%= path %>/new">New <%= class_name %></a>
36
+ </body>
@@ -0,0 +1,14 @@
1
+ <body>
2
+
3
+ <% @attributes.each do |att| -%>
4
+ <p>
5
+ <b><%= att.name.camelize %>:</b>
6
+ <%= "${#{model_parameter_name}.#{att.name}!\"\"}" unless att.boolean? %>
7
+ <%= "${#{model_parameter_name}.#{att.name}?string}" if att.boolean? %>
8
+ </p>
9
+ <% end -%>
10
+
11
+ <a href="<%= "#{path}/${#{model_parameter_name}.id}/edit" %>">Edit</a>
12
+ <a href="<%= path %>">Back</a>
13
+
14
+ </body>
@@ -0,0 +1,18 @@
1
+ class JspGenerator < TemplateEngineGenerator
2
+
3
+ def self.source_root
4
+ File.dirname(__FILE__)
5
+ end
6
+
7
+ def view_folder
8
+ "jsp"
9
+ end
10
+
11
+ def extension
12
+ "jsp"
13
+ end
14
+
15
+ def path url=""
16
+ %Q{${pageContext.request.contextPath}/#{base_path}#{url}}
17
+ end
18
+ end
@@ -6,15 +6,15 @@
6
6
 
7
7
  <form action="<%= path %>" method="post">
8
8
 
9
- <c:if test="${not empty <%= @model %>.id}">
10
- <input type="hidden" name="<%= @model %>.id" value="${<%=@model%>.id}"/>
9
+ <c:if test="${not empty <%= model_parameter_name %>.id}">
10
+ <input type="hidden" name="<%= model_parameter_name %>.id" value="${<%= model_parameter_name%>.id}"/>
11
11
  <input type="hidden" name="_method" value="put"/>
12
12
  </c:if>
13
13
 
14
14
  <% @attributes.each do |att| -%>
15
15
  <div class="field">
16
- <%= att.name.capitalize %>:<br />
17
- <input type="text" name="<%= @model %>.<%=att.name%>" value="${<%=@model%>.<%=att.name%>}"/>
16
+ <%= att.name.camelize %>:<br />
17
+ <input type="text" name="<%= model_parameter_name %>.<%=att.name%>" value="${<%=model_parameter_name%>.<%=att.name%>}"/>
18
18
  </div>
19
19
  <% end -%>
20
20
 
@@ -7,22 +7,22 @@
7
7
  <table>
8
8
  <tr>
9
9
  <%- @attributes.each do |att| -%>
10
- <th><%= att.name %></th>
10
+ <th><%= att.name.camelize %></th>
11
11
  <%- end -%>
12
12
  <th></th>
13
13
  <th></th>
14
14
  <th></th>
15
15
  </tr>
16
16
 
17
- <c:forEach items="${<%=@model%>List}" var="<%=@model%>">
17
+ <c:forEach items="${<%=model_parameter_name%>List}" var="<%=model_parameter_name%>">
18
18
  <tr>
19
19
  <%- @attributes.each do |att| -%>
20
- <td><%= "${#{@model}.#{att.name}}" %></td>
20
+ <td><%= "${#{model_parameter_name}.#{att.name}}" %></td>
21
21
  <%- end -%>
22
- <td><a href="<%= path "/${#{@model}.id}" %>">show</a></td>
23
- <td><a href="<%= path "/${#{@model}.id}/edit" %>">edit</a></td>
22
+ <td><a href="<%= path "/${#{model_parameter_name}.id}" %>">show</a></td>
23
+ <td><a href="<%= path "/${#{model_parameter_name}.id}/edit" %>">edit</a></td>
24
24
  <td>
25
- <form action="<%= path "/${#{@model}.id}" %>" method="post">
25
+ <form action="<%= path "/${#{model_parameter_name}.id}" %>" method="post">
26
26
  <input type="hidden" name="_method" value="delete"/>
27
27
  <button type="submit" onclick="return confirm('Are you sure?')">destroy</button>
28
28
  </form>
@@ -0,0 +1,14 @@
1
+ <head>
2
+ <title><%= class_name %> [show]</title>
3
+ </head>
4
+ <body>
5
+ <%- @attributes.each do |att| -%>
6
+ <p>
7
+ <b><%= att.name.camelize %>:</b>
8
+ <%= "${#{model_parameter_name}.#{att.name}}" %>
9
+ </p>
10
+ <% end -%>
11
+
12
+ <a href="<%= path "/${#{model_parameter_name}.id}/edit" %>">Edit</a>
13
+ <a href="<%= path %>">Back</a>
14
+ </body>
@@ -0,0 +1,21 @@
1
+ class TemplateEngineGenerator < BaseScaffold
2
+
3
+ def build
4
+ create_view("index")
5
+ create_view("show")
6
+ create_view("form")
7
+ create_view("edit")
8
+ create_view("new", "new#{class_name}")
9
+ end
10
+
11
+ def create_view(template_name, file_name=template_name)
12
+ template("templates/#{template_name}.erb", "#{views_path}/#{file_name}.#{extension}")
13
+ end
14
+
15
+ def views_path
16
+ File.join Configuration::WEB_INF, view_folder, model_parameter_name
17
+ end
18
+ end
19
+
20
+ require File.dirname(__FILE__) + "/jsp_generator/jsp_generator"
21
+ require File.dirname(__FILE__) + "/freemarker_generator/freemarker_generator"
@@ -1,22 +1,14 @@
1
- require 'rubygems'
2
-
3
- require 'thor/actions'
4
- require 'thor/group'
5
- require 'active_support/inflector'
6
- require 'yaml'
7
-
8
- require File.dirname(__FILE__) + '/configuration'
9
1
  require File.dirname(__FILE__) + '/generators/base'
10
- require File.dirname(__FILE__) + '/generators/app_generator/app_generator'
11
- require File.dirname(__FILE__) + '/generators/app_generator/dependency'
12
- require File.dirname(__FILE__) + '/generators/app_generator/dependency_manager'
13
- require File.dirname(__FILE__) + '/generators/app_generator/freemarker_template_engine'
14
- require File.dirname(__FILE__) + '/generators/app_generator/jsp_template_engine'
15
- require File.dirname(__FILE__) + '/generators/scaffold_generator/attribute'
16
- require File.dirname(__FILE__) + '/generators/scaffold_generator/scaffold_generator'
17
- require File.dirname(__FILE__) + '/generators/scaffold_generator/base_scaffold'
18
- require File.dirname(__FILE__) + '/generators/scaffold_generator/model_generator/model_generator'
19
- require File.dirname(__FILE__) + '/generators/scaffold_generator/repository_generator/repository_generator'
20
- require File.dirname(__FILE__) + '/generators/scaffold_generator/controller_generator/controller_generator'
21
- require File.dirname(__FILE__) + '/generators/scaffold_generator/freemarker_generator/freemarker_generator'
22
- require File.dirname(__FILE__) + '/generators/scaffold_generator/jsp_generator/jsp_generator'
2
+ require File.dirname(__FILE__) + '/generators/plugin/plugin_generator'
3
+ require File.dirname(__FILE__) + '/generators/app/app_generator'
4
+ require File.dirname(__FILE__) + '/generators/app/dependency'
5
+ require File.dirname(__FILE__) + '/generators/app/dependency_manager'
6
+ require File.dirname(__FILE__) + '/generators/app/freemarker_template_engine'
7
+ require File.dirname(__FILE__) + '/generators/app/jsp_template_engine'
8
+ require File.dirname(__FILE__) + '/generators/scaffold/attribute'
9
+ require File.dirname(__FILE__) + '/generators/scaffold/scaffold_generator'
10
+ require File.dirname(__FILE__) + '/generators/scaffold/base_scaffold'
11
+ require File.dirname(__FILE__) + '/generators/scaffold/model_generator/model_generator'
12
+ require File.dirname(__FILE__) + '/generators/scaffold/repository_generator/repository_generator'
13
+ require File.dirname(__FILE__) + '/generators/scaffold/controller_generator/controller_generator'
14
+ require File.dirname(__FILE__) + '/generators/scaffold/template_engine_generator/template_engine_generator'
@@ -0,0 +1,11 @@
1
+ module VraptorScaffold
2
+ module Runner
3
+ end
4
+ end
5
+
6
+ require 'vraptor-scaffold/runner/help'
7
+ require 'vraptor-scaffold/runner/scaffold'
8
+ require 'vraptor-scaffold/runner/generator'
9
+ require 'vraptor-scaffold/runner/commands_help'
10
+ require 'vraptor-scaffold/runner/plugin'
11
+ require 'vraptor-scaffold/runner/configure'
@@ -0,0 +1,13 @@
1
+ module VraptorScaffold
2
+ module Runner
3
+
4
+ class CommandsHelp
5
+ def run(args)
6
+ Kernel.puts "Available runners for vraptor are: #{VraptorScaffold::COMMANDS.keys.join(', ')}"
7
+ Kernel.puts "Usage:"
8
+ Kernel.puts " vraptor runner"
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module VraptorScaffold
2
+ module Runner
3
+
4
+ class Configure
5
+
6
+ #def run(args)
7
+ # if VraptorScaffold::Runner::Help.help?(args.first) || args.size < 2
8
+ # Kernel.puts "vraptor configure usage:"
9
+ # Kernel.puts "\tvraptor configure PLUGIN_NAME"
10
+ # else
11
+ # plugin_name = args.first
12
+ # require plugin_name
13
+ # puts "Configuring plugin '#{plugin_name}'"
14
+ # plugin = plugin_name.gsub('-','_').camelize.constantize.new(args)
15
+ # plugin.invoke_all
16
+ # plugin
17
+ # end
18
+ #end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ module VraptorScaffold
2
+ module Runner
3
+
4
+ class Generator
5
+ def run(args)
6
+ project_path = args.shift
7
+ if VraptorScaffold::Runner::Help.help? project_path
8
+ AppGenerator.start(["-h"])
9
+ else
10
+ AppGenerator.new(project_path, args).invoke_all
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module VraptorScaffold
2
+ module Runner
3
+
4
+ class Help
5
+
6
+ def self.help?(arg)
7
+ [nil, "-h", "--help"].include?(arg)
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,19 @@
1
+ module VraptorScaffold
2
+ module Runner
3
+
4
+ class Plugin
5
+
6
+ def run(args)
7
+ if VraptorScaffold::Runner::Help.help?(args.first) || args.size < 2
8
+ PluginGenerator.start(["-h"])
9
+ elsif File.exist?("src")
10
+ PluginGenerator.new(args.shift, args).invoke_all
11
+ else
12
+ puts "To run vraptor plugin please go to the project root folder."
13
+ end
14
+ end
15
+ end
16
+
17
+ end
18
+ end
19
+
@@ -0,0 +1,16 @@
1
+ module VraptorScaffold
2
+ module Runner
3
+
4
+ class Scaffold
5
+ def run(args)
6
+ if VraptorScaffold::Runner::Help.help? args.first
7
+ ScaffoldGenerator.start(["-h"])
8
+ elsif File.exist?("src")
9
+ ScaffoldGenerator.new(args).invoke_all
10
+ else
11
+ puts "To run vraptor scaffold please go to the project root folder."
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end