kwatable 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.txt +15 -3
- data/README.txt +1 -1
- data/bin/kwatable +3 -9
- data/examples/ex1/Makefile +18 -26
- data/examples/ex1/example1.yaml +9 -6
- data/examples/ex2/Makefile +15 -24
- data/kwatable.gemspec +2 -2
- data/lib/kwatable.rb +1 -1
- data/lib/kwatable/error-msg.rb +1 -1
- data/lib/kwatable/kwatable.schema.yaml +12 -2
- data/lib/kwatable/main-program.rb +18 -7
- data/lib/kwatable/manipulator.rb +3 -3
- data/lib/kwatable/templates/ddl-mysql.eruby +1 -1
- data/lib/kwatable/templates/ddl-postgresql.eruby +3 -3
- data/lib/kwatable/templates/defaults.yaml +1 -1
- data/lib/kwatable/templates/dto-java.eruby +75 -9
- data/lib/kwatable/templates/dto-ruby.eruby +27 -15
- data/lib/kwatable/templates/validator-ruby.eruby +97 -0
- data/test/assert-diff.rb +1 -1
- data/test/test.rb +80 -151
- metadata +4 -25
- data/test/test1/test1.ddl-mysql.expected +0 -23
- data/test/test1/test1.ddl-postgresql.expected +0 -23
- data/test/test1/test1.dto-java.Group.expected +0 -35
- data/test/test1/test1.dto-java.User.expected +0 -57
- data/test/test1/test1.dto-ruby.Group.expected +0 -20
- data/test/test1/test1.dto-ruby.User.expected +0 -33
- data/test/test1/test1.yaml +0 -96
- data/test/test2/test2.ddl-mysql.expected +0 -49
- data/test/test2/test2.ddl-postgresql.expected +0 -49
- data/test/test2/test2.dto-java.Address.expected +0 -40
- data/test/test2/test2.dto-java.Customer.expected +0 -47
- data/test/test2/test2.dto-java.Item.expected +0 -35
- data/test/test2/test2.dto-java.SalesOrder.expected +0 -48
- data/test/test2/test2.dto-java.SalesOrderLine.expected +0 -54
- data/test/test2/test2.dto-ruby.Address.expected +0 -22
- data/test/test2/test2.dto-ruby.Customer.expected +0 -29
- data/test/test2/test2.dto-ruby.Item.expected +0 -20
- data/test/test2/test2.dto-ruby.SalesOrder.expected +0 -29
- data/test/test2/test2.dto-ruby.SalesOrderLine.expected +0 -36
- data/test/test2/test2.yaml +0 -94
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
!ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
rubygems_version: 0.8.11
|
3
3
|
specification_version: 1
|
4
4
|
name: kwatable
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date:
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2006-03-06 00:00:00 +09:00
|
8
8
|
summary: SQL and DTO generator from table definition
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/kwatable/templates/defaults.yaml
|
41
41
|
- lib/kwatable/templates/dto-java.eruby
|
42
42
|
- lib/kwatable/templates/dto-ruby.eruby
|
43
|
+
- lib/kwatable/templates/validator-ruby.eruby
|
43
44
|
- bin/kwatable
|
44
45
|
- examples/ex1
|
45
46
|
- examples/ex2
|
@@ -49,28 +50,6 @@ files:
|
|
49
50
|
- examples/ex2/Makefile
|
50
51
|
- test/assert-diff.rb
|
51
52
|
- test/test.rb
|
52
|
-
- test/test1
|
53
|
-
- test/test2
|
54
|
-
- test/test1/test1.ddl-mysql.expected
|
55
|
-
- test/test1/test1.ddl-postgresql.expected
|
56
|
-
- test/test1/test1.dto-java.Group.expected
|
57
|
-
- test/test1/test1.dto-java.User.expected
|
58
|
-
- test/test1/test1.dto-ruby.Group.expected
|
59
|
-
- test/test1/test1.dto-ruby.User.expected
|
60
|
-
- test/test1/test1.yaml
|
61
|
-
- test/test2/test2.ddl-mysql.expected
|
62
|
-
- test/test2/test2.ddl-postgresql.expected
|
63
|
-
- test/test2/test2.dto-java.Address.expected
|
64
|
-
- test/test2/test2.dto-java.Customer.expected
|
65
|
-
- test/test2/test2.dto-java.Item.expected
|
66
|
-
- test/test2/test2.dto-java.SalesOrder.expected
|
67
|
-
- test/test2/test2.dto-java.SalesOrderLine.expected
|
68
|
-
- test/test2/test2.dto-ruby.Address.expected
|
69
|
-
- test/test2/test2.dto-ruby.Customer.expected
|
70
|
-
- test/test2/test2.dto-ruby.Item.expected
|
71
|
-
- test/test2/test2.dto-ruby.SalesOrder.expected
|
72
|
-
- test/test2/test2.dto-ruby.SalesOrderLine.expected
|
73
|
-
- test/test2/test2.yaml
|
74
53
|
- README.txt
|
75
54
|
- ChangeLog.txt
|
76
55
|
- COPYING
|
@@ -1,23 +0,0 @@
|
|
1
|
-
----------------------------------------------------------------------
|
2
|
-
-- DDL for MySQL
|
3
|
-
-- generated by kwatable with template 'ddl-mysql.eruby'
|
4
|
-
----------------------------------------------------------------------
|
5
|
-
|
6
|
-
-- Group master table
|
7
|
-
create table groups (
|
8
|
-
id integer auto_increment primary key,
|
9
|
-
name varchar(63) not null,
|
10
|
-
`desc` varchar(255) ,
|
11
|
-
class enum('ADMIN', 'SYSTEM', 'USER', 'UNUSED')
|
12
|
-
);
|
13
|
-
|
14
|
-
-- User master table
|
15
|
-
create table users (
|
16
|
-
id integer auto_increment primary key,
|
17
|
-
name varchar(63) not null,
|
18
|
-
`desc` varchar(255) ,
|
19
|
-
email varchar(63) ,
|
20
|
-
group_id integer , -- references groups(id)
|
21
|
-
account varchar(31) not null,
|
22
|
-
password varchar(31) not null
|
23
|
-
);
|
@@ -1,23 +0,0 @@
|
|
1
|
-
----------------------------------------------------------------------
|
2
|
-
-- DDL for PostgreSQL
|
3
|
-
-- generated by kwatable with template 'ddl-postgresql.eruby'
|
4
|
-
----------------------------------------------------------------------
|
5
|
-
|
6
|
-
-- Group master table
|
7
|
-
create table groups (
|
8
|
-
id serial primary key,
|
9
|
-
name varchar(63) not null,
|
10
|
-
"desc" varchar(255) ,
|
11
|
-
class varchar(6) -- ADMIN,SYSTEM,USER,UNUSED
|
12
|
-
);
|
13
|
-
|
14
|
-
-- User master table
|
15
|
-
create table users (
|
16
|
-
id serial primary key,
|
17
|
-
name varchar(63) not null,
|
18
|
-
"desc" varchar(255) ,
|
19
|
-
email varchar(63) ,
|
20
|
-
group_id integer references groups(id),
|
21
|
-
account varchar(31) not null,
|
22
|
-
password varchar(31) not null
|
23
|
-
);
|
@@ -1,35 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* DTO for Java
|
3
|
-
* generated by kwatable with template 'dto-java.eruby'
|
4
|
-
*/
|
5
|
-
|
6
|
-
/**
|
7
|
-
* Group master table
|
8
|
-
*/
|
9
|
-
public class Group implements java.io.Serializable {
|
10
|
-
|
11
|
-
private int id; /* group id */
|
12
|
-
private String name; /* group name */
|
13
|
-
private String desc; /* group description */
|
14
|
-
private String _class; /* group class */
|
15
|
-
|
16
|
-
public void populate(java.sql.ResultSet resultset) {
|
17
|
-
setId(resultset.getInt("id"));
|
18
|
-
setName(resultset.getString("name"));
|
19
|
-
setDesc(resultset.getString("desc"));
|
20
|
-
setClass(resultset.getString("class"));
|
21
|
-
}
|
22
|
-
|
23
|
-
public int getId() { return id }
|
24
|
-
public void setId(int id) { this.id = id; }
|
25
|
-
|
26
|
-
public String getName() { return name }
|
27
|
-
public void setName(String name) { this.name = name; }
|
28
|
-
|
29
|
-
public String getDesc() { return desc }
|
30
|
-
public void setDesc(String desc) { this.desc = desc; }
|
31
|
-
|
32
|
-
public String getClass() { return _class }
|
33
|
-
public void setClass(String _class) { this._class = _class; }
|
34
|
-
|
35
|
-
}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* DTO for Java
|
3
|
-
* generated by kwatable with template 'dto-java.eruby'
|
4
|
-
*/
|
5
|
-
|
6
|
-
/**
|
7
|
-
* User master table
|
8
|
-
*/
|
9
|
-
public class User implements java.io.Serializable {
|
10
|
-
|
11
|
-
private int id; /* user id */
|
12
|
-
private String name; /* user name */
|
13
|
-
private String desc; /* description about user */
|
14
|
-
private String email; /* */
|
15
|
-
private int group_id; /* group id to which user belongs */
|
16
|
-
private String account; /* */
|
17
|
-
private String password; /* */
|
18
|
-
|
19
|
-
public void populate(java.sql.ResultSet resultset) {
|
20
|
-
setId(resultset.getInt("id"));
|
21
|
-
setName(resultset.getString("name"));
|
22
|
-
setDesc(resultset.getString("desc"));
|
23
|
-
setEmail(resultset.getString("email"));
|
24
|
-
setGroupId(resultset.getInt("group_id"));
|
25
|
-
setAccount(resultset.getString("account"));
|
26
|
-
setPassword(resultset.getString("password"));
|
27
|
-
}
|
28
|
-
|
29
|
-
public int getId() { return id }
|
30
|
-
public void setId(int id) { this.id = id; }
|
31
|
-
|
32
|
-
public String getName() { return name }
|
33
|
-
public void setName(String name) { this.name = name; }
|
34
|
-
|
35
|
-
public String getDesc() { return desc }
|
36
|
-
public void setDesc(String desc) { this.desc = desc; }
|
37
|
-
|
38
|
-
public String getEmail() { return email }
|
39
|
-
public void setEmail(String email) { this.email = email; }
|
40
|
-
|
41
|
-
public int getGroupId() { return group_id }
|
42
|
-
public void setGroupId(int group_id) { this.group_id = group_id; }
|
43
|
-
|
44
|
-
public String getAccount() { return account }
|
45
|
-
public void setAccount(String account) { this.account = account; }
|
46
|
-
|
47
|
-
public String getPassword() { return password }
|
48
|
-
public void setPassword(String password) { this.password = password; }
|
49
|
-
|
50
|
-
private Group group;
|
51
|
-
public Group getGroup() { return group; }
|
52
|
-
public void setGroup(Group group) {
|
53
|
-
this.group = group;
|
54
|
-
this.group_id = group.getId();
|
55
|
-
}
|
56
|
-
|
57
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
##
|
2
|
-
## DTO for Ruby
|
3
|
-
## generated by kwatable with template 'dto-ruby.eruby'
|
4
|
-
##
|
5
|
-
|
6
|
-
## Group master table
|
7
|
-
class Group
|
8
|
-
def populate(values={})
|
9
|
-
self.id = values['id']
|
10
|
-
self.name = values['name']
|
11
|
-
self.desc = values['desc']
|
12
|
-
self.class = values['class']
|
13
|
-
end
|
14
|
-
|
15
|
-
attr_accessor :id # group id
|
16
|
-
attr_accessor :name # group name
|
17
|
-
attr_accessor :desc # group description
|
18
|
-
attr_accessor :class # group class
|
19
|
-
|
20
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
##
|
2
|
-
## DTO for Ruby
|
3
|
-
## generated by kwatable with template 'dto-ruby.eruby'
|
4
|
-
##
|
5
|
-
require 'Group'
|
6
|
-
|
7
|
-
## User master table
|
8
|
-
class User
|
9
|
-
def populate(values={})
|
10
|
-
self.id = values['id']
|
11
|
-
self.name = values['name']
|
12
|
-
self.desc = values['desc']
|
13
|
-
self.email = values['email']
|
14
|
-
self.group_id = values['group_id']
|
15
|
-
self.account = values['account']
|
16
|
-
self.password = values['password']
|
17
|
-
end
|
18
|
-
|
19
|
-
attr_accessor :id # user id
|
20
|
-
attr_accessor :name # user name
|
21
|
-
attr_accessor :desc # description about user
|
22
|
-
attr_accessor :email #
|
23
|
-
attr_accessor :group_id # group id to which user belongs
|
24
|
-
attr_accessor :account #
|
25
|
-
attr_accessor :password #
|
26
|
-
|
27
|
-
attr_reader :group
|
28
|
-
def group=(group)
|
29
|
-
@group = group
|
30
|
-
@group_id = group.id
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
data/test/test1/test1.yaml
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
##
|
2
|
-
## example data file for kwatable
|
3
|
-
##
|
4
|
-
## copyright(c) 2005 kuwata-lab.com all rights reserved.
|
5
|
-
## $Release: 0.1.0 $
|
6
|
-
## $Rev: 13 $
|
7
|
-
##
|
8
|
-
|
9
|
-
columns:
|
10
|
-
- name: id
|
11
|
-
type: integer
|
12
|
-
ident: yes
|
13
|
-
serial: yes
|
14
|
-
|
15
|
-
- name: name
|
16
|
-
type: string
|
17
|
-
required: yes
|
18
|
-
width: 63
|
19
|
-
|
20
|
-
- name: desc
|
21
|
-
type: string
|
22
|
-
|
23
|
-
- name: email
|
24
|
-
type: string
|
25
|
-
width: 63
|
26
|
-
|
27
|
-
- name: status
|
28
|
-
type: string
|
29
|
-
width: 15
|
30
|
-
|
31
|
-
- name: username
|
32
|
-
type: string
|
33
|
-
width: 31
|
34
|
-
|
35
|
-
- name: password
|
36
|
-
type: string
|
37
|
-
width: 31
|
38
|
-
|
39
|
-
- name: memo
|
40
|
-
type: text
|
41
|
-
|
42
|
-
- name: text
|
43
|
-
type: text
|
44
|
-
|
45
|
-
- name: birth
|
46
|
-
type: date
|
47
|
-
|
48
|
-
- name: age
|
49
|
-
type: integer
|
50
|
-
|
51
|
-
- name: last_update
|
52
|
-
type: timestamp
|
53
|
-
|
54
|
-
- name: gender
|
55
|
-
type: string
|
56
|
-
enum:
|
57
|
-
- M
|
58
|
-
- F
|
59
|
-
|
60
|
-
tables:
|
61
|
-
- name: groups
|
62
|
-
class: Group
|
63
|
-
desc: Group master table
|
64
|
-
columns:
|
65
|
-
- name: id
|
66
|
-
desc: group id
|
67
|
-
- name: name
|
68
|
-
desc: group name
|
69
|
-
- name: desc
|
70
|
-
desc: group description
|
71
|
-
- name: class
|
72
|
-
desc: group class
|
73
|
-
type: string
|
74
|
-
enum: [ ADMIN, SYSTEM, USER, UNUSED ]
|
75
|
-
|
76
|
-
- name: users
|
77
|
-
class: User
|
78
|
-
desc: User master table
|
79
|
-
columns:
|
80
|
-
- name: id
|
81
|
-
desc: user id
|
82
|
-
- name: name
|
83
|
-
desc: user name
|
84
|
-
- name: desc
|
85
|
-
desc: description about user
|
86
|
-
- name: email
|
87
|
-
- name: group_id
|
88
|
-
ref: groups.id
|
89
|
-
desc: group id to which user belongs
|
90
|
-
- name: account
|
91
|
-
type: string
|
92
|
-
width: 31
|
93
|
-
required: yes
|
94
|
-
- name: password
|
95
|
-
required: yes
|
96
|
-
|
@@ -1,49 +0,0 @@
|
|
1
|
-
----------------------------------------------------------------------
|
2
|
-
-- DDL for MySQL
|
3
|
-
-- generated by kwatable with template 'ddl-mysql.eruby'
|
4
|
-
----------------------------------------------------------------------
|
5
|
-
|
6
|
-
-- Address master table
|
7
|
-
create table addresses (
|
8
|
-
id integer auto_increment primary key,
|
9
|
-
zipcode varchar(8) ,
|
10
|
-
addr1 varchar(255) ,
|
11
|
-
addr2 varchar(255) ,
|
12
|
-
addr3 varchar(255)
|
13
|
-
);
|
14
|
-
|
15
|
-
-- Customer master table
|
16
|
-
create table customers (
|
17
|
-
id integer auto_increment primary key,
|
18
|
-
name varchar(255) not null,
|
19
|
-
tel varchar(255) ,
|
20
|
-
email varchar(255) ,
|
21
|
-
address_id integer not null -- references addresses(id)
|
22
|
-
);
|
23
|
-
|
24
|
-
-- Item master table
|
25
|
-
create table items (
|
26
|
-
id integer auto_increment primary key,
|
27
|
-
name varchar(255) not null,
|
28
|
-
`desc` varchar(255) ,
|
29
|
-
price decimal not null
|
30
|
-
);
|
31
|
-
|
32
|
-
-- Sales order master table
|
33
|
-
create table sales_orders (
|
34
|
-
id integer auto_increment primary key,
|
35
|
-
customer_id integer not null, -- references customers(id)
|
36
|
-
ordered_date date not null,
|
37
|
-
delivery_date date ,
|
38
|
-
amount decimal
|
39
|
-
);
|
40
|
-
|
41
|
-
-- Sales Order detail lines
|
42
|
-
create table sales_order_lines (
|
43
|
-
num integer not null,
|
44
|
-
order_id integer not null, -- references sales_orders(id)
|
45
|
-
item_id integer not null, -- references items(id)
|
46
|
-
price decimal not null,
|
47
|
-
quantity integer not null
|
48
|
-
, primary key (order_id, item_id)
|
49
|
-
);
|
@@ -1,49 +0,0 @@
|
|
1
|
-
----------------------------------------------------------------------
|
2
|
-
-- DDL for PostgreSQL
|
3
|
-
-- generated by kwatable with template 'ddl-postgresql.eruby'
|
4
|
-
----------------------------------------------------------------------
|
5
|
-
|
6
|
-
-- Address master table
|
7
|
-
create table addresses (
|
8
|
-
id serial primary key,
|
9
|
-
zipcode varchar(8) ,
|
10
|
-
addr1 varchar(255) ,
|
11
|
-
addr2 varchar(255) ,
|
12
|
-
addr3 varchar(255)
|
13
|
-
);
|
14
|
-
|
15
|
-
-- Customer master table
|
16
|
-
create table customers (
|
17
|
-
id serial primary key,
|
18
|
-
name varchar(255) not null,
|
19
|
-
tel varchar(255) ,
|
20
|
-
email varchar(255) ,
|
21
|
-
address_id integer not null references addresses(id)
|
22
|
-
);
|
23
|
-
|
24
|
-
-- Item master table
|
25
|
-
create table items (
|
26
|
-
id serial primary key,
|
27
|
-
name varchar(255) not null,
|
28
|
-
"desc" varchar(255) ,
|
29
|
-
price decimal not null
|
30
|
-
);
|
31
|
-
|
32
|
-
-- Sales order master table
|
33
|
-
create table sales_orders (
|
34
|
-
id serial primary key,
|
35
|
-
customer_id integer not null references customers(id),
|
36
|
-
ordered_date date not null,
|
37
|
-
delivery_date date ,
|
38
|
-
amount decimal
|
39
|
-
);
|
40
|
-
|
41
|
-
-- Sales Order detail lines
|
42
|
-
create table sales_order_lines (
|
43
|
-
num integer not null,
|
44
|
-
order_id integer not null references sales_orders(id),
|
45
|
-
item_id integer not null references items(id),
|
46
|
-
price decimal not null,
|
47
|
-
quantity integer not null
|
48
|
-
, primary key (order_id, item_id)
|
49
|
-
);
|