vraptor-scaffold 0.0.1.beta4 → 0.0.1.beta5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/Gemfile +1 -1
  2. data/History.txt +15 -1
  3. data/README.rdoc +38 -11
  4. data/Rakefile +4 -4
  5. data/TODO.txt +11 -7
  6. data/VERSION.yml +1 -1
  7. data/lib/generators/app_generator/app_generator.rb +23 -3
  8. data/lib/generators/app_generator/templates/Entity.java +42 -0
  9. data/lib/generators/app_generator/templates/Repository.java +43 -0
  10. data/lib/generators/app_generator/templates/pom.erb +9 -4
  11. data/lib/generators/app_generator/templates/web.xml +6 -1
  12. data/lib/generators/scaffold_generator/controller_generator/controller_generator.rb +2 -1
  13. data/lib/generators/scaffold_generator/controller_generator/templates/controller.erb +16 -20
  14. data/lib/generators/scaffold_generator/controller_generator/templates/controller_test.erb +12 -0
  15. data/lib/generators/scaffold_generator/freemarker_generator/freemarker_generator.rb +4 -2
  16. data/lib/generators/scaffold_generator/freemarker_generator/templates/edit.erb +3 -0
  17. data/lib/generators/scaffold_generator/freemarker_generator/templates/new.erb +3 -0
  18. data/lib/generators/scaffold_generator/model_generator/model_generator.rb +1 -0
  19. data/lib/generators/scaffold_generator/model_generator/templates/model.erb +2 -17
  20. data/lib/generators/scaffold_generator/model_generator/templates/model_test.erb +13 -0
  21. data/lib/generators/scaffold_generator/repository_generator/repository_generator.rb +15 -0
  22. data/lib/generators/scaffold_generator/repository_generator/templates/repository.erb +14 -0
  23. data/lib/generators/scaffold_generator/repository_generator/templates/repository_test.erb +13 -0
  24. data/lib/generators/scaffold_generator/scaffold_generator.rb +3 -2
  25. data/lib/load_paths.rb +1 -0
  26. data/spec/lib/generators/app_generator/app_generator_spec.rb +26 -1
  27. data/spec/lib/generators/app_generator/templates/pom.xml +9 -4
  28. data/spec/lib/generators/scaffold_generator/controller_generator/controller_generator_spec.rb +4 -0
  29. data/spec/lib/generators/scaffold_generator/controller_generator/templates/ProductController.java +15 -19
  30. data/spec/lib/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb +8 -0
  31. data/spec/lib/generators/scaffold_generator/model_generator/model_generator_spec.rb +3 -0
  32. data/spec/lib/generators/scaffold_generator/model_generator/templates/Product.java +2 -17
  33. data/spec/lib/generators/scaffold_generator/repository_generator/repository_generator_spec.rb +23 -0
  34. data/spec/lib/generators/scaffold_generator/repository_generator/templates/ProductRepository.java +14 -0
  35. data/spec/lib/generators/scaffold_generator/scaffold_generator_spec.rb +13 -4
  36. data/vraptor-scaffold.gemspec +20 -8
  37. metadata +24 -12
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source :rubygems
2
2
 
3
- gem "thor", ">=0.13.8"
3
+ gem "thor", ">=0.14.0"
4
4
  gem "rake", ">=0.8.7"
5
5
  gem "activesupport", ">=3.0.0.beta4"
6
6
 
data/History.txt CHANGED
@@ -1,4 +1,18 @@
1
- === 0.0.1.beta4 / 2010-07-??
1
+ === 0.0.1.beta4 / 2010-07-?
2
+
3
+ == New Features
4
+ * Added generic repository.
5
+ * Scaffold repository to each model.
6
+ * Now controllers use repository instead entity manager.
7
+ * Generated models come with hashCode and equals.
8
+ * Generating fake tests to models, controllers and repositories.
9
+
10
+ == Improvements
11
+ * Better freemarker views.
12
+ * UTF-8 default enconding.
13
+ * Update jetty maven plugin version(6 to 7).
14
+
15
+ === 0.0.1.beta4 / 2010-07-16
2
16
 
3
17
  == New Features
4
18
  * Added validator support with hibernate-validator.
data/README.rdoc CHANGED
@@ -12,8 +12,14 @@ At the command line client:
12
12
  - vraptor scaffold product name:string value:double
13
13
  - vraptor start
14
14
  - Go http://localhost:8080/products
15
+
16
+ == Tests
17
+ At the command line client:
18
+
19
+ - Running: mvn clean test
20
+ - Code coverage: mvn clean cobertura:cobertura
15
21
 
16
- == Werb Server
22
+ == Web Server
17
23
  The default web server is jetty but you can import the project in your favorite ide
18
24
  and run your project with tomcat or jboss as for example.
19
25
 
@@ -29,25 +35,46 @@ When you run vraptor new command will be created a java web application with:
29
35
  - Sitemesh = Decorator
30
36
  - Maven2 = Project Management
31
37
  - jQuery = JavaScript
32
-
33
- Tests will use junit, mockito and dbunit.
38
+ - Junit
39
+ - Mockito
40
+
41
+ == Description of Contents
34
42
 
35
43
  src/main/java/app/controllers
36
- Controllers will be placed here.
44
+ Controllers will be placed here.
45
+
37
46
  src/main/java/app/models
38
- Models will be placed here.
47
+ Models will be placed here.
48
+
49
+ src/main/java/app/repositories
50
+ Repositories will be placed here.
51
+
39
52
  src/main/webapp
40
- Web root folder.
53
+ Web root folder.
54
+
41
55
  src/main/webapp/decorators
42
- Decorators will be placed here.
56
+ Decorators will be placed here.
57
+
43
58
  src/main/webapp/macros
44
- Freemarker macros will be placed here.
59
+ Freemarker macros will be placed here.
60
+
45
61
  src/main/webapp/javascripts
46
- JavaScripts will be placed here.
62
+ JavaScripts will be placed here.
63
+
47
64
  src/main/webapp/stylesheets
48
- CSS will be placed here.
65
+ CSS will be placed here.
66
+
49
67
  src/main/webapp/WEB-INF/views
