kwatable 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/ChangeLog +46 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.txt +4 -2
  4. data/bin/kwatable +4 -4
  5. data/examples/ex1/Makefile +40 -14
  6. data/examples/ex1/{example1.yaml → tabledef.yaml} +42 -11
  7. data/examples/ex2/Makefile +41 -14
  8. data/examples/ex2/{example2.yaml → tabledef.yaml} +45 -30
  9. data/examples/ex3/Makefile +52 -0
  10. data/examples/ex3/tabledef.yaml +136 -0
  11. data/kwatable.gemspec +11 -10
  12. data/lib/kwatable.rb +24 -18
  13. data/lib/kwatable/kwatable.schema.yaml +95 -5
  14. data/lib/kwatable/main.rb +331 -0
  15. data/lib/kwatable/manipulator.rb +320 -192
  16. data/lib/kwatable/messages.rb +59 -0
  17. data/lib/kwatable/template/ddl-mysql.eruby +202 -0
  18. data/lib/kwatable/{templates → template}/ddl-postgresql.eruby +71 -45
  19. data/lib/kwatable/{templates → template}/defaults.yaml +2 -2
  20. data/lib/kwatable/template/dictionary.en.yaml +70 -0
  21. data/lib/kwatable/template/dictionary.ja.yaml +165 -0
  22. data/lib/kwatable/template/dto-java.eruby +77 -0
  23. data/lib/kwatable/template/dto-java.sub.eruby +259 -0
  24. data/lib/kwatable/template/dto-ruby.eruby +63 -0
  25. data/lib/kwatable/template/dto-ruby.sub.eruby +213 -0
  26. data/lib/kwatable/template/helper/column.rb +70 -0
  27. data/lib/kwatable/template/helper/common.rb +151 -0
  28. data/lib/kwatable/template/helper/java.rb +83 -0
  29. data/lib/kwatable/template/helper/label.rb +90 -0
  30. data/lib/kwatable/template/helper/ruby.rb +36 -0
  31. data/lib/kwatable/template/helper/table.rb +62 -0
  32. data/lib/kwatable/template/hibernate.eruby +139 -0
  33. data/lib/kwatable/template/rails-controller.eruby +66 -0
  34. data/lib/kwatable/template/rails-controller.sub.eruby +114 -0
  35. data/lib/kwatable/template/rails-kwartz.eruby +164 -0
  36. data/lib/kwatable/template/rails-kwartz/_attr.plogic.eruby +56 -0
  37. data/lib/kwatable/template/rails-kwartz/_form.plogic.eruby +81 -0
  38. data/lib/kwatable/template/rails-kwartz/_link.plogic.eruby +36 -0
  39. data/lib/kwatable/template/rails-kwartz/edit.cfg.yaml.eruby +16 -0
  40. data/lib/kwatable/template/rails-kwartz/edit.html.eruby +46 -0
  41. data/lib/kwatable/template/rails-kwartz/edit.plogic.eruby +20 -0
  42. data/lib/kwatable/template/rails-kwartz/layout.html.eruby +39 -0
  43. data/lib/kwatable/template/rails-kwartz/layout.plogic.eruby +32 -0
  44. data/lib/kwatable/template/rails-kwartz/list.html.eruby +94 -0
  45. data/lib/kwatable/template/rails-kwartz/list.plogic.eruby +41 -0
  46. data/lib/kwatable/template/rails-kwartz/new.html.eruby +100 -0
  47. data/lib/kwatable/template/rails-kwartz/new.plogic.eruby +26 -0
  48. data/lib/kwatable/template/rails-kwartz/show.html.eruby +51 -0
  49. data/lib/kwatable/template/rails-kwartz/show.plogic.eruby +9 -0
  50. data/lib/kwatable/template/rails-model.eruby +35 -0
  51. data/lib/kwatable/template/rails-model.sub.eruby +136 -0
  52. data/lib/kwatable/{templates → template}/validator-ruby.eruby +18 -11
  53. data/lib/kwatable/util.rb +133 -0
  54. data/lib/kwatable/util/assert-text-equal.rb +47 -0
  55. data/lib/kwatable/util/assertion.rb +115 -0
  56. data/lib/kwatable/validator.rb +50 -0
  57. data/test/assert-diff.rb +1 -1
  58. data/test/test-ex.rb +306 -0
  59. data/test/test.rb +37 -127
  60. metadata +66 -17
  61. data/COPYING +0 -340
  62. data/ChangeLog.txt +0 -65
  63. data/lib/kwatable/error-msg.rb +0 -38
  64. data/lib/kwatable/main-program.rb +0 -216
  65. data/lib/kwatable/templates/ddl-mysql.eruby +0 -172
  66. data/lib/kwatable/templates/dto-java.eruby +0 -260
  67. data/lib/kwatable/templates/dto-ruby.eruby +0 -185
