heroku-vraptor-scaffold 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.rdoc +188 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +30 -0
- data/LICENSE +22 -0
- data/README.md +23 -0
- data/README.textile +51 -0
- data/Rakefile +20 -0
- data/bin/heroku-vraptor +8 -0
- data/heroku-vraptor-scaffold.gemspec +28 -0
- data/index.sample.html +169 -0
- data/lib/vraptor-scaffold.rb +14 -0
- data/lib/vraptor-scaffold/configuration.rb +54 -0
- data/lib/vraptor-scaffold/execution.rb +22 -0
- data/lib/vraptor-scaffold/generators/app/app_generator.rb +161 -0
- data/lib/vraptor-scaffold/generators/app/dependency.rb +15 -0
- data/lib/vraptor-scaffold/generators/app/dependency_manager.rb +32 -0
- data/lib/vraptor-scaffold/generators/app/templates/angular/angular.js +14327 -0
- data/lib/vraptor-scaffold/generators/app/templates/bootstrap/bootstrap-responsive.css +9 -0
- data/lib/vraptor-scaffold/generators/app/templates/bootstrap/bootstrap.css +9 -0
- data/lib/vraptor-scaffold/generators/app/templates/bootstrap/bootstrap.js +6 -0
- data/lib/vraptor-scaffold/generators/app/templates/bootstrap/glyphicons-halflings-white.png +0 -0
- data/lib/vraptor-scaffold/generators/app/templates/bootstrap/glyphicons-halflings.png +0 -0
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/classpath.erb +18 -0
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/project.erb +36 -0
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings/org.eclipse.jdt.core.prefs +8 -0
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings/org.eclipse.wst.common.component.tt +10 -0
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings/org.eclipse.wst.common.project.facet.core.xml +10 -0
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.container +1 -0
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.name +1 -0
- data/lib/vraptor-scaffold/generators/app/templates/heroku/Main.java +21 -0
- data/lib/vraptor-scaffold/generators/app/templates/heroku/Procfile +1 -0
- data/lib/vraptor-scaffold/generators/app/templates/jquery/jquery.min.js +4 -0
- data/lib/vraptor-scaffold/generators/app/templates/models/Entity.erb +46 -0
- data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-hibernate.java.tt +50 -0
- data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-jpa.java.tt +48 -0
- data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-objectify.java.tt +41 -0
- data/lib/vraptor-scaffold/generators/app/templates/orm/hibernate.cfg.xml +7 -0
- data/lib/vraptor-scaffold/generators/app/templates/orm/persistence.xml +10 -0
- data/lib/vraptor-scaffold/generators/app/templates/pom.erb +110 -0
- data/lib/vraptor-scaffold/generators/app/templates/resources-test/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app/templates/resources/hibernate.properties +16 -0
- data/lib/vraptor-scaffold/generators/app/templates/resources/log4j.properties +4 -0
- data/lib/vraptor-scaffold/generators/app/templates/resources/messages.properties +0 -0
- data/lib/vraptor-scaffold/generators/app/templates/underscore/underscore.min.js +32 -0
- data/lib/vraptor-scaffold/generators/app/templates/vraptor-scaffold.erb +5 -0
- data/lib/vraptor-scaffold/generators/app/templates/webapp/WEB-INF/web.xml.tt +33 -0
- data/lib/vraptor-scaffold/generators/app/templates/webapp/images/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app/templates/webapp/index.html +24 -0
- data/lib/vraptor-scaffold/generators/app/templates/webapp/javascripts/utils.js +7 -0
- data/lib/vraptor-scaffold/generators/base.rb +16 -0
- data/lib/vraptor-scaffold/generators/scaffold/attribute.rb +51 -0
- data/lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb +54 -0
- data/lib/vraptor-scaffold/generators/scaffold/client_generator/client_generator.rb +41 -0
- data/lib/vraptor-scaffold/generators/scaffold/client_generator/templates/controller.erb +75 -0
- data/lib/vraptor-scaffold/generators/scaffold/client_generator/templates/details.erb +16 -0
- data/lib/vraptor-scaffold/generators/scaffold/client_generator/templates/form.erb +39 -0
- data/lib/vraptor-scaffold/generators/scaffold/client_generator/templates/list.erb +40 -0
- data/lib/vraptor-scaffold/generators/scaffold/controller_generator/controller_generator.rb +20 -0
- data/lib/vraptor-scaffold/generators/scaffold/controller_generator/templates/controller.erb +77 -0
- data/lib/vraptor-scaffold/generators/scaffold/controller_generator/templates/controller_test.erb +12 -0
- data/lib/vraptor-scaffold/generators/scaffold/model_generator/model_generator.rb +26 -0
- data/lib/vraptor-scaffold/generators/scaffold/model_generator/templates/model.erb +32 -0
- data/lib/vraptor-scaffold/generators/scaffold/model_generator/templates/model_test.erb +13 -0
- data/lib/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator.rb +32 -0
- data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository.erb +22 -0
- data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_impl.erb +16 -0
- data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_test.erb +13 -0
- data/lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb +35 -0
- data/lib/vraptor-scaffold/runner.rb +9 -0
- data/lib/vraptor-scaffold/runner/commands_help.rb +13 -0
- data/lib/vraptor-scaffold/runner/generator.rb +15 -0
- data/lib/vraptor-scaffold/runner/help.rb +12 -0
- data/lib/vraptor-scaffold/runner/scaffold.rb +16 -0
- data/lib/vraptor-scaffold/version.rb +3 -0
- data/maven/repo/br/com/caelum/vraptor-gae/1.0/vraptor-gae-1.0.jar +0 -0
- data/spec/resources/vraptor-scaffold-objectify.properties +7 -0
- data/spec/resources/vraptor-scaffold.properties +7 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/vraptor-scaffold/configuration_spec.rb +146 -0
- data/spec/vraptor-scaffold/execution_spec.rb +51 -0
- data/spec/vraptor-scaffold/generators/app/app_generator_spec.rb +557 -0
- data/spec/vraptor-scaffold/generators/app/dependency_manager_spec.rb +34 -0
- data/spec/vraptor-scaffold/generators/app/dependency_spec.rb +14 -0
- data/spec/vraptor-scaffold/generators/app/freemarker_template_engine_spec.rb +80 -0
- data/spec/vraptor-scaffold/generators/app/jsp_template_engine_spec.rb +77 -0
- data/spec/vraptor-scaffold/generators/app/templates/Entity.java +45 -0
- data/spec/vraptor-scaffold/generators/app/templates/FreemarkerPathResolver.java +21 -0
- data/spec/vraptor-scaffold/generators/app/templates/ObjectifyFactory.java +30 -0
- data/spec/vraptor-scaffold/generators/app/templates/RepositoryJPA.java +48 -0
- data/spec/vraptor-scaffold/generators/app/templates/RepositoryObjectify.java +41 -0
- data/spec/vraptor-scaffold/generators/app/templates/build.gradle +60 -0
- data/spec/vraptor-scaffold/generators/app/templates/build.properties +18 -0
- data/spec/vraptor-scaffold/generators/app/templates/build.xml +146 -0
- data/spec/vraptor-scaffold/generators/app/templates/classpath-gae +18 -0
- data/spec/vraptor-scaffold/generators/app/templates/decorators-jsp.xml +7 -0
- data/spec/vraptor-scaffold/generators/app/templates/decorators.xml +7 -0
- data/spec/vraptor-scaffold/generators/app/templates/freemarker-web.xml +60 -0
- data/spec/vraptor-scaffold/generators/app/templates/gae-jsp-web.xml +45 -0
- data/spec/vraptor-scaffold/generators/app/templates/ivy-gae.xml +45 -0
- data/spec/vraptor-scaffold/generators/app/templates/ivy.xml +40 -0
- data/spec/vraptor-scaffold/generators/app/templates/jsp-web.xml +45 -0
- data/spec/vraptor-scaffold/generators/app/templates/pom-heroku.xml +182 -0
- data/spec/vraptor-scaffold/generators/app/templates/pom.xml +157 -0
- data/spec/vraptor-scaffold/generators/app/templates/project-gae +47 -0
- data/spec/vraptor-scaffold/generators/app/templates/vraptor-scaffold.properties +7 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/build.gradle +62 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_build.gradle +62 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_ivy.xml +41 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_pom.xml +152 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/ivy.xml +42 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/pom.xml +182 -0
- data/spec/vraptor-scaffold/generators/scaffold/attribute_spec.rb +186 -0
- data/spec/vraptor-scaffold/generators/scaffold/base_scaffold_spec.rb +73 -0
- data/spec/vraptor-scaffold/generators/scaffold/client_controller_generator/controller_generator_spec.rb +62 -0
- data/spec/vraptor-scaffold/generators/scaffold/client_controller_generator/templates/ProductController.java +95 -0
- data/spec/vraptor-scaffold/generators/scaffold/controller_generator/controller_generator_spec.rb +62 -0
- data/spec/vraptor-scaffold/generators/scaffold/controller_generator/templates/ProductController.java +95 -0
- data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/freemarker_generator_spec.rb +81 -0
- data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/templates/form.ftl +28 -0
- data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/jsp_generator_spec.rb +81 -0
- data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/templates/form.jsp +61 -0
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/model_generator_spec.rb +54 -0
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/objectify_model_generator_spec.rb +40 -0
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/ObjectifyFactory.java +33 -0
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/Objectify_Product.java +38 -0
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/Product.java +25 -0
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/hibernate.cfg.xml +8 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/objectify_repository_generator_spec.rb +33 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator_spec.rb +68 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepository.java +22 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepositoryImpl.java +16 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/Objectify_ProductRepository.java +22 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/Objectify_ProductRepositoryImpl.java +16 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ProductRepository.java +22 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ProductRepositoryImpl.java +16 -0
- data/spec/vraptor-scaffold/generators/scaffold/scaffold_generator_spec.rb +79 -0
- data/spec/vraptor-scaffold/http_request_spec.rb +40 -0
- data/spec/vraptor-scaffold/runner/commands_help_spec.rb +12 -0
- data/spec/vraptor-scaffold/runner/configure_spec.rb +12 -0
- data/spec/vraptor-scaffold/runner/generator_spec.rb +31 -0
- data/spec/vraptor-scaffold/runner/help_spec.rb +29 -0
- data/spec/vraptor-scaffold/runner/scaffold_spec.rb +35 -0
- data/spec/vraptor-scaffold/runner/start_spec.rb +51 -0
- data/spec/vraptor-scaffold_spec.rb +4 -0
- metadata +261 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
class ControllerGenerator < BaseScaffold
|
2
|
+
|
3
|
+
def build
|
4
|
+
define_source_paths
|
5
|
+
template("controller.erb", Configuration.main_class_path(Configuration.controllers_package, "#{controller_class_name}.java"))
|
6
|
+
template("controller_test.erb", Configuration.test_class_path(Configuration.controllers_package, "#{controller_test_class_name}.java"))
|
7
|
+
end
|
8
|
+
|
9
|
+
def template_path
|
10
|
+
"src/templates/controllers"
|
11
|
+
end
|
12
|
+
|
13
|
+
def source_root
|
14
|
+
File.join File.dirname(__FILE__), "templates"
|
15
|
+
end
|
16
|
+
|
17
|
+
def path
|
18
|
+
"/#{base_path}"
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
package <%= Configuration.package %>.<%= Configuration.controllers_package %>;
|
2
|
+
|
3
|
+
import java.util.List;
|
4
|
+
|
5
|
+
import <%= Configuration.full_models_package %>.<%= class_name %>;
|
6
|
+
import <%= Configuration.package %>.<%= Configuration.repositories_package %>.<%= repository_interface_name %>;
|
7
|
+
import br.com.caelum.vraptor.Consumes;
|
8
|
+
import br.com.caelum.vraptor.Delete;
|
9
|
+
import br.com.caelum.vraptor.Get;
|
10
|
+
import br.com.caelum.vraptor.Post;
|
11
|
+
import br.com.caelum.vraptor.Put;
|
12
|
+
import br.com.caelum.vraptor.Resource;
|
13
|
+
import br.com.caelum.vraptor.Result;
|
14
|
+
import br.com.caelum.vraptor.Validator;
|
15
|
+
import br.com.caelum.vraptor.validator.ValidationException;
|
16
|
+
import br.com.caelum.vraptor.view.Results;
|
17
|
+
|
18
|
+
@Resource
|
19
|
+
public class <%= controller_class_name %> {
|
20
|
+
|
21
|
+
protected final Result result;
|
22
|
+
protected final <%= repository_interface_name %> repository;
|
23
|
+
protected final Validator validator;
|
24
|
+
|
25
|
+
public <%= controller_class_name %>(Result result, <%= repository_interface_name %> repository, Validator validator) {
|
26
|
+
this.result = result;
|
27
|
+
this.repository = repository;
|
28
|
+
this.validator = validator;
|
29
|
+
}
|
30
|
+
|
31
|
+
@Get("<%= path %>")
|
32
|
+
public void index() {
|
33
|
+
serialize(repository.findAll());
|
34
|
+
}
|
35
|
+
|
36
|
+
@Post("<%= path %>")
|
37
|
+
@Consumes("application/json")
|
38
|
+
public void create(<%= class_name %> <%= model_parameter_name %>) {
|
39
|
+
validate(<%= model_parameter_name %>);
|
40
|
+
repository.create(<%= model_parameter_name %>);
|
41
|
+
result.nothing();
|
42
|
+
}
|
43
|
+
|
44
|
+
@Put("<%= path %>")
|
45
|
+
@Consumes("application/json")
|
46
|
+
public void update(<%= class_name %> <%= model_parameter_name %>) {
|
47
|
+
validate(<%= model_parameter_name %>);
|
48
|
+
repository.update(<%= model_parameter_name %>);
|
49
|
+
result.nothing();
|
50
|
+
}
|
51
|
+
|
52
|
+
@Get("<%= "#{path}/{#{model_parameter_name}.id}" %>")
|
53
|
+
public void show(<%= class_name %> <%= model_parameter_name %>) {
|
54
|
+
serialize(find(<%= model_parameter_name %>));
|
55
|
+
}
|
56
|
+
|
57
|
+
@Delete("<%= "#{path}/{#{model_parameter_name}.id}" %>")
|
58
|
+
public void destroy(<%= class_name %> <%= model_parameter_name %>) {
|
59
|
+
repository.destroy(find(<%= model_parameter_name %>));
|
60
|
+
serialize(<%= model_parameter_name %>);
|
61
|
+
}
|
62
|
+
|
63
|
+
private void serialize(Object object) {
|
64
|
+
result.use(Results.json()).from(object).recursive().serialize();
|
65
|
+
}
|
66
|
+
|
67
|
+
private <%= class_name %> find(<%= class_name %> <%= model_parameter_name %>) {
|
68
|
+
return repository.find(<%= model_parameter_name %>.getId());
|
69
|
+
}
|
70
|
+
|
71
|
+
private void validate(<%= class_name %> <%= model_parameter_name %>) {
|
72
|
+
validator.validate(<%= model_parameter_name %>);
|
73
|
+
if (validator.hasErrors()) {
|
74
|
+
throw new ValidationException(validator.getErrors());
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
data/lib/vraptor-scaffold/generators/scaffold/controller_generator/templates/controller_test.erb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
package <%= Configuration.package %>.<%= Configuration.controllers_package %>;
|
2
|
+
|
3
|
+
import static org.junit.Assert.assertNotNull;
|
4
|
+
|
5
|
+
import org.junit.Test;
|
6
|
+
|
7
|
+
public class <%= controller_test_class_name %> {
|
8
|
+
|
9
|
+
@Test public void fakeTest() {
|
10
|
+
assertNotNull("put something real.", new <%= controller_class_name %>(null, null, null));
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class ModelGenerator < BaseScaffold
|
2
|
+
|
3
|
+
def build
|
4
|
+
define_source_paths
|
5
|
+
template("model.erb", Configuration.main_class_path(Configuration.models_package, "#{class_name}.java"))
|
6
|
+
template("model_test.erb", Configuration.test_class_path(Configuration.models_package, "#{test_class_name}.java"))
|
7
|
+
map_orm_class if Configuration.hibernate?
|
8
|
+
end
|
9
|
+
|
10
|
+
def template_path
|
11
|
+
"src/templates/models"
|
12
|
+
end
|
13
|
+
|
14
|
+
def source_root
|
15
|
+
File.join File.dirname(__FILE__), "templates"
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def map_orm_class
|
20
|
+
file = File.join Configuration::MAIN_RESOURCES, "hibernate.cfg.xml"
|
21
|
+
model = "#{Configuration.full_models_package}.#{class_name}"
|
22
|
+
line_break = "\n "
|
23
|
+
inject_into_file(file, " <mapping class='#{model}'/>#{line_break}", :before => "</session-factory>")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
package <%= Configuration.full_models_package %>;
|
2
|
+
|
3
|
+
import <%= Configuration.package %>.<%= Configuration.controllers_package %>.<%= controller_class_name %>;
|
4
|
+
import br.com.caelum.vraptor.restfulie.relation.RelationBuilder;
|
5
|
+
|
6
|
+
@javax.persistence.Entity
|
7
|
+
public class <%= class_name %> extends Entity {
|
8
|
+
|
9
|
+
<% @attributes.each do |att| -%>
|
10
|
+
private <%= att.java_type %> <%= att.name %>;
|
11
|
+
<% end -%>
|
12
|
+
|
13
|
+
<% @attributes.each do |att| -%>
|
14
|
+
public void set<%= att.name.camelize %>(<%= att.java_type %> <%= att.name %>) {
|
15
|
+
this.<%= att.name %> = <%= att.name %>;
|
16
|
+
}
|
17
|
+
|
18
|
+
public <%= att.java_type %> <%= att.getter_prefix + att.name.camelize %>() {
|
19
|
+
return <%= att.name %>;
|
20
|
+
}
|
21
|
+
|
22
|
+
<% end -%>
|
23
|
+
|
24
|
+
@Override
|
25
|
+
public void configureRelations(RelationBuilder builder) {
|
26
|
+
Class<<%= controller_class_name %>> controller = <%= controller_class_name %>.class;
|
27
|
+
builder.relation("location").uses(controller).show(this);
|
28
|
+
builder.relation("update").uses(controller).update(this);
|
29
|
+
builder.relation("destroy").uses(controller).destroy(this);
|
30
|
+
}
|
31
|
+
|
32
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
package <%= Configuration.full_models_package %>;
|
2
|
+
|
3
|
+
import static org.junit.Assert.assertNotNull;
|
4
|
+
|
5
|
+
import org.junit.Test;
|
6
|
+
|
7
|
+
public class <%= test_class_name %> {
|
8
|
+
|
9
|
+
@Test public void fakeTest() {
|
10
|
+
assertNotNull("put something real.", new <%= class_name %>());
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class RepositoryGenerator < BaseScaffold
|
2
|
+
|
3
|
+
def build
|
4
|
+
define_source_paths
|
5
|
+
template("repository.erb", Configuration.main_class_path(Configuration.repositories_package, "#{repository_interface_name}.java"))
|
6
|
+
template("repository_impl.erb", Configuration.main_class_path(Configuration.repositories_package, "#{repository_impl_name}.java"))
|
7
|
+
template("repository_test.erb", Configuration.test_class_path(Configuration.repositories_package, "#{repository_test_class_name}.java"))
|
8
|
+
end
|
9
|
+
|
10
|
+
def orm_import
|
11
|
+
return "org.hibernate.Session" if Configuration.hibernate?
|
12
|
+
"javax.persistence.EntityManager"
|
13
|
+
end
|
14
|
+
|
15
|
+
def orm_parameter_name
|
16
|
+
return "session" if Configuration.hibernate?
|
17
|
+
"entityManager"
|
18
|
+
end
|
19
|
+
|
20
|
+
def orm_class
|
21
|
+
orm_parameter_name.camelize
|
22
|
+
end
|
23
|
+
|
24
|
+
def template_path
|
25
|
+
"src/templates/repositories"
|
26
|
+
end
|
27
|
+
|
28
|
+
def source_root
|
29
|
+
File.join File.dirname(__FILE__), "templates"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
package <%= Configuration.package %>.<%= Configuration.repositories_package %>;
|
2
|
+
|
3
|
+
import java.util.List;
|
4
|
+
|
5
|
+
import <%= Configuration.full_models_package %>.<%= class_name %>;
|
6
|
+
|
7
|
+
public interface <%= repository_interface_name %> {
|
8
|
+
/*
|
9
|
+
* Delete the methods you don't want to expose
|
10
|
+
*/
|
11
|
+
|
12
|
+
void create(<%= class_name %> entity);
|
13
|
+
|
14
|
+
<%= class_name %> update(<%= class_name %> entity);
|
15
|
+
|
16
|
+
void destroy(<%= class_name %> entity);
|
17
|
+
|
18
|
+
<%= class_name %> find(Long id);
|
19
|
+
|
20
|
+
List<<%= class_name %>> findAll();
|
21
|
+
|
22
|
+
}
|
data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_impl.erb
ADDED
@@ -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
|
+
}
|
data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_test.erb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
package <%= Configuration.package %>.<%= Configuration.repositories_package %>;
|
2
|
+
|
3
|
+
import static org.junit.Assert.assertNotNull;
|
4
|
+
|
5
|
+
import org.junit.Test;
|
6
|
+
|
7
|
+
public class <%= repository_test_class_name %> {
|
8
|
+
|
9
|
+
@Test public void fakeTest() {
|
10
|
+
assertNotNull("put something real.", new <%= repository_impl_name %>(null));
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class ScaffoldGenerator < VraptorScaffold::Base
|
2
|
+
|
3
|
+
attr_accessor :generated_attributes
|
4
|
+
argument :model
|
5
|
+
argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type"
|
6
|
+
|
7
|
+
|
8
|
+
def self.banner
|
9
|
+
"vraptor scaffold #{self.arguments.map(&:usage).join(' ')}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(args)
|
13
|
+
super(args)
|
14
|
+
@generated_attributes = []
|
15
|
+
attributes.each { |field, type|
|
16
|
+
@generated_attributes << Attribute.new(field, type)
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def controller_generator
|
21
|
+
ControllerGenerator.new(model, @generated_attributes).build
|
22
|
+
end
|
23
|
+
|
24
|
+
def model_generator
|
25
|
+
ModelGenerator.new(model, @generated_attributes).build
|
26
|
+
end
|
27
|
+
|
28
|
+
def repository_generator
|
29
|
+
RepositoryGenerator.new(model, @generated_attributes).build
|
30
|
+
end
|
31
|
+
|
32
|
+
def client_generator
|
33
|
+
ClientGenerator.new(model, @generated_attributes).build
|
34
|
+
end
|
35
|
+
end
|
@@ -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,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,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
|
Binary file
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require 'spec'
|
5
|
+
require 'spec/autorun'
|
6
|
+
require File.dirname(__FILE__) + '/../lib/vraptor-scaffold'
|
7
|
+
|
8
|
+
def build_attributes
|
9
|
+
[Attribute.new("name", "string"), Attribute.new("myFlag", "boolean")]
|
10
|
+
end
|
11
|
+
|
12
|
+
def mock_config_file
|
13
|
+
file = YAML.load_file File.join( File.dirname(__FILE__), "resources", "vraptor-scaffold.properties")
|
14
|
+
Configuration.stub!(:config).and_return(file)
|
15
|
+
end
|
16
|
+
|
17
|
+
def mock_objectify_config_file
|
18
|
+
file = YAML.load_file File.join( File.dirname(__FILE__), "resources", "vraptor-scaffold-objectify.properties")
|
19
|
+
Configuration.stub!(:config).and_return(file)
|
20
|
+
end
|
21
|
+
|
22
|
+
def exists_and_identical?(source, created)
|
23
|
+
c = sanitize(File.open(created).read)
|
24
|
+
c2 = sanitize(File.open(source).read)
|
25
|
+
c.should be == c2
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def sanitize(text)
|
30
|
+
text.gsub( /\r/m, "" ).gsub(/\n/m, "").gsub(/ /m, "")
|
31
|
+
end
|