50
- Views will be placed here. Ex: product/index.ftl
68
+ Views will be placed here. Ex: product/index.ftl
69
+
70
+ src/test/java/app/controllers
71
+ Tests to controllers will be placed here.
72
+
73
+ src/test/java/app/models
74
+ Testes to models will be placed here.
75
+
76
+ src/test/java/app/repositories
77
+ Tests to repositories will be placed here.
51
78
 
52
79
  == Dependencies
53
80
  Ensures that you already have installed:
data/Rakefile CHANGED
@@ -11,12 +11,12 @@ begin
11
11
  gem.homepage = "http://github.com/rodolfoliviero/vraptor-scaffold"
12
12
  gem.authors = ["Rodolfo Liviero"]
13
13
 
14
- gem.add_dependency "thor", ">=0.13.8"
15
- gem.add_dependency "rake", ">=0.8.7"
14
+ gem.add_dependency "thor", ">=0.14.0"
15
+ gem.add_dependency "rake", ">=0.8.7"
16
16
  gem.add_dependency "activesupport", ">=3.0.0.beta4"
17
- gem.add_dependency "bundler", ">=1.0.0.beta.5"
17
+ gem.add_dependency "bundler", ">=1.0.0.rc.2"
18
18
 
19
- gem.post_install_message = "Thank you for installing vraptor-scaffold. Please read http://github.com/rodolfoliviero/vraptor-scaffold/blob/master/README.rdoc for more information."
19
+ gem.post_install_message = "Thank you for installing vraptor-scaffold. Please read http://github.com/rodolfoliviero/vraptor-scaffold/blob/master/README.rdoc for more information."
20
20
  end
21
21
  Jeweler::GemcutterTasks.new
22
22
  rescue LoadError
data/TODO.txt CHANGED
@@ -1,15 +1,19 @@
1
- create others persistence unit(maven profile?)
2
- update jpa to jpa2(hibernate 3.5.?-FINAL)
1
+ unit tests to generated code
3
2
  datetime, date and time support.(jquery-ui?)
4
3
  relationship support(many-to-one, one-to-many, many-to-many)
5
- active record is possible?
4
+
5
+ gem description
6
6
  generators help
7
7
  usage file to each generator
8
- gem description
9
- http://waffle.codehaus.org
8
+ create others persistence unit(maven profile?)
9
+ update jpa to jpa2(hibernate 3.5.?-FINAL)
10
+
10
11
  put all html input in macros
11
12
  i18n messages
12
- xstream
13
- context.xml
14
13
  it works on windowns?
15
14
  hibernate joda-time support
15
+ top leval package
16
+ scaml support
17
+ jetty goal
18
+ support to change default encondig when create new app like --enconding=ISO-8859-1
19
+ cuke for duke
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :minor: 0
3
3
  :patch: 1
4
- :build: beta4
4
+ :build: beta5
5
5
  :major: 0
@@ -12,14 +12,21 @@ class AppGenerator < VraptorScaffold::Base
12
12
  create_main_java
13
13
  create_main_resources
14
14
  create_webapp
15
- empty_directory "src/test/java"
16
- empty_directory "src/test/resources"
15
+ create_test
17
16
  end
18
17
 
19
18
  private
20
19
  def create_pom
21
20
  template("templates/pom.erb", "pom.xml")
22
21
  end
22
+
23
+ def create_test
24
+ empty_directory "src/test/java"
25
+ empty_directory "src/test/java/app"
26
+ empty_directory "src/test/java/app/controllers"
27
+ empty_directory "src/test/java/app/models"
28
+ empty_directory "src/test/resources"
29
+ end
23
30
 
24
31
  def create_main_java
25
32
  main_java = "src/main/java"
@@ -33,17 +40,30 @@ class AppGenerator < VraptorScaffold::Base
33
40
  empty_directory "app"
34
41
  inside "app" do
35
42
  empty_directory "controllers"
36
- empty_directory "models"
43
+ create_app_models
37
44
  create_app_infra
45
+ create_app_repository
38
46
  end
39
47
  end
40
48
 
49
+ def create_app_models
50
+ models_path = empty_directory "models"
51
+ template = "Entity.java"
52
+ template_from_root(template, "#{models_path}/#{template}")
53
+ end
54
+
41
55
  def create_app_infra
42
56
  infra_path = empty_directory "infrastructure"
43
57
  template = "FreemarkerPathResolver.java"
44
58
  template_from_root(template, "#{infra_path}/#{template}")
45
59
  end
46
60
 
61
+ def create_app_repository
62
+ repository_path = empty_directory "repositories"
63
+ template = "Repository.java"
64
+ template_from_root(template, "#{repository_path}/#{template}")
65
+ end
66
+
47
67
  def create_main_resources
48
68
  main_resources = "src/main/resources"
49
69
  empty_directory main_resources