@@ -0,0 +1,16 @@
1
+ <%
2
+ ###
3
+ ### $Rev$
4
+ ### $Release: 0.3.0 $
5
+ ### copyright(c) 2005 kuwata-lab.com all rights reserved.
6
+ ###
7
+
8
+
9
+ list_name, item_name, lang, charset, encoding = vars(@table)
10
+ %>
11
+ import_pdata:
12
+ - filename: new.html
13
+ patterns: [ form_content ]
14
+ #import_plogic:
15
+ # - filename: new.plogic
16
+ # patterns: [ <%= item_name %>_*, error_messages ]
@@ -0,0 +1,46 @@
1
+ <%
2
+ ###
3
+ ### $Rev$
4
+ ### $Release: 0.3.0 $
5
+ ### copyright(c) 2005 kuwata-lab.com all rights reserved.
6
+ ###
7
+
8
+
9
+ list_name, item_name, lang, charset, encoding = vars(@table)
10
+ header_title = w(:editing_item, to_label(item_name))
11
+ page_title = w(:editing_item, to_label(item_name))
12
+ encoding_attr = encoding ? " encoding=\"#{encoding}\"" : ''
13
+ lang_attr = lang ? " xml:lang=\"#{lang}\" lang=\"#{lang}\"" : ''
14
+ %>
15
+ <?xml version="1.0"<%= encoding_attr %>?>
16
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
17
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
18
+ <html xmlns="http://www.w3.org/1999/xhtml"<%= lang_attr %>>
19
+ <head>
20
+ <title><%=_ header_title %></title>
21
+ <%= stylesheets() %>
22
+
23
+ </head>
24
+ <body>
25
+
26
+ <h1 id="page_title"><%=_ page_title %></h1>
27
+
28
+ <div id="page_content">
29
+
30
+ <form action="update" id="mark:start_form">
31
+
32
+ <div id="replace_element_with_content:form_content">
33
+ ...
34
+ </div>
35
+
36
+ <input type="submit" id="mark:submit" />
37
+ </form>
38
+
39
+ <p>
40
+ <a href="#" id="mark:link_to_show"><%=_ w(:show) %></a> | <a href="#" id="mark:link_to_list"><%=_ w(:list) %></a>
41
+ </p>
42
+
43
+ </div>
44
+
45
+ </body>
46
+ </html>
@@ -0,0 +1,20 @@
1
+ <%
2
+ ###
3
+ ### $Rev$
4
+ ### $Release: 0.3.0 $
5
+ ### copyright(c) 2005 kuwata-lab.com all rights reserved.
6
+ ###
7
+
8
+
9
+ list_name, item_name, lang, charset, encoding = vars(@table)
10
+ %>
11
+ @import '_link.plogic';
12
+ @import '_form.plogic';
13
+
14
+ #start_form {
15
+ stag: start_form_tag :action=>'update', :id=>@<%=_ item_name %>.id;
16
+ }
17
+
18
+ #submit {
19
+ elem: submit_tag '<%=_ w(:edit) %>';
20
+ }
@@ -0,0 +1,39 @@
1
+ <%
2
+ ###
3
+ ### $Rev$
4
+ ### $Release: 0.3.0 $
5
+ ### copyright(c) 2005 kuwata-lab.com all rights reserved.
6
+ ###
7
+
8
+
9
+ list_name, item_name, lang, charset, encoding = vars(@table)
10
+ header_title = w(:new_item, to_label(item_name))
11
+ page_title = w(:new_item, to_label(item_name))
12
+ encoding_attr = encoding ? " encoding=\"#{encoding}\"" : ''
13
+ lang_attr = lang ? " xml:lang=\"#{lang}\" lang=\"#{lang}\"" : ''
14
+ %>
15
+ <?xml version="1.0"<%= encoding_attr %>?>
16
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
17
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
18
+ <html xmlns="http://www.w3.org/1999/xhtml"<%= lang_attr %>>
19
+ <head>
20
+ <title id="mark:header_title">...header title...</title>
21
+ <% stylesheet_names().each do |sheet| %>
22
+ <link rel="stylesheet" type="text/css" href="<%=_ sheet %>.css" id="mark:stylesheet_<%=_ sheet %>" />
23
+ <% end %>
24
+ <% if charset %>
25
+ <meta http-equiv="Content-Type" content="text/html; charset=<%=_ charset %>" />
26
+ <% end %>
27
+ </head>
28
+ <body>
29
+
30
+ <p style="color: green" id="mark:flash_notice"></p>
31
+
32
+ <h1 id="replace_content_with_content:page_title">...page title...</h1>
33
+
34
+ <div id="replace_element_with_content:page_content">
35
+ ...page content...
36
+ </div>
37
+
38
+ </body>
39
+ </html>
@@ -0,0 +1,32 @@
1
+ <%
2
+ ###
3
+ ### $Rev$
4
+ ### $Release: 0.3.0 $
5
+ ### copyright(c) 2005 kuwata-lab.com all rights reserved.
6
+ ###
7
+
8
+
9
+ list_name, item_name, lang, charset, encoding = vars(@table)
10
+ %>
11
+ #header_title {
12
+ /* cont: '<%=_ list_name %>: ' + controller.action_name; */
13
+ logic: {
14
+ _stag
15
+ _content(page_title)
16
+ _etag
17
+ }
18
+ }
19
+
20
+ <%
21
+ stylesheet_names().each do |sheet|
22
+ %>
23
+ #stylesheet_<%=_ sheet %> {
24
+ elem: stylesheet_link_tag '<%=_ sheet %>';
25
+ }
26
+ <%
27
+ end
28
+ %>
29
+
30
+ #flash_notice {
31
+ cont: flash[:notice];
32
+ }
@@ -0,0 +1,94 @@
1
+ <%
2
+ ###
3
+ ### $Rev$
4
+ ### $Release: 0.3.0 $
5
+ ### copyright(c) 2005 kuwata-lab.com all rights reserved.
6
+ ###
7
+
8
+
9
+ list_name, item_name, lang, charset, encoding = vars(@table)
10
+ header_title = w(:listing_items, to_label(list_name))
11
+ page_title = w(:listing_items, to_label(list_name))
12
+ encoding_attr = encoding ? " encoding=\"#{encoding}\"" : ''
13
+ lang_attr = lang ? " xml:lang=\"#{lang}\" lang=\"#{lang}\"" : ''
14
+ %>
15
+ <?xml version="1.0"<%= encoding_attr %>?>
16
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
17
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
18
+ <html xmlns="http://www.w3.org/1999/xhtml"<%= lang_attr %>>
19
+ <head>
20
+ <title><%=_ header_title %></title>
21
+ <%= stylesheets() %>
22
+
23
+ </head>
24
+ <body>
25
+
26
+ <h1 id="mark:page_title"><%=_ page_title %></h1>
27
+
28
+ <div id="mark:page_content">
29
+
30
+ <table class="list_table" summary="">
31
+
32
+ <thead>
33
+ <tr>
34
+ <%
35
+ for column in @table['columns']
36
+ next unless column_showable?(column)
37
+ label = to_label(column_label(column))
38
+ %>
39
+ <th><%=_ label %></th>
40
+ <%
41
+ end
42
+ %>
43
+ <th>&nbsp;</th>
44
+ </tr>
45
+ </thead>
46
+
47
+ <tbody>
48
+ <tr class="odd" id="mark:<%=_ list_name %>">
49
+ <%
50
+ for column in @table['columns']
51
+ next unless column_showable?(column)
52
+ colname = column_refname(column)
53
+ %>
54
+ <td id="mark:<%=_ item_name %>_<%=_ colname %>"><%=_ colname %></td>
55
+ <%
56
+ end
57
+ %>
58
+ <td>
59
+ <a href="#" id="mark:link_to_show"><%=_ w(:show) %></a>
60
+ <a href="#" id="mark:link_to_edit"><%=_ w(:edit) %></a>
61
+ <a href="#" id="mark:link_to_destroy"><%=_ w(:destroy) %></a>
62
+ </td>
63
+ </tr>
64
+ <% for i in (1..3) %>
65
+ <% tr_class = i % 2 == 1 ? 'even' : 'odd' %>
66
+ <tr class="<%= tr_class %>" id="dummy:d<%= i %>">
67
+ <% for column in @table['columns'] %>
68
+ <% next unless column_showable?(column) %>
69
+ <td><%=_ column_refname(column) %></td>
70
+ <% end %>
71
+ <td>
72
+ <a href="#"><%=_ w(:show) %></a>
73
+ <a href="#"><%=_ w(:edit) %></a>
74
+ <a href="#"><%=_ w(:destroy) %></a>
75
+ </td>
76
+ </tr>
77
+ <% end %>
78
+ </thead>
79
+
80
+ </table>
81
+
82
+ <p>
83
+ <a href="#" id="mark:prev_page"><%=_ w(:prev_page) %></a>
84
+ <a href="#" id="mark:next_page"><%=_ w(:next_page) %></a>
85
+ </p>
86
+
87
+ <p>
88
+ <a href="#" id="mark:link_to_new"><%=_ w(:new_item, to_label(item_name)) %></a>
89
+ </p>
90
+
91
+ </div>
92
+
93
+ </body>
94
+ </html>
@@ -0,0 +1,41 @@
1
+ <%
2
+ ###
3
+ ### $Rev$
4
+ ### $Release: 0.3.0 $
5
+ ### copyright(c) 2005 kuwata-lab.com all rights reserved.
6
+ ###
7
+
8
+
9
+ list_name, item_name, lang, charset, encoding = vars(@table)
10
+ %>
11
+ @import '_link.plogic';
12
+ @import '_attr.plogic';
13
+
14
+ #<%= list_name %> {
15
+ attrs: 'class' flag_even ? 'even' : 'odd';
16
+ logic: {
17
+ flag_even = true
18
+ for @<%= item_name %> in @<%= list_name %> do
19
+ flag_even = !flag_even
20
+ _elem
21
+ end
22
+ }
23
+ }
24
+
25
+ #prev_page {
26
+ stag: start_link_tag :page=>@<%= item_name %>_pages.current.previous;
27
+ logic: {
28
+ if @<%= item_name %>_pages.current.previous
29
+ _elem
30
+ end
31
+ }
32
+ }
33
+
34
+ #next_page {
35
+ stag: start_link_tag :page=>@<%= item_name %>_pages.current.next;
36
+ logic: {
37
+ if @<%= item_name %>_pages.current.next
38
+ _elem
39
+ end
40
+ }
41
+ }
@@ -0,0 +1,100 @@
1
+ <%
2
+ ###
3
+ ### $Rev$
4
+ ### $Release: 0.3.0 $
5
+ ### copyright(c) 2005 kuwata-lab.com all rights reserved.
6
+ ###
7
+
8
+
9
+ list_name, item_name, lang, charset, encoding = vars(@table)
10
+ header_title = w(:new_item, to_label(item_name))
11
+ page_title = w(:new_item, to_label(item_name))
12
+ encoding_attr = encoding ? " encoding=\"#{encoding}\"" : ''
13
+ lang_attr = lang ? " xml:lang=\"#{lang}\" lang=\"#{lang}\"" : ''
14
+ %>
15
+ <?xml version="1.0"<%= encoding_attr %>?>
16
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
17
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
18
+ <html xmlns="http://www.w3.org/1999/xhtml"<%= lang_attr %>>
19
+ <head>
20
+ <title><%=_ header_title %></title>
21
+ <%= stylesheets() %>
22
+
23
+ </head>
24
+ <body>
25
+
26
+ <h1 id="page_title"><%=_ page_title %></h1>
27
+
28
+ <div id="page_content">
29
+
30
+ <form action="create" id="mark:start_form">
31
+ <div id="mark:form_content">
32
+
33
+ <div id="mark:error_messages"></div>
34
+
35
+ <!--[form:<%=_ item_name %>]-->
36
+ <% if @properties[:session_token] || @properties[:stoken] %>
37
+ <input type="hidden" name="session_token" id="mark:session_token" />
38
+ <% end %>
39
+ <table class="form_table" summary="">
40
+ <%
41
+ @table['columns'].each do |column|
42
+ next unless column_editable?(column)
43
+ label = to_label(column_label(column))
44
+ colname = column_refname(column)
45
+ id_str = "#{item_name}_#{colname}"
46
+ label_tag = "<th><label for=\"#{id_str}\">#{label}</label></th>\n"
47
+ control_type = column_control_type(column)
48
+ %>
49
+ <% if control_type %>
50
+ <tr>
51
+ <% end %>
52
+ <% case control_type %>
53
+ <% when 'text_field' %>
54
+ <%= label_tag %>
55
+ <td><input type="text" id="<%=_ id_str %>" /></td>
56
+ <% when 'password_field' %>
57
+ <%= label_tag %>
58
+ <td><input type="password" id="<%=_ id_str %>" /></td>
59
+ <% when 'text_area' %>
60
+ <%= label_tag %>
61
+ <td><textarea id="<%=_ id_str %>"></textarea></td>
62
+ <% when 'select' %>
63
+ <%= label_tag %>
64
+ <td>
65
+ <select id="<%=_ id_str %>">
66
+ <option value=""> - </option>
67
+ </select>
68
+ </td>
69
+ <% when 'checkbox' %>
70
+ <th>&nbsp;</th>
71
+ <td><input type="checkbox" id="<%=_ id_str %>" /><label for="<%=_ id_str %>"><%=_ label %></label></td>
72
+ <% when 'radio' %>
73
+ <th><label><%=_ label %></label></th>
74
+ <td>
75
+ <% column['enum'].each do |elem| %>
76
+ <% evalue, elabel = enum_value_and_label(elem, colname) %>
77
+ <% id_str2 = "#{item_name}_#{colname}_#{evalue.to_s.downcase}" %>
78
+ <input type="radio" id="<%=_ id_str2 %>" /><label for="<%=_ id_str2 %>"><%=_ elabel %></label>
79
+ <% end %>
80
+ </td>
81
+ <% end %>
82
+ <% if control_type %>
83
+ </tr>
84
+ <% end %>
85
+ <% end %>
86
+ </table>
87
+ <!--[eoform:<%=_ item_name %>]-->
88
+
89
+ </div>
90
+ <input type="submit" id="mark:submit" />
91
+ </form>
92
+
93
+ <p>
94
+ <a href="#" id="mark:link_to_list"><%=_ w(:back_to, to_label(:list)) %></a>
95
+ </p>
96
+
97
+ </div>
98
+
99
+ </body>
100
+ </html>
@@ -0,0 +1,26 @@
1
+ <%
2
+ ###
3
+ ### $Rev$
4
+ ### $Release: 0.3.0 $
5
+ ### copyright(c) 2005 kuwata-lab.com all rights reserved.
6
+ ###
7
+
8
+
9
+ list_name, item_name, lang, charset, encoding = vars(@table)
10
+ %>
11
+ @import '_link.plogic';
12
+ @import '_form.plogic';
13
+
14
+ #start_form {
15
+ stag: start_form_tag :action=>'create';
16
+ }
17
+
18
+ #form_content {
19
+ logic: {
20
+ _cont
21
+ }
22
+ }
23
+
24
+ #submit {
25
+ elem: submit_tag '<%=_ w(:create) %>';
26
+ }
@@ -0,0 +1,51 @@
1
+ <%
2
+ ###
3
+ ### $Rev$
4
+ ### $Release: 0.3.0 $
5
+ ### copyright(c) 2005 kuwata-lab.com all rights reserved.
6
+ ###
7
+
8
+
9
+ list_name, item_name, lang, charset, encoding = vars(@table)
10
+ header_title = w(:show_item, to_label(item_name))
11
+ page_title = w(:show_item, to_label(item_name))
12
+ encoding_attr = encoding ? " encoding=\"#{encoding}\"" : ''
13
+ lang_attr = lang ? " xml:lang=\"#{lang}\" lang=\"#{lang}\"" : ''
14
+ %>
15
+ <?xml version="1.0"<%= encoding_attr %>?>
16
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
17
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
18
+ <html xmlns="http://www.w3.org/1999/xhtml"<%= lang_attr %>>
19
+ <head>
20
+ <title><%=_ header_title %></title>
21
+ <%= stylesheets() %>
22
+
23
+ </head>
24
+ <body>
25
+
26
+ <h1 id="page_title"><%=_ page_title %></h1>
27
+
28
+ <div id="page_content">
29
+ <table class="show_table" summary="">
30
+ <%
31
+ @table['columns'].each do |column|
32
+ next unless column_showable?(column)
33
+ colname = column_refname(column)
34
+ label = to_label(column_label(column))
35
+ %>
36
+ <tr>
37
+ <th><%=_ label %></th>
38
+ <td id="mark:<%=_ item_name %>_<%=_ colname %>"><%=_ colname %></td>
39
+ </tr>
40
+ <%
41
+ end
42
+ %>
43
+ </table>
44
+ <p>
45
+ <a href="#" id="mark:link_to_edit"><%=_ w(:edit) %></a> |
46
+ <a href="#" id="mark:link_to_list"><%=_ w(:back_to, to_label(:list)) %></a>
47
+ </p>
48
+ </div>
49
+
50
+ </body>
51
+ </html>