masterview 0.1.5 → 0.2.0
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/CHANGELOG +17 -0
- data/README +36 -504
- data/RELEASE_NOTES +126 -45
- data/Rakefile +215 -86
- data/TODO +8 -3
- data/doc/configuration.html +485 -0
- data/doc/directives.html +1085 -0
- data/doc/guide.html +243 -0
- data/doc/index.html +287 -0
- data/doc/installation.html +376 -0
- data/doc/stylesheets/masterview.css +206 -0
- data/doc/stylesheets/mv-config.css +23 -0
- data/doc/stylesheets/mv-directives.css +18 -0
- data/doc/stylesheets/mv-installation.css +10 -0
- data/doc/troubleshooting.html +18 -0
- data/examples/product.html +256 -0
- data/examples/product.html.old +107 -0
- data/examples/rails_app_config/masterview/environment/development.rb +22 -0
- data/examples/rails_app_config/masterview/environment/production.rb +9 -0
- data/examples/rails_app_config/masterview/settings.rb +59 -0
- data/examples/test.import +80 -0
- data/init.rb +26 -12
- data/lib/masterview/analyzer.rb +25 -15
- data/lib/masterview/directive_base.rb +4 -0
- data/lib/masterview/directive_helpers.rb +7 -5
- data/lib/masterview/directives/import_render.rb +6 -0
- data/lib/masterview/directives/insert_generated_comment.rb +8 -8
- data/lib/masterview/extras/app/controllers/masterview_controller.rb +154 -2
- data/lib/masterview/extras/app/views/masterview/admin/create.rhtml +4 -4
- data/lib/masterview/extras/app/views/masterview/admin/empty.rhtml +1 -1
- data/lib/masterview/extras/app/views/masterview/admin/list.rhtml +14 -9
- data/lib/masterview/extras/app/views/masterview/admin/view_rhtml.rhtml +70 -0
- data/lib/masterview/extras/init_logger.rb +102 -0
- data/lib/masterview/extras/init_rails_erb_mv_direct.rb +117 -0
- data/lib/masterview/extras/init_rails_reparse_checking.rb +59 -0
- data/lib/masterview/extras/watcher.rb +17 -23
- data/lib/masterview/filter_helpers.rb +26 -0
- data/lib/masterview/initializer.rb +912 -0
- data/lib/masterview/io.rb +352 -0
- data/lib/masterview/keyword_expander.rb +116 -0
- data/lib/masterview/masterview_version.rb +2 -2
- data/lib/masterview/mtime_tracking_hash.rb +44 -0
- data/lib/masterview/parser.rb +64 -92
- data/lib/masterview/pathname_extensions.rb +33 -0
- data/lib/masterview/template_spec.rb +49 -56
- data/lib/masterview.rb +40 -85
- data/test/fixtures/configs/fake_rails_app_with_config/config/masterview/environments/development.rb +12 -0
- data/test/fixtures/configs/fake_rails_app_with_config/config/masterview/environments/production.rb +11 -0
- data/test/fixtures/configs/fake_rails_app_with_config/config/masterview/settings.rb +23 -0
- data/test/fixtures/templates/product.html +256 -0
- data/test/fixtures/templates/test.import +80 -0
- data/test/test_helper.rb +5 -3
- data/test/tmp/template/foo.txt +1 -0
- data/test/tmp/templates_src/product.html +256 -0
- data/test/tmp/views/layouts/product.rhtml +35 -0
- data/test/tmp/views/product/_form.rhtml +30 -0
- data/test/tmp/views/product/_product.rhtml +14 -0
- data/test/tmp/views/product/_show.rhtml +27 -0
- data/test/tmp/views/product/destroy.rhtml +27 -0
- data/test/tmp/views/product/edit.rhtml +26 -0
- data/test/tmp/views/product/list.rhtml +31 -0
- data/test/tmp/views/product/new.rhtml +29 -0
- data/test/tmp/views/product/show.rhtml +16 -0
- data/test/unit/config_settings_test.rb +172 -0
- data/test/{attr_test.rb → unit/directive_attr_test.rb} +2 -2
- data/test/{block_test.rb → unit/directive_block_test.rb} +2 -2
- data/test/{content_test.rb → unit/directive_content_test.rb} +2 -2
- data/test/{else_test.rb → unit/directive_else_test.rb} +2 -2
- data/test/{elsif_test.rb → unit/directive_elsif_test.rb} +2 -2
- data/test/{form_test.rb → unit/directive_form_test.rb} +2 -2
- data/test/{global_inline_erb_test.rb → unit/directive_global_inline_erb_test.rb} +2 -2
- data/test/{hidden_field_test.rb → unit/directive_hidden_field_test.rb} +2 -2
- data/test/{if_test.rb → unit/directive_if_test.rb} +2 -2
- data/test/unit/directive_import_render_test.rb +62 -0
- data/test/{import_test.rb → unit/directive_import_test.rb} +2 -2
- data/test/{javascript_include_test.rb → unit/directive_javascript_include_test.rb} +2 -2
- data/test/{link_to_if_test.rb → unit/directive_link_to_if_test.rb} +2 -2
- data/test/{link_to_test.rb → unit/directive_link_to_test.rb} +2 -2
- data/test/{omit_tag_test.rb → unit/directive_omit_tag_test.rb} +2 -2
- data/test/{password_field_test.rb → unit/directive_password_field_test.rb} +2 -2
- data/test/{replace_test.rb → unit/directive_replace_test.rb} +2 -2
- data/test/{stylesheet_link_test.rb → unit/directive_stylesheet_link_test.rb} +2 -2
- data/test/{submit_test.rb → unit/directive_submit_test.rb} +2 -2
- data/test/{text_area_test.rb → unit/directive_text_area_test.rb} +2 -2
- data/test/{text_field_test.rb → unit/directive_text_field_test.rb} +2 -2
- data/test/{example_test.rb → unit/example_test.rb} +1 -1
- data/test/unit/file_mio_test.rb +368 -0
- data/test/{filter_helpers_test.rb → unit/filter_helpers_test.rb} +1 -1
- data/test/unit/keyword_expander_test.rb +95 -0
- data/test/unit/mio_test.rb +110 -0
- data/test/unit/mtime_string_hash_mio_tree_test.rb +289 -0
- data/test/unit/mtime_tracking_hash_test.rb +38 -0
- data/test/{parser_test.rb → unit/parser_test.rb} +19 -1
- data/test/unit/pathname_extensions_test.rb +46 -0
- data/test/{run_parser_test.rb → unit/run_parser_test.rb} +7 -3
- data/test/unit/string_hash_mio_test.rb +320 -0
- data/test/unit/template_file_watcher_test.rb +107 -0
- data/test/{template_spec_test.rb → unit/template_spec_test.rb} +57 -21
- data/test/{template_test.rb → unit/template_test.rb} +123 -22
- data/test/xtras/config-mv-logger_config.rb +109 -0
- data/test/xtras/config_initialize_standalone.rb +53 -0
- metadata +111 -38
- data/lib/masterview/extras/rails_init.rb +0 -72
- data/test/import_render_test.rb +0 -30
- data/test/template_file_watcher_test.rb +0 -50
data/RELEASE_NOTES
CHANGED
@@ -1,15 +1,105 @@
|
|
1
1
|
= MasterView - Rails-optimized (x)html friendly template engine
|
2
2
|
|
3
|
-
== Recent changes
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
== Recent changes (Release 0.2.0)
|
4
|
+
|
5
|
+
Release 0.2.0 features a number of significant improvements.
|
6
|
+
|
7
|
+
MasterView templates can now be compiled directly into the Rails
|
8
|
+
view cache, just like .rhtml files in your app/views directory.
|
9
|
+
Output generation of .rhtml files from a MasterView template
|
10
|
+
is now optional.
|
11
|
+
|
12
|
+
A keyword substitution mechanism is now supported for the
|
13
|
+
mv:generate and mv:import group of template processing directives
|
14
|
+
to enable you to more easily specify standard output file names
|
15
|
+
derived from the template filename and relative path.
|
16
|
+
Template markup of the form:
|
17
|
+
|
18
|
+
mv:generate="{template_path}"
|
19
|
+
|
20
|
+
avoids having to replicate the name of the template file itself
|
21
|
+
or its relative path within the masterview templates directory.
|
22
|
+
See the MasterView User's Guide and Directives Reference for details.
|
23
|
+
|
24
|
+
A new configuration facility has been added to allow you to
|
25
|
+
customize the MasterView configuration using settings
|
26
|
+
files in your rails app config directory, following the
|
27
|
+
same approach as the Rails framework itself.
|
28
|
+
See the new Configuration Guide documentation for details.
|
29
|
+
|
30
|
+
Configuration settings for controlling logging level have been added.
|
31
|
+
The MasterView admin controller is now disabled by default.
|
32
|
+
Use the config.enable_admin_pages setting to enable
|
33
|
+
(usually want only in your config/masterview/environments/development.rb).
|
34
|
+
|
35
|
+
The documentation has been reworked and enhanced to provide
|
36
|
+
improved documentation on installation and usage, along with
|
37
|
+
a new Configuration Guide describing how to customize the
|
38
|
+
MasterView configuration.
|
39
|
+
|
40
|
+
UPGRADE NOTES: If you have customized your MasterView configuration
|
41
|
+
in the init.rb file of your existing plugin installation, you *MUST*
|
42
|
+
migrate your configuration to the new settings file configuration mechanism
|
43
|
+
(config/masterview/settings.rb and environment settings files).
|
44
|
+
|
45
|
+
Also note that a directive was renamed from gen_render to gen_partial to
|
46
|
+
more clearly represent the functionality and eliminate future confusion.
|
47
|
+
Be sure to change any references to gen_render to gen_partial.
|
48
|
+
|
49
|
+
The default location for MasterView templates is now the standard Rails
|
50
|
+
app/views directory. Either move your existing templates into app/views
|
51
|
+
or update the MasterView config.template_src_dir_path setting in your
|
52
|
+
config/masterview/settings.rb to reference your existing templates source
|
53
|
+
directory.
|
54
|
+
|
55
|
+
== Recent changes (Release 0.1.0)
|
56
|
+
|
57
|
+
MasterView now by default generates five masterview template files instead
|
58
|
+
of one, though you can specify the --single-file option to only generate
|
59
|
+
one file. Using one masterview template file gives the most DRY implementation
|
60
|
+
but since all the views are in one file, it can become a point of contention
|
61
|
+
and is a little more difficult for designers to work with.
|
62
|
+
This Version 0.1.0 upgrade fixes that by generating one masterview template
|
63
|
+
for each action (list, new, edit, show, destroy). The layout and message
|
64
|
+
partials are defined in the list template and are imported into the other
|
65
|
+
files so that you can have a complete page rendering when working with style
|
66
|
+
and design of page. Similarly new defines the form partial which is imported
|
67
|
+
into edit, and show defines a _show partial which is imported into destroy.
|
68
|
+
|
69
|
+
One can edit the layout or other partials in the file they are defined in,
|
70
|
+
so for instance to edit the layout, edit the list template and once finished,
|
71
|
+
you can trigger the other templates to be rebuilt with the current information.
|
72
|
+
MasterView now contains an MasterView admin controller/view to visually see
|
73
|
+
all the status and details about the templates. You can rebuild any out of sync
|
74
|
+
templates from this page. Alternatively you can view and rebuild templates from
|
75
|
+
the command line as well using the built in rake commands (mv:list, mv:list_all,
|
76
|
+
mv:rebuild TEMPLATE=foo.html, mv:rebuild_all).
|
77
|
+
|
78
|
+
To make it easy to add additional actions which also import the layout,
|
79
|
+
MasterView now has a way to generate a starter template file for your action
|
80
|
+
by simply choosing from which other template file you want to import the layout
|
81
|
+
from. For instance say you want to add an action called hello to your Product
|
82
|
+
controller. Find the masterview template you want to get the layout imported
|
83
|
+
from which could be (product_list.html, product_new.html, product_edit.html, ...),
|
84
|
+
you can choose any of the templates that have the layout you want (it doesn't
|
85
|
+
matter whether they defined the layout or simply imported it. To generate the
|
86
|
+
starter template go to the MasterView Admin page http://yourserver/masterview
|
87
|
+
and click copy link next to the appropriate template. On the next screen indicate
|
88
|
+
the name of the action you wish to add (in this case 'hello') and click the submit
|
89
|
+
button. MasterView generates a starter template file product_hello.html which
|
90
|
+
imports the layout from the template file you chose and it creates some
|
91
|
+
placeholder divs in the template that you can edit to add your hello view code.
|
92
|
+
Alternatively there is also a
|
93
|
+
rake mv:copy_layout TEMPLATE=product_list.html ACTION=hello
|
94
|
+
command to allow you to do the same thing via command line.
|
95
|
+
|
96
|
+
Note that you don't have to use the starter or generated files to use MasterView
|
97
|
+
(you can just add MasterView attribute directives manually), but I found that
|
98
|
+
once you had things started and wanted to reuse that same information, that
|
99
|
+
having an automated way to get the layout imported makes it much easier and
|
100
|
+
quicker to get things going. You can also change the default action div that is
|
101
|
+
generated by simply creating your own file in app/views/masterview/admin/empty.rhtml
|
102
|
+
which if found the copy_layout will use it, otherwise it uses the one from the gem/plugin.
|
13
103
|
|
14
104
|
== Description
|
15
105
|
|
@@ -18,14 +108,20 @@ It is designed to use the full power and productivity of rails including
|
|
18
108
|
layouts, partials, and rails html helpers while still being editable/styleable
|
19
109
|
in a WYSIWYG HTML editor.
|
20
110
|
|
21
|
-
MasterView is distributed as a gem or a plugin. You may install it as a gem and
|
111
|
+
MasterView is distributed as a gem or a plugin. You may install it as a gem and
|
112
|
+
then generate a lightweight plugin which mainly refers to the gem *or* you can
|
113
|
+
simply install as a plugin which is self contained. I personally prefer installing
|
114
|
+
as a gem for ease of management, however if you are running at a shared hosting
|
115
|
+
environment you might not have authority to install this gem so you may install
|
116
|
+
as a self contained plugin.
|
22
117
|
|
23
118
|
If you are interested in the background story behind all this, it is at the end of this page.
|
24
119
|
|
25
120
|
Author:: Jeff Barczewski
|
26
121
|
Email:: jeff.barczewski @ gmail.com
|
27
|
-
|
122
|
+
Primary developers:: Jeff Barczewski, Deb Lewis
|
28
123
|
Website:: http://masterview.org
|
124
|
+
Rubyforge project:: masterview
|
29
125
|
License:: MIT open source license like Rails
|
30
126
|
|
31
127
|
== Goals
|
@@ -48,44 +144,29 @@ Optional::
|
|
48
144
|
tidy (gem) and tidy library - if these are installed you can use tidy to cleanup html into valid xhtml for use by MasterView
|
49
145
|
log4r (gem) - if this gem is installed then MasterView will use it for logging otherwise it defaults to using built in Logger.
|
50
146
|
|
51
|
-
==
|
52
|
-
|
53
|
-
Install in one of the two following ways depending on whether you can use gems or not.
|
54
|
-
|
55
|
-
=== Installation using gems (if you are able to use gems)
|
56
|
-
|
57
|
-
If you can use gems you may simply do the following
|
58
|
-
|
59
|
-
gem install masterview_gem_pack
|
147
|
+
== User Documentation
|
60
148
|
|
61
|
-
|
149
|
+
MasterView documentation is available online at the MasterView site:
|
150
|
+
http://www.masterview.org
|
151
|
+
and on the rubyforge project
|
152
|
+
http://rubyforge.org/projects/masterview/
|
62
153
|
|
63
|
-
|
64
|
-
|
65
|
-
After this MasterView is ready for use. Skip down to the Usage section for more details.
|
66
|
-
|
67
|
-
=== Installation without using gems, install as plugin
|
154
|
+
== Installation
|
68
155
|
|
69
|
-
|
156
|
+
Detailed installation instructions for installing the masterview gems
|
157
|
+
or a self-contained copy of the plugin is provided in the MasterView
|
158
|
+
Installation Guide.
|
70
159
|
|
71
|
-
|
160
|
+
The Configuration Guide describes how to customize the configuration
|
161
|
+
of the MasterView template engine for your application.
|
72
162
|
|
73
163
|
== Usage
|
74
164
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
By adding the --single-file switch MasterView will create a single file and to make it easier to use this template at design time, some design time css stylesheets are included in the file to hide all sections except one. By default the NEW section is the only one shown. Other options are --show-all which makes all sections visible or [--show-only list] which shows only the LIST section. When you are editing the masterview file you may comment/uncomment one of the other css files to show a different section. The --style param allows you to suppress default style generation and specify an existing stylesheet to use, if you exlude the stylesheet none will be used, if you include this option multiple times with different stylesheets each will be used.
|
82
|
-
|
83
|
-
Once it is done generating, the generated MasterView template file will be created in app/views/masterview/controller.html. This file is html and can be edited with any standard html editor. The rails specific logic is contained in simple attributes which are ignored by html editors. The syntax for these attributes is heavily derived from the rails helper tags themselves so it should feel natural to the rails developer.
|
84
|
-
|
85
|
-
Another interesting thing to know is that while all of the pages for this Model have been bundled up into a few html file for ease of editing, at runtime these templates gets rendered into the exact same layouts and partials that you would use if you were building from scratch. Its jsut that now you can see what your pages will render like in your wysiwyg html editor and change and layout accordingly. Additionally MasterView supplies some javascript to show only one action view at time (list, new, show, edit, destroy) so you can view in your browser without running in Rails. Dummy html can be included to improve the accuracy of the page which can be easily removed at runtime. To make it easier to work with in an editor, design time stylesheets are included in the file to allow you to hide all sections except the one you are working on, simply uncomment the appropriate stylesheet for the section you would like to work with.
|
86
|
-
|
87
|
-
MasterView is designed to be easy for a developer and designer to work together. By keeping the template in an html friendly format, designers can apply style, layout changes, wording changes, without causing havoc on the rails view code. The designer can be involved at anytime during the development cycle including being able to change style and layout after the system is built. This is great for allowing design or wording changes without reinvolving the developers. One can even start from a designer created prototype and add MasterView tags to make it become real. Whichever way you prefer to work, MasterView accomodates you.
|
88
|
-
|
89
|
-
With Version 0.1.0 a MasterView admin controller/view was added to provide a birds-eye view of all your masterview templates, the status of those templates (OK, Invalid xhtml, Conflicts, Imports outdated), the details regarding the status, and the ultimate erb files generated from each template. By default the MasterView admin controller is enabled by the plugin and is available at http://yourserver/masterview This controller can easily be disabled if not wanted by setting the EnableMasterViewAdminPages = false in the vendor/plugins/masterview/init.rb file. Additionally all of the power of the MasterView admin controller is available via a set of rake commands as well. rake mv:list mv:list_all mv:rebuild mv:rebuild_all mv:copy_layout. rake -T will give you further information about these commands.
|
165
|
+
The MasterView User's Guide and a complete Directives Reference are provided
|
166
|
+
in the MasterView user documentation. MasterView templates can be
|
167
|
+
created by hand simply by adding masterview directives markup to
|
168
|
+
an (x)html template, or generated for typical Rails controller/view
|
169
|
+
scenarios using the supplied masterview generator developer tool.
|
90
170
|
|
91
|
-
|
171
|
+
A MasterView Admin controller can optionally be activated in your application
|
172
|
+
to assist you during development with creating and managing your templates.
|
data/Rakefile
CHANGED
@@ -10,8 +10,6 @@ require 'rake/contrib/rubyforgepublisher'
|
|
10
10
|
require 'rake/contrib/xforge'
|
11
11
|
require 'rake/clean'
|
12
12
|
|
13
|
-
require 'gmailer'
|
14
|
-
|
15
13
|
#require 'archive/tar/minitar'
|
16
14
|
#require 'zlib'
|
17
15
|
|
@@ -25,37 +23,107 @@ RUBY_FORGE_GROUPID = "1290"
|
|
25
23
|
|
26
24
|
Main_dir = Dir.getwd
|
27
25
|
|
28
|
-
desc "Default Task"
|
26
|
+
desc "Default Task: run all tests"
|
29
27
|
task :default => [ :test ]
|
30
28
|
|
31
|
-
|
32
|
-
|
29
|
+
task :install => [:package] do
|
30
|
+
`gem install pkg/#{PKG_FILE_NAME}.gem`
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Delete tar.gz / zip / gem / rdoc / tmp"
|
34
|
+
task :cleanup => [ :rm_packages, 'doc:clobber_rdoc', 'dev:cleanup', 'test:cleanup' ]
|
35
|
+
|
36
|
+
|
37
|
+
#==============================================================================
|
38
|
+
# Test tasks
|
39
|
+
#==============================================================================
|
40
|
+
|
41
|
+
desc 'Run all tests'
|
42
|
+
task :test do
|
43
|
+
Rake::Task["test:units"].invoke rescue got_error = true
|
44
|
+
#Rake::Task["test:functionals"].invoke rescue got_error = true
|
45
|
+
#??Rake::Task["test:cleanup"].invoke rescue got_error = true
|
46
|
+
raise "Test failures" if got_error
|
47
|
+
end
|
33
48
|
|
34
|
-
# Run
|
35
|
-
|
49
|
+
# Run all unit tests
|
50
|
+
namespace 'test' do
|
51
|
+
Rake::TestTask.new(:units) do |t|
|
36
52
|
t.libs << "lib"
|
37
53
|
t.libs << "test"
|
38
|
-
t.pattern = 'test/*_test.rb'
|
54
|
+
t.pattern = 'test/unit/*_test.rb'
|
39
55
|
t.verbose = false
|
40
56
|
end
|
57
|
+
end
|
41
58
|
|
42
|
-
|
43
|
-
|
44
|
-
task :
|
45
|
-
|
46
|
-
|
47
|
-
filelist.each do |file|
|
48
|
-
MasterView::Parser.parse_file( file, TmpOutputDir, :tidy => true )
|
49
|
-
end
|
59
|
+
desc 'Clean up tmp files from running tests'
|
60
|
+
namespace 'test' do
|
61
|
+
task :cleanup do
|
62
|
+
FileUtils.remove_dir('test/tmp', true)
|
63
|
+
end
|
50
64
|
end
|
51
65
|
|
52
66
|
|
53
|
-
|
54
|
-
|
67
|
+
#==============================================================================
|
68
|
+
# Documentation Tasks
|
69
|
+
#==============================================================================
|
70
|
+
|
71
|
+
# Generate the RDoc documentation
|
72
|
+
namespace 'doc' do
|
73
|
+
Rake::RDocTask.new { |rdoc|
|
74
|
+
rdoc.rdoc_dir = 'doc/api'
|
75
|
+
rdoc.title = "MasterView Template Engine"
|
76
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
77
|
+
rdoc.rdoc_files.include('README')
|
78
|
+
rdoc.rdoc_files.include('RELEASE_NOTES')
|
79
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
#==============================================================================
|
84
|
+
# Development Utilities Tasks
|
85
|
+
#==============================================================================
|
86
|
+
|
87
|
+
desc 'Install MasterView gems locally from pkg dir'
|
88
|
+
namespace 'dev' do
|
89
|
+
task :install_local_gems do
|
90
|
+
pkg_build = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
91
|
+
pkg_version = MasterView::VERSION::STRING + pkg_build
|
92
|
+
`gem install pkg/masterview-#{pkg_version}.gem --local -f`
|
93
|
+
`gem install pkg/masterview_generator-#{pkg_version}.gem --local -f`
|
94
|
+
`gem install pkg/masterview_plugin_generator-#{pkg_version}.gem --local -f`
|
95
|
+
`gem install pkg/masterview_gem_pack-#{pkg_version}.gem --local -f`
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
desc 'Uninstall all MasterView gems'
|
100
|
+
namespace 'dev' do
|
101
|
+
task :uninstall_gems do
|
102
|
+
`gem uninstall masterview -a -x -i`
|
103
|
+
end
|
55
104
|
end
|
56
105
|
|
57
|
-
|
58
|
-
|
106
|
+
|
107
|
+
desc 'Run parser on masterview html templates in examples'
|
108
|
+
namespace 'dev' do
|
109
|
+
task :mvparse_examples do
|
110
|
+
template_mio_tree = MasterView::FileMIOTree.new('examples', '.html', :logging => true )
|
111
|
+
output_mio_tree = MasterView::FileMIOTree.new('tmp/views', '.rhtml', :logging => true )
|
112
|
+
template_mio_tree.find(:pattern => '*.html') do |mio|
|
113
|
+
MasterView::Parser.parse_mio( mio, output_mio_tree )
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Run syntax check on all ruby code files
|
119
|
+
desc 'Run syntax check on all ruby code files'
|
120
|
+
namespace 'dev' do
|
121
|
+
task :check_syntax do
|
122
|
+
#WAS: filelist = Dir.glob('**/*.rb')
|
123
|
+
#skip: generators - erb-ized code templates confuse the parser
|
124
|
+
filelist = [ 'init.rb', 'lib/masterview.rb' ]
|
125
|
+
filelist.concat Dir.glob('lib/**/*.rb')
|
126
|
+
filelist.concat Dir.glob('test/**/*.rb')
|
59
127
|
filelist.each do |file|
|
60
128
|
output = `ruby -c #{file}`
|
61
129
|
unless output =~ /Syntax OK/
|
@@ -64,26 +132,29 @@ task :syntax do
|
|
64
132
|
return
|
65
133
|
end
|
66
134
|
end
|
135
|
+
puts "#{filelist.length} files checked"
|
67
136
|
puts 'Syntax OK'
|
68
137
|
end
|
138
|
+
end
|
69
139
|
|
70
|
-
#
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
rdoc.rdoc_files.include('README')
|
76
|
-
rdoc.rdoc_files.include('RELEASE_NOTES')
|
77
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
78
|
-
}
|
79
|
-
|
80
|
-
task :lines do
|
140
|
+
# Count LOC in plugin lib
|
141
|
+
desc 'Count LOC'
|
142
|
+
namespace 'dev' do
|
143
|
+
task :count_loc do
|
144
|
+
files = 0
|
81
145
|
lines = 0
|
82
146
|
codelines = 0
|
83
|
-
|
84
|
-
|
147
|
+
|
148
|
+
#VER1 WAS: Dir.foreach("lib") { |file_name|
|
149
|
+
#VER1 WAS: next unless file_name =~ /.*rb/
|
150
|
+
#VER1 WAS: f = File.open("lib/" + file_name)
|
151
|
+
filelist = [ 'init.rb', 'lib/masterview.rb' ]
|
152
|
+
filelist.concat Dir.glob('lib/**/*.rb')
|
153
|
+
#filelist.concat Dir.glob('test**/*.rb')
|
154
|
+
filelist.each { |file_name|
|
85
155
|
|
86
|
-
f = File.open(
|
156
|
+
f = File.open(file_name)
|
157
|
+
files += 1
|
87
158
|
|
88
159
|
while line = f.gets
|
89
160
|
lines += 1
|
@@ -92,10 +163,22 @@ task :lines do
|
|
92
163
|
codelines += 1
|
93
164
|
end
|
94
165
|
}
|
95
|
-
puts "Lines #{lines}, LOC #{codelines}"
|
166
|
+
puts "Lines #{lines}, LOC #{codelines} in #{files} files"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
desc 'Remove tmp files from running dev utilities'
|
171
|
+
namespace 'dev' do
|
172
|
+
task :cleanup do
|
173
|
+
FileUtils.remove_dir('tmp', true)
|
174
|
+
end
|
96
175
|
end
|
97
176
|
|
98
177
|
|
178
|
+
#==============================================================================
|
179
|
+
# Build/Release Tasks
|
180
|
+
#==============================================================================
|
181
|
+
|
99
182
|
# Publish beta gem
|
100
183
|
#desc "Publish the gem"
|
101
184
|
#task :publish => [:rdoc, :package] do
|
@@ -119,27 +202,92 @@ task :verify_gmail do
|
|
119
202
|
raise "GMAIL_PASSWORD environment variable not set!" unless ENV['GMAIL_PASSWORD']
|
120
203
|
end
|
121
204
|
|
205
|
+
def copy_if_different(src,dst)
|
206
|
+
return if File.exist?(src) and File.exist?(dst) and File.read(src) == File.read(dst)
|
207
|
+
FileUtils.cp src, dst
|
208
|
+
end
|
209
|
+
|
210
|
+
desc 'Copy duplicated files - copy files that are duplicated between packages'
|
211
|
+
task :copy_duplicated_files do
|
212
|
+
copy_if_different 'init.rb', 'generators/masterview_plugin/templates/init.rb'
|
213
|
+
copy_if_different 'tasks/masterview.rake', 'generators/masterview_plugin/templates/masterview.rake'
|
214
|
+
copy_if_different 'lib/masterview/extras/app/views/masterview/admin/empty.rhtml', 'generators/masterview_plugin/templates/empty.rhtml'
|
215
|
+
copy_if_different 'examples/rails_app_config/masterview/settings.rb', 'generators/masterview_plugin/templates/settings.rb'
|
216
|
+
copy_if_different 'examples/rails_app_config/masterview/environment/development.rb', 'generators/masterview_plugin/templates/development.rb'
|
217
|
+
copy_if_different 'examples/rails_app_config/masterview/environment/production.rb', 'generators/masterview_plugin/templates/production.rb'
|
218
|
+
end
|
122
219
|
|
123
220
|
desc 'Build all packages'
|
124
|
-
task :package => [
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
221
|
+
task :package => [
|
222
|
+
:copy_duplicated_files,
|
223
|
+
# gems (runtime, mv generator, mv plugin generator, 3-in-1 supersaver)
|
224
|
+
'masterview:package',
|
225
|
+
'masterview_generator:package',
|
226
|
+
'masterview_plugin_generator:package',
|
227
|
+
'masterview_gem_pack:package',
|
228
|
+
# zip/gzip of full masterview
|
229
|
+
'masterview_plugin:package'
|
230
|
+
]
|
129
231
|
|
130
232
|
desc 'Re-build all packages'
|
131
|
-
task :repackage => [
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
233
|
+
task :repackage => [
|
234
|
+
:copy_duplicated_files,
|
235
|
+
# gems (runtime, mv generator, mv plugin generator, 3-in-1 supersaver)
|
236
|
+
'masterview:repackage',
|
237
|
+
'masterview_generator:repackage',
|
238
|
+
'masterview_plugin_generator:repackage',
|
239
|
+
'masterview_gem_pack:repackage',
|
240
|
+
# zip/gzip of full masterview
|
241
|
+
'masterview_plugin:repackage'
|
242
|
+
]
|
136
243
|
|
137
244
|
desc 'Release all files'
|
138
|
-
task :release_files => [
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
245
|
+
task :release_files => [
|
246
|
+
# gems (runtime, mv generator, mv plugin generator, 3-in-1 supersaver)
|
247
|
+
'masterview:release_files',
|
248
|
+
'masterview_generator:release_files',
|
249
|
+
'masterview_plugin_generator:release_files',
|
250
|
+
'masterview_gem_pack:release_files',
|
251
|
+
# zip/gzip of full masterview
|
252
|
+
'masterview_plugin:release_files'
|
253
|
+
]
|
254
|
+
|
255
|
+
desc 'Remove all tar.gz / zip / gem build pkg files'
|
256
|
+
task :rm_packages do
|
257
|
+
FileUtils.remove_dir('pkg', true)
|
258
|
+
end
|
259
|
+
|
260
|
+
####
|
261
|
+
#ISSUE: jeff - we don't include that top-level index.html in any of the packages?!
|
262
|
+
####
|
263
|
+
PKG_FILES_RELEASE_DOCS = [
|
264
|
+
"[A-Z]*" # README, RELEASE_NOTES, CHANGELOG, MIT_LICENSE, TODO
|
265
|
+
]
|
266
|
+
|
267
|
+
PKG_FILES_RUNTIME = [
|
268
|
+
"lib/**/*",
|
269
|
+
"directives/**/*", #SHOULD THIS GO AWAY (??)
|
270
|
+
"Rakefile",
|
271
|
+
"init.rb"
|
272
|
+
]
|
273
|
+
PKG_FILES_MV_GENERATOR = [
|
274
|
+
"generators/masterview/**/*" # generator for creating app template scaffold
|
275
|
+
]
|
276
|
+
PKG_FILES_MV_PLUGIN_GENERATOR = [
|
277
|
+
"generators/masterview_plugin/**/*" # generator for creating vendor/plugins stub for gem install
|
278
|
+
]
|
279
|
+
|
280
|
+
PKG_FILES_DOCS = [ # docs and examples, actually
|
281
|
+
"doc/*",
|
282
|
+
"doc/stylesheets/*",
|
283
|
+
"examples/**/*"
|
284
|
+
]
|
285
|
+
PKG_FILES_TESTS = [
|
286
|
+
"test/**/*"
|
287
|
+
]
|
288
|
+
PKG_FILES_EXCLUDE_PATTERN = /\bCVS\b|~$|\.svn|semantic.cache/
|
289
|
+
|
290
|
+
RAKE_PROCESSOR = RUBY_PLATFORM =~ /mswin32/ ? 'rake.cmd' : 'rake' # sigh
|
143
291
|
|
144
292
|
namespace 'masterview_plugin' do
|
145
293
|
module MasterViewComplete
|
@@ -149,16 +297,8 @@ namespace 'masterview_plugin' do
|
|
149
297
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
150
298
|
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
|
151
299
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
152
|
-
|
153
|
-
|
154
|
-
"generators/masterview/**/*", #exclude the masterview_plugin generator, not needed for non-gem install
|
155
|
-
"directives/**/*",
|
156
|
-
"test/**/*",
|
157
|
-
"example/**/*",
|
158
|
-
"[A-Z]*",
|
159
|
-
"Rakefile",
|
160
|
-
"init.rb"
|
161
|
-
].exclude(/\bCVS\b|~$|\.svn|semantic.cache/)
|
300
|
+
PKG_INCLUDES = PKG_FILES_RUNTIME + PKG_FILES_MV_GENERATOR + PKG_FILES_DOCS + PKG_FILES_TESTS + PKG_FILES_RELEASE_DOCS
|
301
|
+
PKG_FILES = FileList.new( PKG_INCLUDES ).exclude( PKG_FILES_EXCLUDE_PATTERN )
|
162
302
|
|
163
303
|
spec = Gem::Specification.new do |s|
|
164
304
|
s.name = PKG_NAME
|
@@ -226,9 +366,8 @@ namespace 'masterview_gem_pack' do
|
|
226
366
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
227
367
|
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
|
228
368
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
229
|
-
|
230
|
-
|
231
|
-
].exclude(/\bCVS\b|~$|\.svn|semantic.cache/)
|
369
|
+
PKG_INCLUDES = PKG_FILES_RELEASE_DOCS
|
370
|
+
PKG_FILES = FileList.new( PKG_INCLUDES ).exclude( PKG_FILES_EXCLUDE_PATTERN )
|
232
371
|
|
233
372
|
spec = Gem::Specification.new do |s|
|
234
373
|
s.name = PKG_NAME
|
@@ -299,15 +438,8 @@ namespace 'masterview' do
|
|
299
438
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
300
439
|
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
|
301
440
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
302
|
-
|
303
|
-
|
304
|
-
"directives/**/*",
|
305
|
-
"test/**/*",
|
306
|
-
"example/**/*",
|
307
|
-
"[A-Z]*",
|
308
|
-
"Rakefile",
|
309
|
-
"init.rb"
|
310
|
-
].exclude(/\bCVS\b|~$|\.svn|semantic.cache/)
|
441
|
+
PKG_INCLUDES = PKG_FILES_RUNTIME + PKG_FILES_DOCS + PKG_FILES_TESTS + PKG_FILES_RELEASE_DOCS
|
442
|
+
PKG_FILES = FileList.new( PKG_INCLUDES ).exclude( PKG_FILES_EXCLUDE_PATTERN )
|
311
443
|
|
312
444
|
spec = Gem::Specification.new do |s|
|
313
445
|
s.name = PKG_NAME
|
@@ -378,12 +510,14 @@ namespace 'masterview_generator' do
|
|
378
510
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
379
511
|
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
|
380
512
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
381
|
-
|
513
|
+
#PKG_INCLUDES = PKG_FILES_MV_GENERATOR
|
514
|
+
#PKG_FILES = FileList.new( PKG_INCLUDES ).exclude( PKG_FILES_EXCLUDE_PATTERN )
|
515
|
+
|
382
516
|
desc "Package masterview_generator"
|
383
517
|
task :package do
|
384
518
|
work_dir = Dir.getwd
|
385
519
|
Dir.chdir 'generators/masterview'
|
386
|
-
system( "
|
520
|
+
system( "#{RAKE_PROCESSOR} package" )
|
387
521
|
Dir.chdir work_dir
|
388
522
|
end
|
389
523
|
|
@@ -391,7 +525,7 @@ namespace 'masterview_generator' do
|
|
391
525
|
task :repackage do
|
392
526
|
work_dir = Dir.getwd
|
393
527
|
Dir.chdir 'generators/masterview'
|
394
|
-
system( "
|
528
|
+
system( "#{RAKE_PROCESSOR} repackage" )
|
395
529
|
Dir.chdir work_dir
|
396
530
|
end
|
397
531
|
|
@@ -442,16 +576,14 @@ namespace 'masterview_plugin_generator' do
|
|
442
576
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
443
577
|
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
|
444
578
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
445
|
-
|
446
|
-
|
447
|
-
"[A-Z]*"
|
448
|
-
].exclude(/\bCVS\b|~$|\.svn|semantic.cache/)
|
579
|
+
PKG_INCLUDES = PKG_FILES_MV_PLUGIN_GENERATOR + PKG_FILES_RELEASE_DOCS
|
580
|
+
PKG_FILES = FileList.new( PKG_INCLUDES ).exclude( PKG_FILES_EXCLUDE_PATTERN )
|
449
581
|
|
450
582
|
desc "Package masterview_generator"
|
451
583
|
task :package do
|
452
584
|
work_dir = Dir.getwd
|
453
585
|
Dir.chdir 'generators/masterview_plugin'
|
454
|
-
system( "
|
586
|
+
system( "#{RAKE_PROCESSOR} package" )
|
455
587
|
Dir.chdir work_dir
|
456
588
|
end
|
457
589
|
|
@@ -459,7 +591,7 @@ namespace 'masterview_plugin_generator' do
|
|
459
591
|
task :repackage do
|
460
592
|
work_dir = Dir.getwd
|
461
593
|
Dir.chdir 'generators/masterview_plugin'
|
462
|
-
system( "
|
594
|
+
system( "#{RAKE_PROCESSOR} repackage" )
|
463
595
|
Dir.chdir work_dir
|
464
596
|
end
|
465
597
|
|
@@ -502,8 +634,6 @@ namespace 'masterview_plugin_generator' do
|
|
502
634
|
end
|
503
635
|
|
504
636
|
|
505
|
-
|
506
|
-
|
507
637
|
desc "Publish news on RubyForge"
|
508
638
|
task :publish_news => [ :verify_rubyforge, :tar, :gem, :demotar] do
|
509
639
|
Rake::XForge::NewsPublisher.new(Ruby_PDF) do |news|
|
@@ -527,12 +657,11 @@ end
|
|
527
657
|
desc "Post a release announcement via GMail."
|
528
658
|
#task :email_announcement => [ :verify_gmail, :tar, :gem, :demotar] do
|
529
659
|
task :email_announcement => [ :verify_gmail ] do
|
660
|
+
require 'gmailer'
|
530
661
|
GMailer.connect(ENV["GMAIL_USER"], ENV["GMAIL_PASSWORD"]) do |gmail|
|
531
662
|
gmail.send :to => "ruby-talk@ruby-lang.org",
|
532
663
|
:subject => "[ANN] PDF::Writer #{PDF::Writer::VERSION}",
|
533
664
|
:body => File.read("Release-Announcement")
|
534
665
|
end
|
535
|
-
end
|
536
|
-
|
537
|
-
|
538
666
|
|
667
|
+
end
|