bivouac 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -12,6 +12,10 @@ Bivouac is a simple generator for camping[http://code.whytheluckystiff.net/campi
12
12
 
13
13
  == FEATURES/PROBLEMS:
14
14
 
15
+ === 0.0.5:
16
+ * new generator : scaffold! -- maybe someone need it!
17
+ * Ho my god! the code is horrible!
18
+
15
19
  === 0.0.4:
16
20
  * the application file is now in app and not in app/controller
17
21
  * Mongrel postamble is no more in the TODO list
@@ -39,7 +43,6 @@ Bivouac is a simple generator for camping[http://code.whytheluckystiff.net/campi
39
43
 
40
44
  * add test with mosquito[http://code.whytheluckystiff.net/camping/wiki/MosquitoForBugFreeCamping]
41
45
  * test with Apache and Lighttpd
42
- * add scaffold generator -- who want it ?
43
46
  * rewrite script/server and remove postamble
44
47
  * add mysql, postgresql, oracle, ... support
45
48
 
data/doc/rdoc/created.rid CHANGED
@@ -1 +1 @@
1
- Sat, 04 Aug 2007 02:26:46 +0200
1
+ Wed, 08 Aug 2007 18:13:52 +0200
@@ -73,7 +73,7 @@ end</strong>
73
73
  <div id="README" class="page_shade">
74
74
  <div class="page">
75
75
  <div class="header">
76
- <div class="path">README / Sat Aug 04 02:26:17 +0200 2007</div>
76
+ <div class="path">README / Wed Aug 08 18:12:33 +0200 2007</div>
77
77
  </div>
78
78
 
79
79
  <h1>Bivouac</h1>
@@ -98,6 +98,15 @@ Bivouac is a simple generator for <a
98
98
  href="http://code.whytheluckystiff.net/camping">camping</a>.
99
99
  </p>
100
100
  <h2>FEATURES/PROBLEMS:</h2>
101
+ <h3>0.0.5:</h3>
102
+ <ul>
103
+ <li>new generator : scaffold! &#8212; maybe someone need it!
104
+
105
+ </li>
106
+ <li>Ho my god! the code is horrible!
107
+
108
+ </li>
109
+ </ul>
101
110
  <h3>0.0.4:</h3>
102
111
  <ul>
103
112
  <li>the application file is now in app and not in app/controller
@@ -166,9 +175,6 @@ href="http://code.whytheluckystiff.net/camping/wiki/MosquitoForBugFreeCamping">m
166
175
  </li>
167
176
  <li>test with Apache and Lighttpd
168
177
 
169
- </li>
170
- <li>add scaffold generator &#8212; who want it ?
171
-
172
178
  </li>
173
179
  <li>rewrite script/server and remove postamble
174
180
 
@@ -14,15 +14,17 @@ module Bivouac
14
14
  include Bivouac::Template
15
15
 
16
16
  def initialize( argv )
17
+ # Generator type (controller, model, migrate, view, ...)
17
18
  @generator_type = argv.shift
18
19
 
20
+ # Generator options
19
21
  @options = OpenStruct.new( :noview => false, :default_route => true, :routes => [] )
20
22
  @opts = OptionParser.new do |opts|
21
23
  opts.banner = "Usage: script/generate generator [options] [args]"
22
24
 
23
25
  opts.separator ""
24
26
  opts.separator "Generators"
25
- opts.separator " Builtin: controller, model, migrate, view"
27
+ opts.separator " Builtin: controller, model, migrate, view, scaffold"
26
28
 
27
29
  opts.separator ""
28
30
  opts.separator "controller generator options:"
@@ -61,30 +63,43 @@ module Bivouac
61
63
  exit
62
64
  end
63
65
 
66
+ # parse options
64
67
  @opts.parse! argv
65
68
  if argv.length < 1
66
69
  puts @opts
67
70
  exit
68
71
  end
69
72
 
73
+ # Generator arguments.
74
+ # Example :
75
+ # script/generate controller Hello World
76
+ # @script_arguments = ['Hello', 'World']
70
77
  @script_arguments = argv.dup
71
78
 
79
+ # Application environment
72
80
  @app = Bivouac::Environment.new( )
81
+
82
+ # Application name for the generator, passed to the template
73
83
  @generation_app_name = @app.environment.appname
84
+
85
+ # Application organisation (goh, jof or erb)
74
86
  @generation_type = @app.environment.orgtype
75
87
  end
76
88
 
77
89
  def run
78
90
  @script_arguments.each do |@generation_name|
91
+ # Class name passed to the template
79
92
  @generation_class_name = @generation_name.classify
93
+ # File name for the template
80
94
  @generation_file_name = @generation_class_name.underscore
95
+ # Call the generator
81
96
  send( @generator_type.to_sym )
82
97
  end
83
98
  end
84
99
 
85
100
  private
86
101
  def controller
87
- @destination_file = File.dirname( $0 ) + "/../app/" + @generator_type.pluralize + "/" + @generation_file_name.underscore + ".rb"
102
+ @destination_file = File.dirname( $0 ) + "/../app/controllers/" + @generation_file_name.underscore + ".rb"
88
103
  @generation_view_name = @generation_class_name.underscore
89
104
 
90
105
  default_route = '/' + @generation_view_name
@@ -103,7 +118,7 @@ module Bivouac
103
118
  end
104
119
 
105
120
  def migrate
106
- @generation_table_name = (@generation_class_name.downcase + "_" + @generation_name).tableize
121
+ @generation_table_name = (@generation_app_name.downcase + "_" + @generation_name).tableize
107
122
 
108
123
  @destination_file = File.dirname( $0 ) + "/../db/migrate/" + @generation_file_name.underscore + ".rb"
109
124
  createFile( @destination_file ) do |io|
@@ -117,7 +132,7 @@ module Bivouac
117
132
  end
118
133
 
119
134
  def model
120
- @destination_file = File.dirname( $0 ) + "/../app/" + @generator_type.pluralize + "/" + @generation_file_name.underscore + ".rb"
135
+ @destination_file = File.dirname( $0 ) + "/../app/models/" + @generation_file_name.underscore + ".rb"
121
136
  createFile( @destination_file ) do |io|
122
137
  io.puts template( "generate/model", binding )
123
138
  end
@@ -138,6 +153,40 @@ module Bivouac
138
153
  end
139
154
  end
140
155
 
156
+ def scaffold
157
+ @generation_view_name = @generation_class_name.underscore
158
+
159
+ # Generate model and migrate
160
+ model( )
161
+
162
+ # Generate scaffold controllers
163
+ @destination_file = File.dirname( $0 ) + "/../app/controllers/list_" + @generation_file_name + ".rb"
164
+ createFile( @destination_file ) do |io|
165
+ io.puts template( "generate/scaffold_controller_list", binding )
166
+ end
167
+ @destination_file = File.dirname( $0 ) + "/../app/controllers/create_" + @generation_file_name + ".rb"
168
+ createFile( @destination_file ) do |io|
169
+ io.puts template( "generate/scaffold_controller_create", binding )
170
+ end
171
+ @destination_file = File.dirname( $0 ) + "/../app/controllers/view_" + @generation_file_name + ".rb"
172
+ createFile( @destination_file ) do |io|
173
+ io.puts template( "generate/scaffold_controller_view", binding )
174
+ end
175
+
176
+ # Generate scaffold views
177
+ @destination_file = File.dirname( $0 ) + "/../app/views/list_" + @generation_file_name + ".rb"
178
+ createFile( @destination_file ) do |io|
179
+ io.puts template( "generate/scaffold_view_list", binding )
180
+ end
181
+ @destination_file = File.dirname( $0 ) + "/../app/views/create_" + @generation_file_name + ".rb"
182
+ createFile( @destination_file ) do |io|
183
+ io.puts template( "generate/scaffold_view_create", binding )
184
+ end
185
+ @destination_file = File.dirname( $0 ) + "/../app/views/view_" + @generation_file_name + ".rb"
186
+ createFile( @destination_file ) do |io|
187
+ io.puts template( "generate/scaffold_view_view", binding )
188
+ end
189
+ end
141
190
  end
142
191
  end
143
192
 
@@ -2,6 +2,7 @@ module <%= @generation_app_name %>::Models
2
2
  class Create<%= @generation_class_name %> < V 1.0
3
3
  def self.up
4
4
  create_table :<%= @generation_table_name %> do |t|
5
+ t.column :id, :integer, :null => false
5
6
  # ...
6
7
  end
7
8
  end
@@ -0,0 +1,15 @@
1
+ module <%= @generation_app_name %>::Controllers
2
+ class Create<%= @generation_class_name %> < R '/<%= @generation_view_name %>/add'
3
+ def get
4
+ render :create_<%= @generation_view_name %>
5
+ end
6
+
7
+ def post
8
+ @<%= @generation_view_name %> = Models::<%= @generation_class_name %>.create
9
+ # @<%= @generation_view_name %>.<field> = input.<field>
10
+ @<%= @generation_view_name %>.save
11
+ redirect List<%= @generation_class_name %>
12
+ # render :view_<%= @generation_view_name %>
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ module <%= @generation_app_name %>::Controllers
2
+ class List<%= @generation_class_name %> < R '/<%= @generation_view_name %>'
3
+ def get
4
+ @<%= @generation_view_name.pluralize %> = Models::<%= @generation_class_name %>.find_all
5
+ render :list_<%= @generation_view_name %>
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ module <%= @generation_app_name %>::Controllers
2
+ class View<%= @generation_class_name %> < R '/<%= @generation_view_name %>/(\d)'
3
+ def get(id)
4
+ @<%= @generation_view_name %> = Models::<%= @generation_class_name %>.find(id)
5
+ render :view_<%= @generation_view_name %>
6
+ end
7
+ def post(id)
8
+ @<%= @generation_view_name %> = Models::<%= @generation_class_name %>.find(id)
9
+ # @<%= @generation_view_name %>.<field> = input.<field>
10
+ @<%= @generation_view_name %>.save
11
+ render :view_<%= @generation_view_name %>
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ module <%= @generation_app_name %>::Views
2
+ def create_<%= @generation_view_name %>
3
+ p "Add a new <%= @generation_class_name %>"
4
+ div.<%= @generation_view_name %>_form do
5
+ form(:method => 'post', :action => R(Create<%= @generation_class_name %>)) do
6
+ # ...
7
+ input :type => 'submit'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module <%= @generation_app_name %>::Views
2
+ def list_<%= @generation_view_name %>
3
+ a 'add a <%= @generation_class_name %>', :href => R(Create<%= @generation_class_name %>)
4
+ div.<%= @generation_view_name.pluralize %> do
5
+ @<%= @generation_view_name.pluralize %>.each do |<%= @generation_view_name %>|
6
+ #...
7
+ a 'view', :href => R(View<%= @generation_class_name %>, <%= @generation_view_name %>.id)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module <%= @generation_app_name %>::Views
2
+ def view_<%= @generation_view_name %>
3
+ div.<%= @generation_view_name %> do
4
+ #...
5
+ a 'List', :href => R(List<%= @generation_class_name %>)
6
+ end
7
+ div.<%= @generation_view_name %>_form do
8
+ form(:method => 'post', :action => R(View<%= @generation_class_name %>, @<%= @generation_view_name %>.id)) do
9
+ # ...
10
+ input :type => 'submit'
11
+ end
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: bivouac
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.4
7
- date: 2007-08-04 00:00:00 +02:00
6
+ version: 0.0.5
7
+ date: 2007-08-08 00:00:00 +02:00
8
8
  summary: Developpe with Camping like you do with Rails
9
9
  require_paths:
10
10
  - lib
@@ -67,6 +67,12 @@ files:
67
67
  - lib/bivouac/template/generate/create.rb
68
68
  - lib/bivouac/template/generate/migrate.rb
69
69
  - lib/bivouac/template/generate/model.rb
70
+ - lib/bivouac/template/generate/scaffold_controller_create.rb
71
+ - lib/bivouac/template/generate/scaffold_controller_list.rb
72
+ - lib/bivouac/template/generate/scaffold_controller_view.rb
73
+ - lib/bivouac/template/generate/scaffold_view_create.rb
74
+ - lib/bivouac/template/generate/scaffold_view_list.rb
75
+ - lib/bivouac/template/generate/scaffold_view_view.rb
70
76
  - lib/bivouac/template/generate/view_erb.rb
71
77
  - lib/bivouac/template/generate/view_goh.rb
72
78
  - lib/bivouac/template/generate.rb