masterview_generator 0.3.0 → 0.3.1

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.
Files changed (2) hide show
  1. data/masterview_generator.rb +41 -24
  2. metadata +2 -2
@@ -9,9 +9,9 @@ class ScaffoldingSandbox
9
9
  def sandbox_binding
10
10
  binding
11
11
  end
12
-
12
+
13
13
  def default_input_block
14
- Proc.new { |record, column|
14
+ Proc.new { |record, column|
15
15
  " <div class=\"record\">\n <div class=\"label\"><label for=\"#{record}_#{column.name}\">#{column.human_name}:</label></div>\n <div class=\"field\">#{input(record, column.name)}</div>\n </div>\n" }
16
16
  end
17
17
  end
@@ -30,7 +30,7 @@ end
30
30
 
31
31
  class ShowScaffoldingSandbox < ScaffoldingSandbox
32
32
  def default_input_block
33
- Proc.new { |record, column|
33
+ Proc.new { |record, column|
34
34
  " <div class=\"record\">\n <div class=\"label\"><label>#{column.human_name}:</label></div>\n <div class=\"field\" mv:content=\"h @#{record}.send(:#{column.name})\">#{record} #{column.human_name}</div>\n </div>\n" }
35
35
  end
36
36
  end
@@ -57,7 +57,7 @@ class ActionView::Helpers::InstanceTag
57
57
  def to_date_select_tag(options = {})
58
58
  date_select options
59
59
  end
60
-
60
+
61
61
  def to_datetime_select_tag(options = {})
62
62
  datetime_select options
63
63
  end
@@ -67,12 +67,29 @@ module Rails
67
67
  module Generator
68
68
  module Commands
69
69
  class Create < Base
70
+ # Ask the user interactively whether to force collision.
71
+ def mv_force_file_collision?(destination)
72
+ $stdout.print "overwrite #{destination}? [Ynaq] "
73
+ case $stdin.gets
74
+ when /a/i
75
+ $stdout.puts "forcing #{spec.name}"
76
+ options[:collision] = :force
77
+ when /q/i
78
+ $stdout.puts "aborting #{spec.name}"
79
+ raise SystemExit
80
+ when /n/i then :skip
81
+ else :force
82
+ end
83
+ rescue
84
+ retry
85
+ end
86
+
70
87
  def string_to_file(content, relative_destination, file_options = {}, &block)
71
88
  template_mio = MasterView::IOMgr.template.path(relative_destination)
72
89
 
73
90
  # If source and destination are identical then we're done.
74
91
  if template_mio.identical?(content)
75
- return logger.identical(relative_destination)
92
+ return logger.identical(relative_destination)
76
93
  end
77
94
 
78
95
  # Check for and resolve file collisions.
@@ -81,7 +98,7 @@ module Rails
81
98
  # Make a choice whether to overwrite the file. :force and
82
99
  # :skip already have their mind made up, but give :ask a shot.
83
100
  choice = case (file_options[:collision] || options[:collision]).to_sym #|| :ask
84
- when :ask then force_file_collision?(relative_destination)
101
+ when :ask then mv_force_file_collision?(relative_destination)
85
102
  when :force then :force
86
103
  when :skip then :skip
87
104
  else raise "Invalid collision option: #{options[:collision].inspect}"
@@ -109,7 +126,7 @@ module Rails
109
126
  #if file_options[:chmod]
110
127
  # FileUtils.chmod(file_options[:chmod], destination)
111
128
  #end
112
-
129
+
113
130
  # Optionally add file to subversion
114
131
  #system("svn add #{destination}") if options[:svn]
115
132
  end
@@ -180,7 +197,7 @@ module Rails
180
197
  end
181
198
 
182
199
  class Update < Create
183
- def multi_include_template(relative_source, relative_destination, template_options = {}, multi_assign_options = {})
200
+ def multi_include_template(relative_source, relative_destination, template_options = {}, multi_assign_options = {})
184
201
  return if relative_source.is_a?(StringIO) && relative_destination.is_a?(StringIO)
185
202
  begin
186
203
  dest_file = destination_path(relative_destination)
@@ -240,19 +257,19 @@ class MasterviewGenerator < Rails::Generator::NamedBase
240
257
  if full_options[:single_file]
241
258
  com = <<-END
242
259
  <!--
243
- These stylesheets below are for design time use to allow working with only one visible section at a time, especially
260
+ These stylesheets below are for design time use to allow working with only one visible section at a time, especially
244
261
  when trying to use absolute positioning. You may comment/uncomment which ever section you wish to work with.
245
- You may comment all of them out to work with all at design time. These stylesheets will not be used at runtime
262
+ You may comment all of them out to work with all at design time. These stylesheets will not be used at runtime
246
263
  -->
247
264
  END
248
265
 
249
266
  dts << com
250
267
 
251
- dts << html_comment( '<link rel="stylesheet" type="text/css" href="../../masterview/extra/show_only_new.css" mv:preview="remove" mv:replace=""/>',
268
+ dts << html_comment( '<link rel="stylesheet" type="text/css" href="../../masterview/extra/show_only_new.css" mv:preview="remove" mv:replace=""/>',
252
269
  full_options[:showSection] != :new )
253
270
  dts << html_comment( '<link rel="stylesheet" type="text/css" href="../../masterview/extra/show_only_edit.css" mv:preview="remove" mv:replace=""/>', true)
254
271
  dts << html_comment( '<link rel="stylesheet" type="text/css" href="../../masterview/extra/show_only_show.css" mv:preview="remove" mv:replace=""/>', true)
255
- dts << html_comment( '<link rel="stylesheet" type="text/css" href="../../masterview/extra/show_only_list.css" mv:preview="remove" mv:replace=""/>',
272
+ dts << html_comment( '<link rel="stylesheet" type="text/css" href="../../masterview/extra/show_only_list.css" mv:preview="remove" mv:replace=""/>',
256
273
  full_options[:showSection] != :list )
257
274
  dts << html_comment( '<link rel="stylesheet" type="text/css" href="../../masterview/extra/show_only_destroy.css" mv:preview="remove" mv:replace=""/>', true)
258
275
  end
@@ -269,7 +286,7 @@ class MasterviewGenerator < Rails::Generator::NamedBase
269
286
  def design_time_javascript
270
287
  dtj = ''
271
288
  # todo make this relative to whereever IOMgr.template is
272
- if full_options[:single_file]
289
+ if full_options[:single_file]
273
290
  dtj << %Q[ <script type="text/javascript" mv:replace="" src="../../masterview/extra/mvpreview.js"></script>\n]
274
291
  dtj << %Q[ <script type="text/javascript" mv:replace="">\n]
275
292
  dtj << %Q[ mvpreview.preparePage( '#{controller_file_name}', {showOneSection: '#{controller_file_name}_list', single_file: true } );\n]
@@ -350,8 +367,8 @@ class MasterviewGenerator < Rails::Generator::NamedBase
350
367
 
351
368
  # MasterView
352
369
  if full_options[:single_file]
353
- m.multi_include_template "masterview.rhtml","#{controller_masterview_name}/masterview.html", {},
354
- {
370
+ m.multi_include_template "masterview.rhtml","#{controller_masterview_name}/masterview.html", {},
371
+ {
355
372
  'form_inclusion' =>
356
373
  { :insert => 'form_scaffold.rhtml',
357
374
  :sandbox => lambda { create_multi_sandbox('ScaffoldingSandbox') },
@@ -359,14 +376,14 @@ class MasterviewGenerator < Rails::Generator::NamedBase
359
376
  :end_mark => 'eoform',
360
377
  :mark_id => singular_name
361
378
  },
362
- 'list_head_inclusion' =>
379
+ 'list_head_inclusion' =>
363
380
  { :insert => 'list_head_scaffold.rhtml',
364
381
  :sandbox => lambda { create_multi_sandbox('ListHeadScaffoldingSandbox') },
365
382
  :begin_mark => 'listhead',
366
383
  :end_mark => 'eolisthead',
367
384
  :mark_id => singular_name
368
385
  },
369
- 'list_line_inclusion' =>
386
+ 'list_line_inclusion' =>
370
387
  { :insert => 'list_line_scaffold.rhtml',
371
388
  :sandbox => lambda { create_multi_sandbox('ListLineScaffoldingSandbox') },
372
389
  :begin_mark => 'listline',
@@ -383,15 +400,15 @@ class MasterviewGenerator < Rails::Generator::NamedBase
383
400
  }
384
401
  else #multi file
385
402
  m.multi_file_multi_include_template "masterview.rhtml",
386
- {
403
+ {
387
404
  :list => "#{controller_masterview_name}/list.html",
388
405
  :new => "#{controller_masterview_name}/new.html",
389
406
  :edit => "#{controller_masterview_name}/edit.html",
390
407
  :show => "#{controller_masterview_name}/show.html",
391
408
  :destroy => "#{controller_masterview_name}/destroy.html",
392
409
  },
393
- {},
394
- {
410
+ {},
411
+ {
395
412
  'form_inclusion' =>
396
413
  { :insert => 'form_scaffold.rhtml',
397
414
  :sandbox => lambda { create_multi_sandbox('ScaffoldingSandbox') },
@@ -399,14 +416,14 @@ class MasterviewGenerator < Rails::Generator::NamedBase
399
416
  :end_mark => 'eoform',
400
417
  :mark_id => singular_name
401
418
  },
402
- 'list_head_inclusion' =>
419
+ 'list_head_inclusion' =>
403
420
  { :insert => 'list_head_scaffold.rhtml',
404
421
  :sandbox => lambda { create_multi_sandbox('ListHeadScaffoldingSandbox') },
405
422
  :begin_mark => 'listhead',
406
423
  :end_mark => 'eolisthead',
407
424
  :mark_id => singular_name
408
425
  },
409
- 'list_line_inclusion' =>
426
+ 'list_line_inclusion' =>
410
427
  { :insert => 'list_line_scaffold.rhtml',
411
428
  :sandbox => lambda { create_multi_sandbox('ListLineScaffoldingSandbox') },
412
429
  :begin_mark => 'listline',
@@ -524,8 +541,8 @@ class MasterviewGenerator < Rails::Generator::NamedBase
524
541
  def suffix
525
542
  "_#{singular_name}" if options[:suffix]
526
543
  end
527
-
528
- def model_name
544
+
545
+ def model_name
529
546
  class_name.demodulize
530
547
  end
531
548
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: masterview_generator
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.0
7
- date: 2006-11-07 00:00:00 -06:00
6
+ version: 0.3.1
7
+ date: 2006-11-20 00:00:00 -06:00
8
8
  summary: A (x)html friendly template engine for rails with the power of layouts, and partials. MasterView Generator for creating templates and scaffolding.
9
9
  require_paths:
10
10
  - .