@@ -0,0 +1,42 @@
1
+ package app.models;
2
+
3
+ import javax.persistence.GeneratedValue;
4
+ import javax.persistence.Id;
5
+ import javax.persistence.MappedSuperclass;
6
+
7
+ @MappedSuperclass
8
+ public class Entity {
9
+
10
+ @Id @GeneratedValue
11
+ protected Long id;
12
+
13
+ public void setId(Long id) {
14
+ this.id = id;
15
+ }
16
+
17
+ public Long getId() {
18
+ return id;
19
+ }
20
+
21
+ @Override
22
+ public boolean equals(Object obj) {
23
+ if (obj == null) {
24
+ return false;
25
+ }
26
+ if (getClass() != obj.getClass()) {
27
+ return false;
28
+ }
29
+ final Entity other = (Entity) obj;
30
+ if (id != other.id && (id == null || !id.equals(other.id))) {
31
+ return false;
32
+ }
33
+ return true;
34
+ }
35
+
36
+ @Override
37
+ public int hashCode() {
38
+ int hash = 7;
39
+ hash = 17 * hash + (this.getId() != null ? this.getId().hashCode() : 0);
40
+ return hash;
41
+ }
42
+ }
@@ -0,0 +1,43 @@
1
+ package app.repositories;
2
+
3
+ import java.io.Serializable;
4
+ import java.lang.reflect.ParameterizedType;
5
+ import java.util.List;
6
+
7
+ import javax.persistence.EntityManager;
8
+
9
+ public abstract class Repository<T> {
10
+
11
+ protected final EntityManager entityManager;
12
+
13
+ public Repository(EntityManager entityManager) {
14
+ this.entityManager = entityManager;
15
+ }
16
+
17
+ public void create(Object entity) {
18
+ entityManager.persist(entity);
19
+ }
20
+
21
+ public void update(Object entity) {
22
+ entityManager.merge(entity);
23
+ }
24
+
25
+ public void destroy(Object entity) {
26
+ entityManager.remove(entity);
27
+ }
28
+
29
+ public T find(Serializable id) {
30
+ return (T) entityManager.find(getParameterizedClass(), id);
31
+ }
32
+
33
+ @SuppressWarnings("unchecked")
34
+ public List<T> findAll() {
35
+ return entityManager.createQuery("From " + getParameterizedClass().getName()).getResultList();
36
+ }
37
+
38
+ @SuppressWarnings("unchecked")
39
+ private Class<T> getParameterizedClass() {
40
+ ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
41
+ return (Class<T>) parameterizedType.getActualTypeArguments()[0];
42
+ }
43
+ }
@@ -6,7 +6,11 @@
6
6
  <packaging>war</packaging>
7
7
  <version>0.0.1-SNAPSHOT</version>
8
8
  <name><%= @project_name %></name>
9
-
9
+
10
+ <properties>
11
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12
+ </properties>
13
+
10
14
  <build>
11
15
  <plugins>
12
16
  <plugin>
@@ -15,6 +19,7 @@
15
19
  <configuration>
16
20
  <source>1.6</source>
17
21
  <target>1.6</target>
22
+ <encoding>UTF-8</encoding>
18
23
  </configuration>
19
24
  </plugin>
20
25
  <plugin>
@@ -32,12 +37,12 @@
32
37
  </plugin>
33
38
  <plugin>
34
39
  <groupId>org.mortbay.jetty</groupId>
35
- <artifactId>maven-jetty-plugin</artifactId>
40
+ <artifactId>jetty-maven-plugin</artifactId>
41
+ <version>7.1.6.v20100715</version>
36
42
  <configuration>
37
- <scanIntervalSeconds>5</scanIntervalSeconds>
43
+ <scanIntervalSeconds>3</scanIntervalSeconds>
38
44
  <stopKey>foo</stopKey>
39
45
  <stopPort>9999</stopPort>
40
- <contextPath>/</contextPath>
41
46
  </configuration>
42
47
  </plugin>
43
48
  </plugins>
@@ -11,6 +11,11 @@
11
11
  <param-value>br.com.caelum.vraptor.util.jpa.JPACustomProvider</param-value>
12
12
  </context-param>
13
13
 
14
+ <context-param>
15
+ <param-name>br.com.caelum.vraptor.encoding</param-name>
16
+ <param-value>UTF-8</param-value>
17
+ </context-param>
18
+
14
19
  <filter>
15
20
  <filter-name>sitemesh</filter-name>
16
21
  <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
@@ -40,7 +45,7 @@
40
45
  </init-param>
41
46
  <init-param>
42
47
  <param-name>default_encoding</param-name>
43
- <param-value>ISO-8859-1</param-value>
48
+ <param-value>UTF-8</param-value>
44
49
  </init-param>
45
50
  <init-param>
46
51
  <param-name>auto_import</param-name>
@@ -6,10 +6,11 @@ class ControllerGenerator < BaseScaffold
6
6
 
7
7
  def build
8
8
  template("templates/controller.erb", "src/main/java/app/controllers/#{controller_class_name}.java")
9
+ template("templates/controller_test.erb", "src/test/java/app/controllers/#{controller_class_name}Test.java")
9
10
  end
10
11
 
11
12
  def controller_class_name
12
- "#{@model.capitalize}Controller"
13
+ "#{class_name}Controller"
13
14
  end
14
15
 
15
16
  def path
@@ -2,9 +2,8 @@ package app.controllers;
2
2
 
3
3
  import java.util.List;
4
4
 
5
- import javax.persistence.EntityManager;
6
-
7
5
  import app.models.<%= class_name %>;
6
+ import app.repositories.<%= class_name %>Repository;
8
7
  import br.com.caelum.vraptor.Delete;
9
8
  import br.com.caelum.vraptor.Get;
10
9
  import br.com.caelum.vraptor.Path;
