vraptor-scaffold 0.0.1.beta2 → 0.0.1.beta3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/History.txt +18 -0
- data/LICENSE +2 -0
- data/README.rdoc +49 -14
- data/Rakefile +6 -0
- data/TODO.txt +11 -5
- data/VERSION.yml +1 -1
- data/lib/generators/app_generator/app_generator.rb +13 -5
- data/lib/generators/app_generator/templates/FreemarkerPathResolver.java +4 -6
- data/lib/generators/app_generator/templates/log4j.properties +4 -0
- data/lib/generators/app_generator/templates/macros/html.ftl +11 -0
- data/lib/generators/app_generator/templates/persistence.xml +4 -2
- data/lib/generators/app_generator/templates/pom.erb +1 -1
- data/lib/generators/app_generator/templates/web.xml +4 -0
- data/lib/generators/attribute.rb +19 -0
- data/lib/generators/scaffold_generator/freemarker_generator/freemarker_generator.rb +8 -4
- data/lib/generators/scaffold_generator/freemarker_generator/templates/edit.erb +1 -1
- data/lib/generators/scaffold_generator/freemarker_generator/templates/index.erb +4 -1
- data/lib/generators/scaffold_generator/freemarker_generator/templates/new.erb +1 -1
- data/lib/generators/scaffold_generator/freemarker_generator/templates/show.erb +2 -1
- data/lib/generators/scaffold_generator/scaffold_generator.rb +22 -5
- data/lib/vraptor-scaffold.rb +2 -1
- data/spec/lib/generators/app_generator/app_generator_spec.rb +20 -14
- data/spec/lib/generators/app_generator/templates/pom.xml +1 -1
- data/spec/lib/generators/attribute_spec.rb +82 -0
- data/spec/lib/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb +5 -5
- data/spec/lib/generators/scaffold_generator/model_generator/templates/Product.java +5 -5
- data/spec/lib/generators/scaffold_generator/scaffold_generator_spec.rb +30 -10
- data/spec/lib/vraptor-scaffold_spec.rb +8 -1
- data/spec/spec_helper.rb +1 -1
- data/vraptor-scaffold.gemspec +17 -3
- metadata +74 -7
- data/lib/generators/app_generator/templates/log4j.xml +0 -20
data/.gitignore
CHANGED
data/History.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
=== 0.0.1.beta3 / 2010-07-11
|
2
|
+
|
3
|
+
== New Features
|
4
|
+
* Added command to start web server(jetty).
|
5
|
+
* Added boolean support.
|
6
|
+
|
7
|
+
== Improvements
|
8
|
+
* Bumped vraptor version to 3.1.3.
|
9
|
+
* Change log4j.xml to log4j.properties.
|
10
|
+
* Change views directory from WEB-INF/freemarker to WEB-INF/views.
|
11
|
+
* Change hsqldb to use file instead of memory.
|
12
|
+
|
13
|
+
== Bugfixes
|
14
|
+
* Fixed pom when creating project with path like /home/rodolfo/project.
|
15
|
+
* Fixed runtime dependencies.
|
16
|
+
|
17
|
+
=== 0.0.1.beta2 / 2010-07-07
|
18
|
+
* Crud with vraptor, maven 2, jpa, freemarker e jquery.
|
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,33 +1,68 @@
|
|
1
1
|
= Vraptor Scaffold
|
2
|
+
Scaffold for vraptor3.
|
2
3
|
|
3
4
|
== Installation
|
4
|
-
|
5
|
-
|
5
|
+
gem install vraptor-scaffold --pre
|
6
|
+
|
7
|
+
== Getting Started
|
8
|
+
At the command line client:
|
9
|
+
|
10
|
+
- vraptor new myapp
|
11
|
+
- Change directory into myapp
|
12
|
+
- vraptor scaffold product name:string value:double
|
13
|
+
- vraptor start
|
14
|
+
- Go http://localhost:8080/products
|
6
15
|
|
7
|
-
==
|
16
|
+
== Werb Server
|
17
|
+
The default web server is jetty but you can import the project in your favorite ide
|
18
|
+
and run your project with tomcat or jboss as for example.
|
8
19
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
20
|
+
== Supported Java Types
|
21
|
+
The only supported types for now are: boolean, double, float, short, integer, long and string.
|
22
|
+
|
23
|
+
== Architecture Overview
|
24
|
+
When you run vraptor new command will be created a java web application with:
|
13
25
|
|
14
|
-
|
26
|
+
- Vraptor3 = Controller
|
27
|
+
- Jpa(Hibernate) = ORM
|
28
|
+
- Freemarker = Template Engine
|
29
|
+
- Sitemesh = Decorator
|
30
|
+
- Maven2 = Project Management
|
31
|
+
- Jquery = JavaScript
|
32
|
+
|
33
|
+
Tests will use junit, mockito and dbunit.
|
15
34
|
|
16
|
-
|
35
|
+
src/main/java/app/controllers
|
36
|
+
Controllers will be placed here.
|
37
|
+
src/main/java/app/models
|
38
|
+
Models will be placed here.
|
39
|
+
src/main/webapp
|
40
|
+
Web root folder.
|
41
|
+
src/main/webapp/decorators
|
42
|
+
Decorators will be placed here.
|
43
|
+
src/main/webapp/macros
|
44
|
+
Freemarker macros will be placed here.
|
45
|
+
src/main/webapp/javascripts
|
46
|
+
JavaScripts will be placed here.
|
47
|
+
src/main/webapp/stylesheets
|
48
|
+
CSS will be placed here.
|
49
|
+
src/main/webapp/WEB-INF/views
|
50
|
+
Views will be placed here. Ex: product/index.ftl
|
51
|
+
|
52
|
+
== Dependencies
|
53
|
+
Ensures that you already have installed:
|
54
|
+
|
17
55
|
- Java 6
|
18
56
|
- Maven 2
|
19
57
|
|
20
58
|
== Note on Patches/Pull Requests
|
21
|
-
|
22
59
|
- Fork the project.
|
23
60
|
- Make your feature addition or bug fix.
|
24
61
|
- Add tests for it.
|
25
62
|
- Send me a pull request.
|
26
63
|
|
27
|
-
==
|
28
|
-
|
64
|
+
== Author
|
29
65
|
-- Rodolfo Liviero [mailto:rodolfoliviero@gmail.com]
|
30
66
|
|
31
67
|
== Copyright
|
32
|
-
|
33
|
-
Copyright (c) 2010 Rodolfo Liviero. See LICENSE for details.
|
68
|
+
Copyright (c) 2010 Rodolfo Liviero. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -10,6 +10,12 @@ begin
|
|
10
10
|
gem.email = "rodolfoliviero@gmail.com"
|
11
11
|
gem.homepage = "http://github.com/rodolfoliviero/vraptor-scaffold"
|
12
12
|
gem.authors = ["Rodolfo Liviero"]
|
13
|
+
|
14
|
+
gem.add_dependency "thor", ">=0.13.7"
|
15
|
+
gem.add_dependency "rake", ">=0.8.7"
|
16
|
+
gem.add_dependency "activesupport", ">=2.3.8"
|
17
|
+
gem.add_dependency "bundler", ">=1.0.0.beta.2"
|
18
|
+
|
13
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."
|
14
20
|
end
|
15
21
|
Jeweler::GemcutterTasks.new
|
data/TODO.txt
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
-
Fix pom when create app with path Ex: /home/rodolfo/src/app
|
2
|
-
change log4j.xml to lo4j.properties
|
3
1
|
display name web.xml with app name
|
4
|
-
|
5
|
-
create others persistence unit
|
2
|
+
create others persistence unit(maven profile?)
|
6
3
|
new java keyword(how to call new method in controller?)
|
7
|
-
change database to derby
|
8
4
|
create "partial" to form
|
5
|
+
update jpa to jpa2(hibernate 3.5.?-FINAL)
|
6
|
+
datetime, date and time support.(jquery-ui?)
|
7
|
+
relationship support(many-to-one, one-to-many, many-to-many)
|
8
|
+
active record is possible?
|
9
|
+
generators help
|
10
|
+
usage file to each generator
|
11
|
+
gem description
|
12
|
+
http://waffle.codehaus.org
|
13
|
+
put all html input in macros
|
14
|
+
i18n
|
data/VERSION.yml
CHANGED
@@ -4,9 +4,9 @@ class AppGenerator < VraptorScaffold::Base
|
|
4
4
|
File.dirname(__FILE__)
|
5
5
|
end
|
6
6
|
|
7
|
-
def build(
|
8
|
-
@project_name =
|
9
|
-
self.destination_root=(
|
7
|
+
def build(project_path)
|
8
|
+
@project_name = project_path.split("/").last
|
9
|
+
self.destination_root=(project_path)
|
10
10
|
empty_directory "."
|
11
11
|
create_pom
|
12
12
|
create_main_java
|
@@ -48,7 +48,7 @@ class AppGenerator < VraptorScaffold::Base
|
|
48
48
|
main_resources = "src/main/resources"
|
49
49
|
empty_directory main_resources
|
50
50
|
inside main_resources do
|
51
|
-
template_from_root("log4j.
|
51
|
+
template_from_root("log4j.properties", "#{main_resources}/log4j.properties")
|
52
52
|
meta_inf = empty_directory "META-INF"
|
53
53
|
template_from_root("persistence.xml", "#{meta_inf}/persistence.xml")
|
54
54
|
end
|
@@ -62,10 +62,18 @@ class AppGenerator < VraptorScaffold::Base
|
|
62
62
|
create_decorators
|
63
63
|
create_js
|
64
64
|
create_css
|
65
|
+
create_macros
|
65
66
|
create_web_inf
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
70
|
+
def create_macros
|
71
|
+
macros = empty_directory "macros"
|
72
|
+
inside "macros" do
|
73
|
+
template_from_root("macros/html.ftl", "#{macros}/html.ftl")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
69
77
|
def create_css
|
70
78
|
css = empty_directory "stylesheets"
|
71
79
|
inside "stylesheets" do
|
@@ -92,7 +100,7 @@ class AppGenerator < VraptorScaffold::Base
|
|
92
100
|
inside "WEB-INF" do
|
93
101
|
template_from_root("decorators.xml", "#{web_inf}/decorators.xml")
|
94
102
|
template_from_root("web.xml", "#{web_inf}/web.xml")
|
95
|
-
empty_directory "
|
103
|
+
empty_directory "views"
|
96
104
|
end
|
97
105
|
end
|
98
106
|
|
@@ -1,20 +1,18 @@
|
|
1
1
|
package app.infrastructure;
|
2
2
|
|
3
|
-
import
|
4
|
-
|
3
|
+
import br.com.caelum.vraptor.http.FormatResolver;
|
5
4
|
import br.com.caelum.vraptor.ioc.Component;
|
6
|
-
import br.com.caelum.vraptor.view.AcceptHeaderToFormat;
|
7
5
|
import br.com.caelum.vraptor.view.DefaultPathResolver;
|
8
6
|
|
9
7
|
@Component
|
10
8
|
public class FreemarkerPathResolver extends DefaultPathResolver {
|
11
9
|
|
12
|
-
public FreemarkerPathResolver(
|
13
|
-
super(
|
10
|
+
public FreemarkerPathResolver(FormatResolver resolver) {
|
11
|
+
super(resolver);
|
14
12
|
}
|
15
13
|
|
16
14
|
protected String getPrefix() {
|
17
|
-
return "/WEB-INF/
|
15
|
+
return "/WEB-INF/views/";
|
18
16
|
}
|
19
17
|
|
20
18
|
protected String getExtension() {
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<#macro checkbox name checked=false>
|
2
|
+
<#if checked>
|
3
|
+
<input type="checkbox" name="${name}" checked>
|
4
|
+
<#else>
|
5
|
+
<input type="checkbox" name="${name}">
|
6
|
+
</#if>
|
7
|
+
</#macro>
|
8
|
+
|
9
|
+
<#macro text name value="">
|
10
|
+
<input type="text" name="${name}" value="${value}">
|
11
|
+
</#macro>
|
@@ -9,9 +9,11 @@
|
|
9
9
|
|
10
10
|
<properties>
|
11
11
|
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
|
12
|
-
<property name="hibernate.connection.url" value="jdbc:hsqldb:
|
13
|
-
<property name="hibernate.hbm2ddl.auto" value="
|
12
|
+
<property name="hibernate.connection.url" value="jdbc:hsqldb:file:tmp/devdb" />
|
13
|
+
<property name="hibernate.hbm2ddl.auto" value="update" />
|
14
14
|
<property name="hibernate.query.substitutions" value="true=1, false=0"/>
|
15
|
+
<property name="hibernate.show_sql" value="true" />
|
16
|
+
<property name="hibernate.format_sql" value="true" />
|
15
17
|
</properties>
|
16
18
|
</persistence-unit>
|
17
19
|
|
@@ -42,6 +42,10 @@
|
|
42
42
|
<param-name>default_encoding</param-name>
|
43
43
|
<param-value>ISO-8859-1</param-value>
|
44
44
|
</init-param>
|
45
|
+
<init-param>
|
46
|
+
<param-name>auto_import</param-name>
|
47
|
+
<param-value>macros/html.ftl as html</param-value>
|
48
|
+
</init-param>
|
45
49
|
<load-on-startup>1</load-on-startup>
|
46
50
|
</servlet>
|
47
51
|
|
data/lib/generators/attribute.rb
CHANGED
@@ -3,6 +3,25 @@ class Attribute
|
|
3
3
|
|
4
4
|
def initialize(name, type)
|
5
5
|
@name = name
|
6
|
+
set_type(type)
|
7
|
+
end
|
8
|
+
|
9
|
+
def set_type(type)
|
6
10
|
@type = type
|
11
|
+
@type = @type.capitalize unless boolean?
|
12
|
+
end
|
13
|
+
|
14
|
+
def html_input
|
15
|
+
input = "text"
|
16
|
+
input = "checkbox" if boolean?
|
17
|
+
input
|
18
|
+
end
|
19
|
+
|
20
|
+
def boolean?
|
21
|
+
type.eql? "boolean"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.valid_types
|
25
|
+
%w(boolean double float short integer long string)
|
7
26
|
end
|
8
27
|
end
|
@@ -5,10 +5,14 @@ class FreemarkerGenerator < BaseScaffold
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def build
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
create_view("index")
|
9
|
+
create_view("show")
|
10
|
+
create_view("new", "new#{class_name}")
|
11
|
+
create_view("edit")
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_view(template_name, file_name=template_name)
|
15
|
+
template("templates/#{template_name}.erb", "src/main/webapp/WEB-INF/views/#{@model}/#{file_name}.ftl")
|
12
16
|
end
|
13
17
|
|
14
18
|
def path
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<% @attributes.each do |att| -%>
|
8
8
|
<div class="field">
|
9
9
|
<%= att.name.capitalize %>:<br />
|
10
|
-
|
10
|
+
<%= "<@html.#{att.html_input} \"#{@model}.#{att.name}\" #{@model}.#{att.name}/>" %>
|
11
11
|
</div>
|
12
12
|
<% end -%>
|
13
13
|
<div class="actions">
|
@@ -14,7 +14,10 @@
|
|
14
14
|
<#list <%= "#{@model}List as #@model" %>>
|
15
15
|
<tr>
|
16
16
|
<% @attributes.each do |att| -%>
|
17
|
-
<td
|
17
|
+
<td>
|
18
|
+
<%= "${#{@model}.#{att.name}!\"\"}" unless att.boolean? %>
|
19
|
+
<%= "${#{@model}.#{att.name}?string}" if att.boolean? %>
|
20
|
+
</td>
|
18
21
|
<% end -%>
|
19
22
|
<td><a href="<%= "#{path}/${#{@model}.id}/show" %>">show</a></td>
|
20
23
|
<td><a href="<%= "#{path}/${#{@model}.id}/edit" %>">edit</a></td>
|
@@ -3,8 +3,9 @@ class ScaffoldGenerator
|
|
3
3
|
attr_accessor :attributes, :model
|
4
4
|
|
5
5
|
def initialize(args)
|
6
|
-
@model = args.
|
7
|
-
|
6
|
+
@model = args.shift.downcase
|
7
|
+
@attributes = []
|
8
|
+
validate_scaffold_command(args)
|
8
9
|
end
|
9
10
|
|
10
11
|
def build
|
@@ -14,11 +15,27 @@ class ScaffoldGenerator
|
|
14
15
|
end
|
15
16
|
|
16
17
|
private
|
17
|
-
def
|
18
|
-
|
18
|
+
def validate_scaffold_command(args)
|
19
|
+
unless File.exist?("pom.xml")
|
20
|
+
puts "To run scaffold please go to the project root folder."
|
21
|
+
Kernel::exit
|
22
|
+
end
|
23
|
+
validate_parse_attributes(args)
|
24
|
+
end
|
25
|
+
|
26
|
+
def validate_parse_attributes(args)
|
19
27
|
args.each do |arg|
|
20
28
|
parsedAttribute = arg.split(":")
|
21
|
-
|
29
|
+
validate_parse_attribute(parsedAttribute)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate_parse_attribute(parsedAttribute)
|
34
|
+
type = parsedAttribute.last.downcase
|
35
|
+
unless Attribute.valid_types.include?(type)
|
36
|
+
puts "Attribute #{type} is not supported. The supported attributes types are: #{Attribute.valid_types.join(" ")}"
|
37
|
+
Kernel::exit
|
22
38
|
end
|
39
|
+
@attributes << Attribute.new(parsedAttribute.first, type)
|
23
40
|
end
|
24
41
|
end
|
data/lib/vraptor-scaffold.rb
CHANGED
@@ -3,9 +3,10 @@ require File.dirname(__FILE__) + '/load_paths'
|
|
3
3
|
module VraptorScaffold
|
4
4
|
class Main
|
5
5
|
def self.execute(args)
|
6
|
-
|
6
|
+
action = args.shift
|
7
7
|
AppGenerator.new.build(args[0]) if action == "new"
|
8
8
|
ScaffoldGenerator.new(args).build if action == "scaffold"
|
9
|
+
exec("mvn compile war:inplace jetty:run") if action == "start"
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -3,28 +3,28 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
|
|
3
3
|
describe AppGenerator do
|
4
4
|
|
5
5
|
before(:all) do
|
6
|
-
@
|
7
|
-
AppGenerator.new.build(@
|
6
|
+
@project_path = "src/vraptor-scaffold"
|
7
|
+
AppGenerator.new.build(@project_path)
|
8
8
|
end
|
9
9
|
|
10
10
|
after(:all) do
|
11
|
-
FileUtils.remove_dir(@
|
11
|
+
FileUtils.remove_dir(@project_path)
|
12
12
|
end
|
13
13
|
|
14
14
|
context "build new application" do
|
15
15
|
it "should create directory with project name" do
|
16
|
-
File.exist?(@
|
16
|
+
File.exist?(@project_path).should be_true
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should create pom" do
|
20
20
|
from = File.expand_path(File.dirname(__FILE__) + "/templates/pom.xml")
|
21
|
-
to = "#{@
|
21
|
+
to = "#{@project_path}/pom.xml"
|
22
22
|
FileUtils.compare_file(from, to).should be_true
|
23
23
|
end
|
24
24
|
|
25
25
|
context "creating main java" do
|
26
26
|
before(:all) do
|
27
|
-
@main_java = "#{@
|
27
|
+
@main_java = "#{@project_path}/src/main/java"
|
28
28
|
@app = "#{@main_java}/app"
|
29
29
|
end
|
30
30
|
|
@@ -57,7 +57,7 @@ describe AppGenerator do
|
|
57
57
|
|
58
58
|
context "creating main resources" do
|
59
59
|
before(:all) do
|
60
|
-
@main_resources = "#{@
|
60
|
+
@main_resources = "#{@project_path}/src/main/resources"
|
61
61
|
@meta_inf = "#{@main_resources}/META-INF"
|
62
62
|
end
|
63
63
|
|
@@ -66,8 +66,8 @@ describe AppGenerator do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should create log4j" do
|
69
|
-
from = "#{AppGenerator.source_root}/templates/log4j.
|
70
|
-
to = "#{@main_resources}/log4j.
|
69
|
+
from = "#{AppGenerator.source_root}/templates/log4j.properties"
|
70
|
+
to = "#{@main_resources}/log4j.properties"
|
71
71
|
FileUtils.compare_file(from, to).should be_true
|
72
72
|
end
|
73
73
|
|
@@ -83,7 +83,7 @@ describe AppGenerator do
|
|
83
83
|
end
|
84
84
|
context "creating webapp" do
|
85
85
|
before(:all) do
|
86
|
-
@webapp = "#{@
|
86
|
+
@webapp = "#{@project_path}/src/main/webapp"
|
87
87
|
@web_inf = "#{@webapp}/WEB-INF"
|
88
88
|
@decorators = "#{@webapp}/decorators"
|
89
89
|
end
|
@@ -108,6 +108,12 @@ describe AppGenerator do
|
|
108
108
|
FileUtils.compare_file(from, to).should be_true
|
109
109
|
end
|
110
110
|
|
111
|
+
it "should create html macro file" do
|
112
|
+
from = "#{AppGenerator.source_root}/templates/macros/html.ftl"
|
113
|
+
to = "#{@webapp}/macros/html.ftl"
|
114
|
+
FileUtils.compare_file(from, to).should be_true
|
115
|
+
end
|
116
|
+
|
111
117
|
it "should create WEB-INF folder" do
|
112
118
|
File.exist?(@web_inf).should be_true
|
113
119
|
end
|
@@ -124,8 +130,8 @@ describe AppGenerator do
|
|
124
130
|
FileUtils.compare_file(from, to).should be_true
|
125
131
|
end
|
126
132
|
|
127
|
-
it "should create
|
128
|
-
File.exist?("#{@web_inf}/
|
133
|
+
it "should create views folder" do
|
134
|
+
File.exist?("#{@web_inf}/views").should be_true
|
129
135
|
end
|
130
136
|
|
131
137
|
it "should create scaffold css" do
|
@@ -142,8 +148,8 @@ describe AppGenerator do
|
|
142
148
|
end
|
143
149
|
context "creating test" do
|
144
150
|
before(:all) do
|
145
|
-
@test_java = "#{@
|
146
|
-
@test_resource = "#{@
|
151
|
+
@test_java = "#{@project_path}/src/test/java"
|
152
|
+
@test_resource = "#{@project_path}/src/test/java"
|
147
153
|
end
|
148
154
|
|
149
155
|
it "should create test source folder" do
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Attribute do
|
4
|
+
|
5
|
+
context "supported types" do
|
6
|
+
it "should support boolean" do
|
7
|
+
Attribute.valid_types.include?"boolean".should be_true
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should support double" do
|
11
|
+
Attribute.valid_types.include?"double".should be_true
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should support string" do
|
15
|
+
Attribute.valid_types.include?"string".should be_true
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should support float" do
|
19
|
+
Attribute.valid_types.include?"float".should be_true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should support short" do
|
23
|
+
Attribute.valid_types.include?"short".should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should support integer" do
|
27
|
+
Attribute.valid_types.include?"integer".should be_true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should support long" do
|
31
|
+
Attribute.valid_types.include?"long".should be_true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "html_input" do
|
36
|
+
it "should know html input to boolean" do
|
37
|
+
Attribute.new("flag", "boolean").html_input.should eql("checkbox")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should know html input to string" do
|
41
|
+
Attribute.new("name", "string").html_input.should eql("text")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should know html input to double" do
|
45
|
+
Attribute.new("name", "double").html_input.should eql("text")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should know html input to float" do
|
49
|
+
Attribute.new("name", "float").html_input.should eql("text")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should know html input to short" do
|
53
|
+
Attribute.new("name", "short").html_input.should eql("text")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should know html input to integer" do
|
57
|
+
Attribute.new("name", "integer").html_input.should eql("text")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should know html input to long" do
|
61
|
+
Attribute.new("name", "long").html_input.should eql("text")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "set type" do
|
66
|
+
it "should set corret type to boolean" do
|
67
|
+
Attribute.new("flag", "boolean").type.should eql("boolean")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should set corret type otherwise" do
|
71
|
+
Attribute.new("id", "long").type.should eql("Long")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should be boolean when type is boolean" do
|
76
|
+
Attribute.new("flag", "boolean").boolean?.should be_true
|
77
|
+
end
|
78
|
+
|
79
|
+
it "cannot be boolean otherwise" do
|
80
|
+
Attribute.new("flag", "short").boolean?.should be_false
|
81
|
+
end
|
82
|
+
end
|
data/spec/lib/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb
CHANGED
@@ -12,19 +12,19 @@ describe FreemarkerGenerator do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should create index view" do
|
15
|
-
File.exist?("src/main/webapp/WEB-INF/
|
15
|
+
File.exist?("src/main/webapp/WEB-INF/views/product/index.ftl").should be_true
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should create show view" do
|
19
|
-
File.exist?("src/main/webapp/WEB-INF/
|
19
|
+
File.exist?("src/main/webapp/WEB-INF/views/product/show.ftl").should be_true
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should create new view" do
|
23
|
-
File.exist?("src/main/webapp/WEB-INF/
|
23
|
+
File.exist?("src/main/webapp/WEB-INF/views/product/newProduct.ftl").should be_true
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
it "should create edit view" do
|
27
|
-
File.exist?("src/main/webapp/WEB-INF/
|
27
|
+
File.exist?("src/main/webapp/WEB-INF/views/product/edit.ftl").should be_true
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
@@ -11,7 +11,7 @@ public class Product {
|
|
11
11
|
private Long id;
|
12
12
|
|
13
13
|
private String name;
|
14
|
-
private
|
14
|
+
private boolean flag;
|
15
15
|
|
16
16
|
public void setId(Long id) {
|
17
17
|
this.id = id;
|
@@ -29,12 +29,12 @@ public class Product {
|
|
29
29
|
return name;
|
30
30
|
}
|
31
31
|
|
32
|
-
public void
|
33
|
-
this.
|
32
|
+
public void setFlag(boolean flag) {
|
33
|
+
this.flag = flag;
|
34
34
|
}
|
35
35
|
|
36
|
-
public
|
37
|
-
return
|
36
|
+
public boolean getFlag() {
|
37
|
+
return flag;
|
38
38
|
}
|
39
39
|
|
40
40
|
}
|
@@ -3,24 +3,44 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
|
|
3
3
|
describe ScaffoldGenerator do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
args = ["product", "name:
|
7
|
-
|
6
|
+
@args = ["product", "name:String", "value:double"]
|
7
|
+
end
|
8
|
+
|
9
|
+
context "invalid scaffold command" do
|
10
|
+
it "outside project root" do
|
11
|
+
File.stub!(:exist?).with("pom.xml").and_return(false)
|
12
|
+
Kernel.should_receive(:exit)
|
13
|
+
ScaffoldGenerator.new(@args)
|
14
|
+
end
|
8
15
|
|
9
|
-
|
10
|
-
|
16
|
+
it "invalid attribute type" do
|
17
|
+
File.stub!(:exist?).and_return(true)
|
18
|
+
args = ["product", "name:string", "value:char"]
|
19
|
+
Kernel.should_receive(:exit)
|
20
|
+
ScaffoldGenerator.new(args)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "valid scaffold command" do
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
File.stub!(:exist?).and_return(true)
|
28
|
+
@generator = ScaffoldGenerator.new(@args)
|
11
29
|
|
12
|
-
|
30
|
+
@model_generator = mock(ModelGenerator)
|
31
|
+
ModelGenerator.stub!(:new).with(@generator.model, @generator.attributes).and_return(@model_generator)
|
13
32
|
|
14
|
-
|
15
|
-
|
16
|
-
|
33
|
+
@controller_generator = mock(ControllerGenerator)
|
34
|
+
ControllerGenerator.stub!(:new).with(@generator.model, @generator.attributes).and_return(@controller_generator)
|
35
|
+
|
36
|
+
@freemarker_generator = mock(FreemarkerGenerator)
|
37
|
+
FreemarkerGenerator.stub!(:new).with(@generator.model, @generator.attributes).and_return(@freemarker_generator)
|
17
38
|
|
18
39
|
@model_generator.stub!(:build)
|
19
40
|
@controller_generator.stub!(:build)
|
20
41
|
@freemarker_generator.stub!(:build)
|
21
42
|
end
|
22
|
-
|
23
|
-
context "build scaffold" do
|
43
|
+
|
24
44
|
it "should call model generator" do
|
25
45
|
@model_generator.should_receive(:build)
|
26
46
|
@generator.build
|
@@ -16,7 +16,7 @@ describe VraptorScaffold::Main do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "cannot call app generator when not typed new" do
|
19
|
-
@args.
|
19
|
+
@args.shift
|
20
20
|
@generator.should_not_receive(:build)
|
21
21
|
VraptorScaffold::Main.execute(@args)
|
22
22
|
end
|
@@ -34,4 +34,11 @@ describe VraptorScaffold::Main do
|
|
34
34
|
VraptorScaffold::Main.execute(@args)
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
context "web server" do
|
39
|
+
it "should start server when typed start" do
|
40
|
+
VraptorScaffold::Main.should_receive(:exec).with("mvn compile war:inplace jetty:run")
|
41
|
+
VraptorScaffold::Main.execute(["start"])
|
42
|
+
end
|
43
|
+
end
|
37
44
|
end
|
data/spec/spec_helper.rb
CHANGED
data/vraptor-scaffold.gemspec
CHANGED
@@ -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.
|
8
|
+
s.version = "0.0.1.beta3"
|
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-
|
12
|
+
s.date = %q{2010-07-11}
|
13
13
|
s.default_executable = %q{vraptor}
|
14
14
|
s.description = %q{}
|
15
15
|
s.email = %q{rodolfoliviero@gmail.com}
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
".document",
|
23
23
|
".gitignore",
|
24
24
|
"Gemfile",
|
25
|
+
"History.txt",
|
25
26
|
"LICENSE",
|
26
27
|
"README.rdoc",
|
27
28
|
"Rakefile",
|
@@ -33,7 +34,8 @@ Gem::Specification.new do |s|
|
|
33
34
|
"lib/generators/app_generator/templates/decorators.xml",
|
34
35
|
"lib/generators/app_generator/templates/index.jsp",
|
35
36
|
"lib/generators/app_generator/templates/javascripts/jquery-1.4.2.min.js",
|
36
|
-
"lib/generators/app_generator/templates/log4j.
|
37
|
+
"lib/generators/app_generator/templates/log4j.properties",
|
38
|
+
"lib/generators/app_generator/templates/macros/html.ftl",
|
37
39
|
"lib/generators/app_generator/templates/main.ftl",
|
38
40
|
"lib/generators/app_generator/templates/persistence.xml",
|
39
41
|
"lib/generators/app_generator/templates/pom.erb",
|
@@ -90,9 +92,21 @@ Gem::Specification.new do |s|
|
|
90
92
|
s.specification_version = 3
|
91
93
|
|
92
94
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
95
|
+
s.add_runtime_dependency(%q<thor>, [">= 0.13.7"])
|
96
|
+
s.add_runtime_dependency(%q<rake>, [">= 0.8.7"])
|
97
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.8"])
|
98
|
+
s.add_runtime_dependency(%q<bundler>, [">= 1.0.0.beta.2"])
|
93
99
|
else
|
100
|
+
s.add_dependency(%q<thor>, [">= 0.13.7"])
|
101
|
+
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
102
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.8"])
|
103
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0.beta.2"])
|
94
104
|
end
|
95
105
|
else
|
106
|
+
s.add_dependency(%q<thor>, [">= 0.13.7"])
|
107
|
+
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
108
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.8"])
|
109
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0.beta.2"])
|
96
110
|
end
|
97
111
|
end
|
98
112
|
|
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:
|
4
|
+
hash: 299253583
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- 1
|
10
|
-
-
|
11
|
-
version: 0.0.1.
|
10
|
+
- beta3
|
11
|
+
version: 0.0.1.beta3
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Rodolfo Liviero
|
@@ -16,10 +16,75 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-07-
|
19
|
+
date: 2010-07-11 00:00:00 -03:00
|
20
20
|
default_executable: vraptor
|
21
|
-
dependencies:
|
22
|
-
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: thor
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 37
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
- 13
|
34
|
+
- 7
|
35
|
+
version: 0.13.7
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rake
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 49
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
- 8
|
50
|
+
- 7
|
51
|
+
version: 0.8.7
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: activesupport
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 19
|
63
|
+
segments:
|
64
|
+
- 2
|
65
|
+
- 3
|
66
|
+
- 8
|
67
|
+
version: 2.3.8
|
68
|
+
type: :runtime
|
69
|
+
version_requirements: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: bundler
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 62196359
|
79
|
+
segments:
|
80
|
+
- 1
|
81
|
+
- 0
|
82
|
+
- 0
|
83
|
+
- beta
|
84
|
+
- 2
|
85
|
+
version: 1.0.0.beta.2
|
86
|
+
type: :runtime
|
87
|
+
version_requirements: *id004
|
23
88
|
description: ""
|
24
89
|
email: rodolfoliviero@gmail.com
|
25
90
|
executables:
|
@@ -33,6 +98,7 @@ files:
|
|
33
98
|
- .document
|
34
99
|
- .gitignore
|
35
100
|
- Gemfile
|
101
|
+
- History.txt
|
36
102
|
- LICENSE
|
37
103
|
- README.rdoc
|
38
104
|
- Rakefile
|
@@ -44,7 +110,8 @@ files:
|
|
44
110
|
- lib/generators/app_generator/templates/decorators.xml
|
45
111
|
- lib/generators/app_generator/templates/index.jsp
|
46
112
|
- lib/generators/app_generator/templates/javascripts/jquery-1.4.2.min.js
|
47
|
-
- lib/generators/app_generator/templates/log4j.
|
113
|
+
- lib/generators/app_generator/templates/log4j.properties
|
114
|
+
- lib/generators/app_generator/templates/macros/html.ftl
|
48
115
|
- lib/generators/app_generator/templates/main.ftl
|
49
116
|
- lib/generators/app_generator/templates/persistence.xml
|
50
117
|
- lib/generators/app_generator/templates/pom.erb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
3
|
-
|
4
|
-
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
|
5
|
-
<layout class="org.apache.log4j.PatternLayout">
|
6
|
-
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %5p [%-20c{1}] %m%n" />
|
7
|
-
</layout>
|
8
|
-
</appender>
|
9
|
-
|
10
|
-
<logger name="org.hibernate">
|
11
|
-
<level value="WARN" />
|
12
|
-
<appender-ref ref="CONSOLE" />
|
13
|
-
</logger>
|
14
|
-
|
15
|
-
<root>
|
16
|
-
<priority value="INFO" />
|
17
|
-
<appender-ref ref="CONSOLE" />
|
18
|
-
</root>
|
19
|
-
|
20
|
-
</log4j:configuration>
|