masterview_plugin_generator 0.1.0 → 0.1.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.
- data/masterview_plugin_generator.rb +2 -0
- data/templates/masterview.rake +94 -0
- metadata +2 -1
@@ -9,7 +9,9 @@ class MasterviewPluginGenerator < Rails::Generator::Base
|
|
9
9
|
record do |m|
|
10
10
|
m.directory 'vendor/plugins/masterview'
|
11
11
|
m.directory 'vendor/plugins/masterview/directives'
|
12
|
+
m.directory 'vendor/plugins/masterview/tasks'
|
12
13
|
m.template 'init.rb', 'vendor/plugins/masterview/init.rb'
|
14
|
+
m.template 'masterview.rake', 'vendor/plugins/masterview/tasks/masterview.rake'
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
@@ -0,0 +1,94 @@
|
|
1
|
+
currentPath = File.dirname(__FILE__)
|
2
|
+
require File.join( currentPath, '../lib/masterview' )
|
3
|
+
|
4
|
+
MasterView::Log.level = Logger::ERROR
|
5
|
+
|
6
|
+
namespace :mv do
|
7
|
+
|
8
|
+
desc 'Display list and status about each MasterView template'
|
9
|
+
task :list do
|
10
|
+
template_specs, content_hash = MasterView::TemplateSpec.scan
|
11
|
+
@template_specs_sorted = template_specs.sort
|
12
|
+
@template_specs_sorted.each do |path, ts|
|
13
|
+
puts "#{path}\t#{ts.status}\t#{ts.message}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Display list, status, and full details about each MasterView template'
|
18
|
+
task :list_all do
|
19
|
+
template_specs, content_hash = MasterView::TemplateSpec.scan
|
20
|
+
@template_specs_sorted = template_specs.sort
|
21
|
+
@template_specs_sorted.each do |path, ts|
|
22
|
+
puts "#{path}\t#{ts.status}\t#{ts.message}"
|
23
|
+
puts "\tgenerates: #{ts.gen_parts.join(', ')}\n\n"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Rebuild/update template imports, specify TEMPLATE=foo.html'
|
28
|
+
task :rebuild do
|
29
|
+
raise "Usage: rake mv:rebuild TEMPLATE=foo.html" unless ENV['TEMPLATE']
|
30
|
+
path = ENV['TEMPLATE']
|
31
|
+
short_name = File.basename(path)
|
32
|
+
short_name = short_name+'.html' unless short_name.index('.')
|
33
|
+
path = File.join('app/views', MasterView::TemplateSrcRelativePath, short_name)
|
34
|
+
template_specs, content_hash = MasterView::TemplateSpec.scan
|
35
|
+
template_spec = template_specs[path]
|
36
|
+
raise 'Template '+path+' not found' unless template_spec
|
37
|
+
if template_spec.rebuild_template(content_hash, :write_to_file => true)
|
38
|
+
puts 'File '+path+' updated'
|
39
|
+
puts 'Note: Backup was created in '+MasterView::DirectoryForRebuildBackups
|
40
|
+
else
|
41
|
+
puts 'Identical content - no update needed for '+path
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'Rebuild all outdated template imports'
|
46
|
+
task :rebuild_all do
|
47
|
+
files_rebuilt = []
|
48
|
+
MasterView::TemplateSpec.scan do |template_spec, content_hash|
|
49
|
+
if template_spec.status == MasterView::TemplateSpec::Status::ImportsOutdated &&
|
50
|
+
template_spec.rebuild_template(content_hash, :write_to_file => true)
|
51
|
+
files_rebuilt << template_spec.path
|
52
|
+
end
|
53
|
+
end
|
54
|
+
files_rebuilt.each do |f|
|
55
|
+
puts f+' updated'
|
56
|
+
end
|
57
|
+
unless files_rebuilt.empty? || MasterView::DirectoryForRebuildBackups.nil?
|
58
|
+
puts 'Note: Backups were created in '+MasterView::DirectoryForRebuildBackups
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# checks app path first for views and files, then falls back to files in MV
|
63
|
+
def find_path(path)
|
64
|
+
mv_path = File.join(File.dirname(__FILE__), '../lib/masterview/extras', path)
|
65
|
+
working_path = (File.exist?(path)) ? path : mv_path
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'Create shell template using layout of existing masterview template, requires TEMPLATE=foo.html ACTION=list'
|
69
|
+
task :copy_layout do
|
70
|
+
raise "Usage: rake mv:copy_layout TEMPLATE=foo.html ACTION=list" unless ENV['TEMPLATE'] && ENV['ACTION']
|
71
|
+
action_to_create = ENV['ACTION']
|
72
|
+
short_name = File.basename(ENV['TEMPLATE'])
|
73
|
+
|
74
|
+
empty_file_path = find_path('app/views/masterview/admin/empty.rhtml')
|
75
|
+
empty_insert_erb = File.readlines(empty_file_path).join
|
76
|
+
|
77
|
+
src_file = File.join('app/views', MasterView::TemplateSrcRelativePath, short_name)
|
78
|
+
dst_file = MasterView::TemplateSpec.create_empty_shell_for_action(src_file, action_to_create, empty_insert_erb, :write_to_file => true)
|
79
|
+
puts dst_file+' created'
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "Run parser manually on masterview html files to generate the erb/rhtml files"
|
83
|
+
task :parse do
|
84
|
+
OutputDir = 'app/views'
|
85
|
+
filelist = Dir.glob('app/views/masterview/**/*.html')
|
86
|
+
filelist.each do |file|
|
87
|
+
MasterView::Parser.parse_file( file, OutputDir)
|
88
|
+
puts 'Generated erb/rhtml files from '+file
|
89
|
+
end
|
90
|
+
puts 'Generated erb/rhtml output was created in app/views/** tree'
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
end
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: masterview_plugin_generator
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
6
|
+
version: 0.1.1
|
7
7
|
date: 2006-05-29 00:00:00 -05:00
|
8
8
|
summary: A (x)html friendly template engine for rails with the power of layouts, and partials. MasterView Plugin Generator for GEM
|
9
9
|
require_paths:
|
@@ -30,6 +30,7 @@ authors:
|
|
30
30
|
files:
|
31
31
|
- masterview_plugin_generator.rb
|
32
32
|
- templates/init.rb
|
33
|
+
- templates/masterview.rake
|
33
34
|
- Rakefile
|
34
35
|
test_files: []
|
35
36
|
|