@@ -18,65 +17,62 @@ import br.com.caelum.vraptor.Validator;
18
17
  public class <%= controller_class_name %> {
19
18
 
20
19
  private final Result result;
21
- private final EntityManager entityManager;
20
+ private final <%= class_name %>Repository repository;
22
21
  private final Validator validator;
23
22
 
24
- public <%= controller_class_name %>(Result result, EntityManager entityManager, Validator validator) {
25
- this.entityManager = entityManager;
23
+ public <%= controller_class_name %>(Result result, <%= class_name %>Repository repository, Validator validator) {
26
24
  this.result = result;
25
+ this.repository = repository;
27
26
  this.validator = validator;
28
27
  }
29
28
 
30
29
  @Get
31
30
  @Path("<%= path %>")
32
31
  public List<<%= class_name %>> index() {
33
- return entityManager.createQuery("from <%= class_name %>").getResultList();
32
+ return repository.findAll();
34
33
  }
35
34
 
36
35
  @Post
37
36
  @Path("<%= path %>")
38
37
  public void create(<%= class_name %> <%= @model %>) {
39
38
  validator.validate(<%= @model %>);
40
- validator.onErrorForwardTo(this).form(<%= @model %>);
41
- entityManager.persist(<%= @model %>);
39
+ validator.onErrorUsePageOf(this).new<%= class_name %>();
40
+ repository.create(<%= @model %>);
42
41
  result.redirectTo(this).index();
43
42
  }
44
43
 
45
44
  @Get
46
45
  @Path("<%= "#{path}/new" %>")
47
- public void new<%= class_name %>() {
48
- result.forwardTo(this).form(new <%= class_name %>());
46
+ public <%= class_name %> new<%= class_name %>() {
47
+ return new <%= class_name %>();
49
48
  }
50
49
 
51
50
  @Put
52
51
  @Path("<%= path %>")
53
52
  public void update(<%= class_name %> <%= @model %>) {
54
53
  validator.validate(<%= @model %>);
55
- validator.onErrorForwardTo(this).form(<%= @model %>);
56
- entityManager.merge(<%= @model %>);
54
+ validator.onErrorUsePageOf(this).edit(<%= @model %>);
55
+ repository.update(<%= @model %>);
57
56
  result.redirectTo(this).index();
58
57
  }
59
58
 
60
59
  @Get
61
60
  @Path("<%= "#{path}/{#{@model}.id}/edit" %>")
62
- public void edit(<%= @model.capitalize %> <%= @model %>) {
63
- result.forwardTo(this).form(entityManager.find(<%= @model.capitalize %>.class, <%= @model %>.getId()));
61
+ public <%= class_name %> edit(<%= class_name %> <%= @model %>) {
62
+ return repository.find(<%= @model %>.getId());
64
63
  }
65
64
 
66
65
  @Get
67
66
  @Path("<%= "#{path}/{#{@model}.id}/show" %>")
68
- public <%= class_name %> show(<%= @model.capitalize %> <%= @model %>) {
69
- return entityManager.find(<%= @model.capitalize %>.class, <%= @model %>.getId());
67
+ public <%= class_name %> show(<%= class_name %> <%= @model %>) {
68
+ return repository.find(<%= @model %>.getId());
70
69
  }
71
70
 
72
71
  @Delete
73
72
  @Path("<%= path %>")
74
73
  public void destroy(<%= class_name %> <%= @model %>) {
75
- entityManager.remove(entityManager.find(<%= class_name %>.class, <%= @model %>.getId()));
74
+ repository.destroy(repository.find(<%= @model %>.getId()));
76
75
  result.redirectTo(this).index();
77
76
  }
78
77
 
79
- public <%= class_name %> form(<%= class_name %> <%= @model %>) {
80
- return <%= @model %>;
81
- }
82
78
  }
@@ -0,0 +1,12 @@
1
+ package app.controllers;
2
+
3
+ import static org.junit.Assert.assertNotNull;
4
+
5
+ import org.junit.Test;
6
+
7
+ public class <%= controller_class_name %>Test {
8
+
9
+ @Test public void fakeTest() {
10
+ assertNotNull("put something real.", new <%= controller_class_name %>(null, null, null));
11
+ }
12
+ }
@@ -8,10 +8,12 @@ class FreemarkerGenerator < BaseScaffold
8
8
  create_view("index")
9
9
  create_view("show")
10
10
  create_view("form")
11
+ create_view("edit")
12
+ create_view("new", "new#{class_name}")
11
13
  end
12
14
 
13
- def create_view(name)
14
- template("templates/#{name}.erb", "src/main/webapp/WEB-INF/views/#{@model}/#{name}.ftl")
15
+ def create_view(template_name, file_name=template_name)
16
+ template("templates/#{template_name}.erb", "src/main/webapp/WEB-INF/views/#{@model}/#{file_name}.ftl")
15
17
  end
16
18
 
17
19
  def path
@@ -0,0 +1,3 @@
1
+ <body>
2
+ <#include "form.ftl">
3
+ </body>
@@ -0,0 +1,3 @@
1
+ <body>
2
+ <#include "form.ftl">
3
+ </body>
@@ -6,5 +6,6 @@ class ModelGenerator < BaseScaffold
6
6
 
7
7
  def build
8
8
  template("templates/model.erb", "src/main/java/app/models/#{class_name}.java")
9
+ template("templates/model_test.erb", "src/test/java/app/models/#{class_name}Test.java")
9
10
  end
10
11
  end
@@ -1,26 +1,11 @@
1
1
  package app.models;
2
2
 
3
- import javax.persistence.Entity;
4
- import javax.persistence.GeneratedValue;
5
- import javax.persistence.Id;
6
-
7
- @Entity
8
- public class <%= class_name %> {
9
-
10
- @Id @GeneratedValue
11
- private Long id;
3
+ @javax.persistence.Entity
4
+ public class <%= class_name %> extends Entity {
12
5
 
13
6
  <% @attributes.each do |att| -%>
14
7
  private <%= att.type %> <%= att.name %>;
15
8
  <% end -%>
16
-
17
- public void setId(Long id) {
18
- this.id = id;
19
- }
20
-
21
- public Long getId() {
22
- return id;
23
- }
24
9
 
25
10
  <% @attributes.each do |att| -%>
26
11
  public void set<%= att.name.capitalize %>(<%= att.type %> <%= att.name %>) {
@@ -0,0 +1,13 @@
1
+ package app.models;
2
+
3
+ import static org.junit.Assert.assertNotNull;
4
+
5
+ import org.junit.Test;
6
+
7
+ public class <%= class_name %>Test {
8
+
9
+ @Test public void fakeTest() {
10
+ assertNotNull("put something real.", new <%= class_name %>());
11
+ }
12
+ }
13
+
@@ -0,0 +1,15 @@
1
+ class RepositoryGenerator < BaseScaffold
2
+
3
+ def self.source_root
4
+ File.dirname(__FILE__)
5
+ end
6
+
7
+ def build
8
+ template("templates/repository.erb", "src/main/java/app/repositories/#{class_name}Repository.java")
9
+ template("templates/repository_test.erb", "src/test/java/app/repositories/#{repository_class_name}Test.java")
10
+ end
11
+
12
+ def repository_class_name
13
+ "#{class_name}Repository"
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ package app.repositories;
2
+
3
+ import javax.persistence.EntityManager;
4
+
5
+ import br.com.caelum.vraptor.ioc.Component;
6
+ import app.models.<%= class_name %>;
7
+
8
+ @Component
9
+ public class <%= repository_class_name %> extends Repository<<%= class_name %>> {
10
+
11
+ public <%= repository_class_name %>(EntityManager entityManager) {
12
+ super(entityManager);
13
+ }
14
+ }
@@ -0,0 +1,13 @@
1
+ package app.repositories;
2
+
3
+ import static org.junit.Assert.assertNotNull;
4
+
5
+ import org.junit.Test;
6
+
7
+ public class <%= repository_class_name %>Test {
8
+
9
+ @Test public void fakeTest() {
10
+ assertNotNull("put something real.", new <%= repository_class_name %>(null));
11
+ }
12
+ }
13
+
@@ -10,8 +10,9 @@ class ScaffoldGenerator
10
10
 
11
11
  def build
12
12
  ModelGenerator.new(model, attributes).build
13
- ControllerGenerator.new(model, @attributes).build
14
- FreemarkerGenerator.new(model, @attributes).build
13
+ RepositoryGenerator.new(model, attributes).build
14
+ ControllerGenerator.new(model, attributes).build
15
+ FreemarkerGenerator.new(model, attributes).build
15
16
  end
16
17
 
17
18
  private
data/lib/load_paths.rb CHANGED
@@ -10,6 +10,7 @@ require File.dirname(__FILE__) + '/../lib/generators/base'
10
10
  require File.dirname(__FILE__) + '/../lib/generators/scaffold_generator/scaffold_generator'
11
11
  require File.dirname(__FILE__) + '/../lib/generators/scaffold_generator/base_scaffold'
12
12
  require File.dirname(__FILE__) + '/../lib/generators/scaffold_generator/model_generator/model_generator'
13
+ require File.dirname(__FILE__) + '/../lib/generators/scaffold_generator/repository_generator/repository_generator'
13
14
  require File.dirname(__FILE__) + '/../lib/generators/scaffold_generator/controller_generator/controller_generator'
14
15
  require File.dirname(__FILE__) + '/../lib/generators/scaffold_generator/freemarker_generator/freemarker_generator'
15
16
  require File.dirname(__FILE__) + '/../lib/generators/app_generator/app_generator'
@@ -8,7 +8,7 @@ describe AppGenerator do
8
8
  end
9
9
 
10
10
  after(:all) do
11
- FileUtils.remove_dir(@project_path)
11
+ FileUtils.remove_dir("src")
12
12
  end
13
13
 
14
14
  context "build new application" do
@@ -44,6 +44,12 @@ describe AppGenerator do
44
44
  File.exist?("#{@app}/models").should be_true
45
45
  end
46
46
 
47
+ it "should create generic entity" do
48
+ from = "#{AppGenerator.source_root}/templates/Entity.java"
49
+ to = "#{@app}/models/Entity.java"
50
+ FileUtils.compare_file(from, to).should be_true
51
+ end
52
+
47
53
  it "should create infrastructure folder" do
48
54
  File.exist?("#{@app}/infrastructure").should be_true
49
55
  end
@@ -53,6 +59,12 @@ describe AppGenerator do
53
59
  to = "#{@app}/infrastructure/FreemarkerPathResolver.java"
54
60
  FileUtils.compare_file(from, to).should be_true
55
61
  end
62
+
63
+ it "should create generic repository" do
64
+ from = "#{AppGenerator.source_root}/templates/Repository.java"
65
+ to = "#{@app}/repositories/Repository.java"
66
+ FileUtils.compare_file(from, to).should be_true
67
+ end
56
68
  end
57
69
 
58
70
  context "creating main resources" do
@@ -156,12 +168,25 @@ describe AppGenerator do
156
168
  before(:all) do
157
169
  @test_java = "#{@project_path}/src/test/java"
158
170
  @test_resource = "#{@project_path}/src/test/java"
171
+ @app = "#{@test_java}/app"
159
172
  end
160
173
 
161
174
  it "should create test source folder" do
162
175
  File.exist?(@test_java).should be_true
163
176
  end
164
177
 
178
+ it "should create app folder" do
179
+ File.exist?(@app).should be_true
180
+ end
181
+
182
+ it "should create controllers folder" do
183
+ File.exist?("#{@app}/controllers").should be_true
184
+ end
185
+
186
+ it "should create models folder" do
187
+ File.exist?("#{@app}/models").should be_true
188
+ end
189
+
165
190
  it "should create test resource folder" do
166
191
  File.exist?(@test_resource).should be_true
167
192
  end
@@ -6,7 +6,11 @@
6
6
  <packaging>war</packaging>
7
7
  <version>0.0.1-SNAPSHOT</version>
8
8
  <name>vraptor-scaffold</name>
9
-
9
+
10
+ <properties>
11
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12
+ </properties>
13
+
10
14
  <build>
11
15
  <plugins>
12
16
  <plugin>
@@ -15,6 +19,7 @@
15
19
  <configuration>
16
20
  <source>1.6</source>
17
21
  <target>1.6</target>
22
+ <encoding>UTF-8</encoding>
18
23
  </configuration>
19
24
  </plugin>
20
25
  <plugin>
@@ -32,12 +37,12 @@
32
37
  </plugin>
33
38
  <plugin>
34
39
  <groupId>org.mortbay.jetty</groupId>
35
- <artifactId>maven-jetty-plugin</artifactId>
40
+ <artifactId>jetty-maven-plugin</artifactId>
41
+ <version>7.1.6.v20100715</version>
36
42
  <configuration>
37
- <scanIntervalSeconds>5</scanIntervalSeconds>
43
+ <scanIntervalSeconds>3</scanIntervalSeconds>
38
44
  <stopKey>foo</stopKey>
39
45
  <stopPort>9999</stopPort>
40
- <contextPath>/</contextPath>
41
46
  </configuration>
42
47
  </plugin>
43
48
  </plugins>
@@ -17,4 +17,8 @@ describe ControllerGenerator do
17
17
  FileUtils.compare_file(from, to).should be_true
18
18
  end
19
19
 
20
+ it "should create controller test" do
21
+ File.exist?("src/test/java/app/controllers/ProductControllerTest.java").should be_true
22
+ end
23
+
20
24
  end
@@ -2,9 +2,8 @@ package app.controllers;
2
2
 
3
3
  import java.util.List;
4
4
 
5
- import javax.persistence.EntityManager;
6
-
7
5
  import app.models.Product;
6
+ import app.repositories.ProductRepository;
8
7
  import br.com.caelum.vraptor.Delete;
9
8
  import br.com.caelum.vraptor.Get;
10
9
  import br.com.caelum.vraptor.Path;
@@ -18,65 +17,62 @@ import br.com.caelum.vraptor.Validator;
18
17
  public class ProductController {
19
18
 
20
19
  private final Result result;
21
- private final EntityManager entityManager;
20
+ private final ProductRepository repository;
22
21
  private final Validator validator;
23
22
 
24
- public ProductController(Result result, EntityManager entityManager, Validator validator) {
25
- this.entityManager = entityManager;
23
+ public ProductController(Result result, ProductRepository repository, Validator validator) {
26
24
  this.result = result;
25
+ this.repository = repository;
27
26
  this.validator = validator;
28
27
  }
29
28
 
30
29
  @Get
31
30
  @Path("/products")
32
31
  public List<Product> index() {
33
- return entityManager.createQuery("from Product").getResultList();
32
+ return repository.findAll();
34
33
  }
35
34
 
36
35
  @Post
37
36
  @Path("/products")
38
37
  public void create(Product product) {
39
38
  validator.validate(product);
40
- validator.onErrorForwardTo(this).form(product);
41
- entityManager.persist(product);
39
+ validator.onErrorUsePageOf(this).newProduct();
40
+ repository.create(product);
42
41
  result.redirectTo(this).index();
43
42
  }
44
43
 
45
44
  @Get
46
45
  @Path("/products/new")
47
- public void newProduct() {
48
- result.forwardTo(this).form(new Product());
46
+ public Product newProduct() {
47
+ return new Product();
49
48
  }
50
49
 
51
50
  @Put
52
51
  @Path("/products")
53
52
  public void update(Product product) {
54
53
  validator.validate(product);
55
- validator.onErrorForwardTo(this).form(product);
56
- entityManager.merge(product);
54
+ validator.onErrorUsePageOf(this).edit(product);
55
+ repository.update(product);
57
56
  result.redirectTo(this).index();
58
57
  }
59
58
 
60
59
  @Get
61
60
  @Path("/products/{product.id}/edit")
62
- public void edit(Product product) {
63
- result.forwardTo(this).form(entityManager.find(Product.class, product.getId()));
61
+ public Product edit(Product product) {
62
+ return repository.find(product.getId());
64
63
  }
65
64
 
66
65
  @Get
67
66
  @Path("/products/{product.id}/show")
68
67
  public Product show(Product product) {
69
- return entityManager.find(Product.class, product.getId());
68
+ return repository.find(product.getId());
70
69
  }
71
70
 
72
71
  @Delete
73
72
  @Path("/products")
74
73
  public void destroy(Product product) {
75
- entityManager.remove(entityManager.find(Product.class, product.getId()));
74
+ repository.destroy(repository.find(product.getId()));
76
75
  result.redirectTo(this).index();
77
76
  }
78
77
 
79
- public Product form(Product product) {
80
- return product;
81
- }
82
78
  }
@@ -23,4 +23,12 @@ describe FreemarkerGenerator do
23
23
  File.exist?("src/main/webapp/WEB-INF/views/product/form.ftl").should be_true
24
24
  end
25
25
 
26
+ it "should create new view" do
27
+ File.exist?("src/main/webapp/WEB-INF/views/product/newProduct.ftl").should be_true
28
+ end
29
+
30
+ it "should create edit view" do
31
+ File.exist?("src/main/webapp/WEB-INF/views/product/edit.ftl").should be_true
32
+ end
33
+
26
34
  end
@@ -17,4 +17,7 @@ describe ModelGenerator do
17
17
  FileUtils.compare_file(from, to).should be_true
18
18
  end
19
19
 
20
+ it "should create model test" do
21
+ File.exist?("src/test/java/app/models/ProductTest.java").should be_true
22
+ end
20
23
  end
@@ -1,25 +1,10 @@
1
1
  package app.models;
2
2
 
3
- import javax.persistence.Entity;
4
- import javax.persistence.GeneratedValue;
5
- import javax.persistence.Id;
6
-
7
- @Entity
8
- public class Product {
9
-
10
- @Id @GeneratedValue
11
- private Long id;
3
+ @javax.persistence.Entity
4
+ public class Product extends Entity {
12
5
 
13
6
  private String name;
14
7
  private boolean flag;
15
-
16
- public void setId(Long id) {
17
- this.id = id;
18
- }
19
-
20
- public Long getId() {
21
- return id;
22
- }
23
8
 
24
9
  public void setName(String name) {
25
10
  this.name = name;
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
2
+
3
+ describe RepositoryGenerator do
4
+
5
+ before(:each) do
6
+ @generator = RepositoryGenerator.new("product", build_attributes)
7
+ @generator.build
8
+ end
9
+
10
+ after(:each) do
11
+ FileUtils.remove_dir("src")
12
+ end
13
+
14
+ it "should create repository" do
15
+ from = File.expand_path(File.dirname(__FILE__) + "/templates/ProductRepository.java")
16
+ to = "src/main/java/app/repositories/ProductRepository.java"
17
+ FileUtils.compare_file(from, to).should be_true
18
+ end
19
+
20
+ it "should create repository" do
21
+ File.exist?("src/test/java/app/repositories/ProductRepositoryTest.java").should be_true
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ package app.repositories;
2
+
3
+ import javax.persistence.EntityManager;
4
+
5
+ import br.com.caelum.vraptor.ioc.Component;
6
+ import app.models.Product;
7
+
8
+ @Component
9
+ public class ProductRepository extends Repository<Product> {
10
+
11
+ public ProductRepository(EntityManager entityManager) {
12
+ super(entityManager);
13
+ }
14
+ }
@@ -29,16 +29,20 @@ describe ScaffoldGenerator do
29
29
 
30
30
  @model_generator = mock(ModelGenerator)
31
31
  ModelGenerator.stub!(:new).with(@generator.model, @generator.attributes).and_return(@model_generator)
32
-
32
+
33
+ @repository_generator = mock(RepositoryGenerator)
34
+ RepositoryGenerator.stub!(:new).with(@generator.model, @generator.attributes).and_return(@repository_generator)
35
+
33
36
  @controller_generator = mock(ControllerGenerator)
34
37
  ControllerGenerator.stub!(:new).with(@generator.model, @generator.attributes).and_return(@controller_generator)
35
38
 
36
39
  @freemarker_generator = mock(FreemarkerGenerator)
37
40
  FreemarkerGenerator.stub!(:new).with(@generator.model, @generator.attributes).and_return(@freemarker_generator)
38
41
 
39
- @model_generator.stub!(:build)
40
- @controller_generator.stub!(:build)
41
- @freemarker_generator.stub!(:build)
42
+ @model_generator.stub!(:build)
43
+ @repository_generator.stub!(:build)
44
+ @controller_generator.stub!(:build)
45
+ @freemarker_generator.stub!(:build)
42
46
  end
43
47
 
44
48
  it "should call model generator" do
@@ -55,5 +59,10 @@ describe ScaffoldGenerator do
55
59
  @freemarker_generator.should_receive(:build)
56
60
  @generator.build
57
61
  end
62
+
63
+ it "should call repository generator" do
64
+ @repository_generator.should_receive(:build)
65
+ @generator.build
66
+ end
58
67
  end
59
68
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{vraptor-scaffold}
8
- s.version = "0.0.1.beta4"
8
+ s.version = "0.0.1.beta5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rodolfo Liviero"]
12
- s.date = %q{2010-07-18}
12
+ s.date = %q{2010-08-04}
13
13
  s.default_executable = %q{vraptor}
14
14
  s.description = %q{}
15
15
  s.email = %q{rodolfoliviero@gmail.com}
@@ -30,7 +30,9 @@ Gem::Specification.new do |s|
30
30
  "VERSION.yml",
31
31
  "bin/vraptor",
32
32
  "lib/generators/app_generator/app_generator.rb",
33
+ "lib/generators/app_generator/templates/Entity.java",
33
34
  "lib/generators/app_generator/templates/FreemarkerPathResolver.java",
35
+ "lib/generators/app_generator/templates/Repository.java",
34
36
  "lib/generators/app_generator/templates/decorators.xml",
35
37
  "lib/generators/app_generator/templates/index.jsp",
36
38
  "lib/generators/app_generator/templates/javascripts/jquery-1.4.2.min.js",
@@ -47,12 +49,19 @@ Gem::Specification.new do |s|
47
49
  "lib/generators/scaffold_generator/base_scaffold.rb",
48
50
  "lib/generators/scaffold_generator/controller_generator/controller_generator.rb",
49
51
  "lib/generators/scaffold_generator/controller_generator/templates/controller.erb",
52
+ "lib/generators/scaffold_generator/controller_generator/templates/controller_test.erb",
50
53
  "lib/generators/scaffold_generator/freemarker_generator/freemarker_generator.rb",
54
+ "lib/generators/scaffold_generator/freemarker_generator/templates/edit.erb",
51
55
  "lib/generators/scaffold_generator/freemarker_generator/templates/form.erb",
52
56
  "lib/generators/scaffold_generator/freemarker_generator/templates/index.erb",
57
+ "lib/generators/scaffold_generator/freemarker_generator/templates/new.erb",
53
58
  "lib/generators/scaffold_generator/freemarker_generator/templates/show.erb",
54
59
  "lib/generators/scaffold_generator/model_generator/model_generator.rb",
55
60
  "lib/generators/scaffold_generator/model_generator/templates/model.erb",
61
+ "lib/generators/scaffold_generator/model_generator/templates/model_test.erb",
62
+ "lib/generators/scaffold_generator/repository_generator/repository_generator.rb",
63
+ "lib/generators/scaffold_generator/repository_generator/templates/repository.erb",
64
+ "lib/generators/scaffold_generator/repository_generator/templates/repository_test.erb",
56
65
  "lib/generators/scaffold_generator/scaffold_generator.rb",
57
66
  "lib/load_paths.rb",
58
67
  "lib/vraptor-scaffold.rb",
@@ -64,6 +73,8 @@ Gem::Specification.new do |s|
64
73
  "spec/lib/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb",
65
74
  "spec/lib/generators/scaffold_generator/model_generator/model_generator_spec.rb",
66
75
  "spec/lib/generators/scaffold_generator/model_generator/templates/Product.java",
76
+ "spec/lib/generators/scaffold_generator/repository_generator/repository_generator_spec.rb",
77
+ "spec/lib/generators/scaffold_generator/repository_generator/templates/ProductRepository.java",
67
78
  "spec/lib/generators/scaffold_generator/scaffold_generator_spec.rb",
68
79
  "spec/lib/vraptor-scaffold_spec.rb",
69
80
  "spec/spec.opts",
@@ -80,6 +91,7 @@ Gem::Specification.new do |s|
80
91
  "spec/lib/vraptor-scaffold_spec.rb",
81
92
  "spec/lib/generators/app_generator/app_generator_spec.rb",
82
93
  "spec/lib/generators/scaffold_generator/controller_generator/controller_generator_spec.rb",
94
+ "spec/lib/generators/scaffold_generator/repository_generator/repository_generator_spec.rb",
83
95
  "spec/lib/generators/scaffold_generator/scaffold_generator_spec.rb",
84
96
  "spec/lib/generators/scaffold_generator/model_generator/model_generator_spec.rb",
85
97
  "spec/lib/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb",
@@ -92,21 +104,21 @@ Gem::Specification.new do |s|
92
104
  s.specification_version = 3
93
105
 
94
106
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
95
- s.add_runtime_dependency(%q<thor>, [">= 0.13.8"])
107
+ s.add_runtime_dependency(%q<thor>, [">= 0.14.0"])
96
108
  s.add_runtime_dependency(%q<rake>, [">= 0.8.7"])
97
109
  s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0.beta4"])
98
- s.add_runtime_dependency(%q<bundler>, [">= 1.0.0.beta.5"])
110
+ s.add_runtime_dependency(%q<bundler>, [">= 1.0.0.rc.2"])
99
111
  else
100
- s.add_dependency(%q<thor>, [">= 0.13.8"])
112
+ s.add_dependency(%q<thor>, [">= 0.14.0"])
101
113
  s.add_dependency(%q<rake>, [">= 0.8.7"])
102
114
  s.add_dependency(%q<activesupport>, [">= 3.0.0.beta4"])
103
- s.add_dependency(%q<bundler>, [">= 1.0.0.beta.5"])
115
+ s.add_dependency(%q<bundler>, [">= 1.0.0.rc.2"])
104
116
  end
105
117
  else
106
- s.add_dependency(%q<thor>, [">= 0.13.8"])
118
+ s.add_dependency(%q<thor>, [">= 0.14.0"])
107
119
  s.add_dependency(%q<rake>, [">= 0.8.7"])
108
120
  s.add_dependency(%q<activesupport>, [">= 3.0.0.beta4"])
109
- s.add_dependency(%q<bundler>, [">= 1.0.0.beta.5"])
121
+ s.add_dependency(%q<bundler>, [">= 1.0.0.rc.2"])
110
122
  end
111
123
  end
112
124
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vraptor-scaffold
3
3
  version: !ruby/object:Gem::Version
4
- hash: 299253580
4
+ hash: 299253581
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
9
  - 1
10
- - beta4
11
- version: 0.0.1.beta4
10
+ - beta5
11
+ version: 0.0.1.beta5
12
12
  platform: ruby
13
13
  authors:
14
14
  - Rodolfo Liviero
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-07-18 00:00:00 -03:00
19
+ date: 2010-08-04 00:00:00 -03:00
20
20
  default_executable: vraptor
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,12 +27,12 @@ dependencies:
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- hash: 59
30
+ hash: 39
31
31
  segments:
32
32
  - 0
33
- - 13
34
- - 8
35
- version: 0.13.8
33
+ - 14
34
+ - 0
35
+ version: 0.14.0
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
@@ -76,14 +76,14 @@ dependencies:
76
76
  requirements:
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- hash: 62196361
79
+ hash: 15424049
80
80
  segments:
81
81
  - 1
82
82
  - 0
83
83
  - 0
84
- - beta
85
- - 5
86
- version: 1.0.0.beta.5
84
+ - rc
85
+ - 2
86
+ version: 1.0.0.rc.2
87
87
  type: :runtime
88
88
  version_requirements: *id004
89
89
  description: ""
@@ -107,7 +107,9 @@ files:
107
107
  - VERSION.yml
108
108
  - bin/vraptor
109
109
  - lib/generators/app_generator/app_generator.rb
110
+ - lib/generators/app_generator/templates/Entity.java
110
111
  - lib/generators/app_generator/templates/FreemarkerPathResolver.java
112
+ - lib/generators/app_generator/templates/Repository.java
111
113
  - lib/generators/app_generator/templates/decorators.xml
112
114
  - lib/generators/app_generator/templates/index.jsp
113
115
  - lib/generators/app_generator/templates/javascripts/jquery-1.4.2.min.js
@@ -124,12 +126,19 @@ files:
124
126
  - lib/generators/scaffold_generator/base_scaffold.rb
125
127
  - lib/generators/scaffold_generator/controller_generator/controller_generator.rb
126
128
  - lib/generators/scaffold_generator/controller_generator/templates/controller.erb
129
+ - lib/generators/scaffold_generator/controller_generator/templates/controller_test.erb
127
130
  - lib/generators/scaffold_generator/freemarker_generator/freemarker_generator.rb
131
+ - lib/generators/scaffold_generator/freemarker_generator/templates/edit.erb
128
132
  - lib/generators/scaffold_generator/freemarker_generator/templates/form.erb
129
133
  - lib/generators/scaffold_generator/freemarker_generator/templates/index.erb
134
+ - lib/generators/scaffold_generator/freemarker_generator/templates/new.erb
130
135
  - lib/generators/scaffold_generator/freemarker_generator/templates/show.erb
131
136
  - lib/generators/scaffold_generator/model_generator/model_generator.rb
132
137
  - lib/generators/scaffold_generator/model_generator/templates/model.erb
138
+ - lib/generators/scaffold_generator/model_generator/templates/model_test.erb
139
+ - lib/generators/scaffold_generator/repository_generator/repository_generator.rb
140
+ - lib/generators/scaffold_generator/repository_generator/templates/repository.erb
141
+ - lib/generators/scaffold_generator/repository_generator/templates/repository_test.erb
133
142
  - lib/generators/scaffold_generator/scaffold_generator.rb
134
143
  - lib/load_paths.rb
135
144
  - lib/vraptor-scaffold.rb
@@ -141,6 +150,8 @@ files:
141
150
  - spec/lib/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb
142
151
  - spec/lib/generators/scaffold_generator/model_generator/model_generator_spec.rb
143
152
  - spec/lib/generators/scaffold_generator/model_generator/templates/Product.java
153
+ - spec/lib/generators/scaffold_generator/repository_generator/repository_generator_spec.rb
154
+ - spec/lib/generators/scaffold_generator/repository_generator/templates/ProductRepository.java
144
155
  - spec/lib/generators/scaffold_generator/scaffold_generator_spec.rb
145
156
  - spec/lib/vraptor-scaffold_spec.rb
146
157
  - spec/spec.opts
@@ -186,6 +197,7 @@ test_files:
186
197
  - spec/lib/vraptor-scaffold_spec.rb
187
198
  - spec/lib/generators/app_generator/app_generator_spec.rb
188
199
  - spec/lib/generators/scaffold_generator/controller_generator/controller_generator_spec.rb
200
+ - spec/lib/generators/scaffold_generator/repository_generator/repository_generator_spec.rb
189
201
  - spec/lib/generators/scaffold_generator/scaffold_generator_spec.rb
190
202
  - spec/lib/generators/scaffold_generator/model_generator/model_generator_spec.rb
191
203
  - spec/lib/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb