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.
Files changed (105) hide show
  1. data/CHANGELOG +17 -0
  2. data/README +36 -504
  3. data/RELEASE_NOTES +126 -45
  4. data/Rakefile +215 -86
  5. data/TODO +8 -3
  6. data/doc/configuration.html +485 -0
  7. data/doc/directives.html +1085 -0
  8. data/doc/guide.html +243 -0
  9. data/doc/index.html +287 -0
  10. data/doc/installation.html +376 -0
  11. data/doc/stylesheets/masterview.css +206 -0
  12. data/doc/stylesheets/mv-config.css +23 -0
  13. data/doc/stylesheets/mv-directives.css +18 -0
  14. data/doc/stylesheets/mv-installation.css +10 -0
  15. data/doc/troubleshooting.html +18 -0
  16. data/examples/product.html +256 -0
  17. data/examples/product.html.old +107 -0
  18. data/examples/rails_app_config/masterview/environment/development.rb +22 -0
  19. data/examples/rails_app_config/masterview/environment/production.rb +9 -0
  20. data/examples/rails_app_config/masterview/settings.rb +59 -0
  21. data/examples/test.import +80 -0
  22. data/init.rb +26 -12
  23. data/lib/masterview/analyzer.rb +25 -15
  24. data/lib/masterview/directive_base.rb +4 -0
  25. data/lib/masterview/directive_helpers.rb +7 -5
  26. data/lib/masterview/directives/import_render.rb +6 -0
  27. data/lib/masterview/directives/insert_generated_comment.rb +8 -8
  28. data/lib/masterview/extras/app/controllers/masterview_controller.rb +154 -2
  29. data/lib/masterview/extras/app/views/masterview/admin/create.rhtml +4 -4
  30. data/lib/masterview/extras/app/views/masterview/admin/empty.rhtml +1 -1
  31. data/lib/masterview/extras/app/views/masterview/admin/list.rhtml +14 -9
  32. data/lib/masterview/extras/app/views/masterview/admin/view_rhtml.rhtml +70 -0
  33. data/lib/masterview/extras/init_logger.rb +102 -0
  34. data/lib/masterview/extras/init_rails_erb_mv_direct.rb +117 -0
  35. data/lib/masterview/extras/init_rails_reparse_checking.rb +59 -0
  36. data/lib/masterview/extras/watcher.rb +17 -23
  37. data/lib/masterview/filter_helpers.rb +26 -0
  38. data/lib/masterview/initializer.rb +912 -0
  39. data/lib/masterview/io.rb +352 -0
  40. data/lib/masterview/keyword_expander.rb +116 -0
  41. data/lib/masterview/masterview_version.rb +2 -2
  42. data/lib/masterview/mtime_tracking_hash.rb +44 -0
  43. data/lib/masterview/parser.rb +64 -92
  44. data/lib/masterview/pathname_extensions.rb +33 -0
  45. data/lib/masterview/template_spec.rb +49 -56
  46. data/lib/masterview.rb +40 -85
  47. data/test/fixtures/configs/fake_rails_app_with_config/config/masterview/environments/development.rb +12 -0
  48. data/test/fixtures/configs/fake_rails_app_with_config/config/masterview/environments/production.rb +11 -0
  49. data/test/fixtures/configs/fake_rails_app_with_config/config/masterview/settings.rb +23 -0
  50. data/test/fixtures/templates/product.html +256 -0
  51. data/test/fixtures/templates/test.import +80 -0
  52. data/test/test_helper.rb +5 -3
  53. data/test/tmp/template/foo.txt +1 -0
  54. data/test/tmp/templates_src/product.html +256 -0
  55. data/test/tmp/views/layouts/product.rhtml +35 -0
  56. data/test/tmp/views/product/_form.rhtml +30 -0
  57. data/test/tmp/views/product/_product.rhtml +14 -0
  58. data/test/tmp/views/product/_show.rhtml +27 -0
  59. data/test/tmp/views/product/destroy.rhtml +27 -0
  60. data/test/tmp/views/product/edit.rhtml +26 -0
  61. data/test/tmp/views/product/list.rhtml +31 -0
  62. data/test/tmp/views/product/new.rhtml +29 -0
  63. data/test/tmp/views/product/show.rhtml +16 -0
  64. data/test/unit/config_settings_test.rb +172 -0
  65. data/test/{attr_test.rb → unit/directive_attr_test.rb} +2 -2
  66. data/test/{block_test.rb → unit/directive_block_test.rb} +2 -2
  67. data/test/{content_test.rb → unit/directive_content_test.rb} +2 -2
  68. data/test/{else_test.rb → unit/directive_else_test.rb} +2 -2
  69. data/test/{elsif_test.rb → unit/directive_elsif_test.rb} +2 -2
  70. data/test/{form_test.rb → unit/directive_form_test.rb} +2 -2
  71. data/test/{global_inline_erb_test.rb → unit/directive_global_inline_erb_test.rb} +2 -2
  72. data/test/{hidden_field_test.rb → unit/directive_hidden_field_test.rb} +2 -2
  73. data/test/{if_test.rb → unit/directive_if_test.rb} +2 -2
  74. data/test/unit/directive_import_render_test.rb +62 -0
  75. data/test/{import_test.rb → unit/directive_import_test.rb} +2 -2
  76. data/test/{javascript_include_test.rb → unit/directive_javascript_include_test.rb} +2 -2
  77. data/test/{link_to_if_test.rb → unit/directive_link_to_if_test.rb} +2 -2
  78. data/test/{link_to_test.rb → unit/directive_link_to_test.rb} +2 -2
  79. data/test/{omit_tag_test.rb → unit/directive_omit_tag_test.rb} +2 -2
  80. data/test/{password_field_test.rb → unit/directive_password_field_test.rb} +2 -2
  81. data/test/{replace_test.rb → unit/directive_replace_test.rb} +2 -2
  82. data/test/{stylesheet_link_test.rb → unit/directive_stylesheet_link_test.rb} +2 -2
  83. data/test/{submit_test.rb → unit/directive_submit_test.rb} +2 -2
  84. data/test/{text_area_test.rb → unit/directive_text_area_test.rb} +2 -2
  85. data/test/{text_field_test.rb → unit/directive_text_field_test.rb} +2 -2
  86. data/test/{example_test.rb → unit/example_test.rb} +1 -1
  87. data/test/unit/file_mio_test.rb +368 -0
  88. data/test/{filter_helpers_test.rb → unit/filter_helpers_test.rb} +1 -1
  89. data/test/unit/keyword_expander_test.rb +95 -0
  90. data/test/unit/mio_test.rb +110 -0
  91. data/test/unit/mtime_string_hash_mio_tree_test.rb +289 -0
  92. data/test/unit/mtime_tracking_hash_test.rb +38 -0
  93. data/test/{parser_test.rb → unit/parser_test.rb} +19 -1
  94. data/test/unit/pathname_extensions_test.rb +46 -0
  95. data/test/{run_parser_test.rb → unit/run_parser_test.rb} +7 -3
  96. data/test/unit/string_hash_mio_test.rb +320 -0
  97. data/test/unit/template_file_watcher_test.rb +107 -0
  98. data/test/{template_spec_test.rb → unit/template_spec_test.rb} +57 -21
  99. data/test/{template_test.rb → unit/template_test.rb} +123 -22
  100. data/test/xtras/config-mv-logger_config.rb +109 -0
  101. data/test/xtras/config_initialize_standalone.rb +53 -0
  102. metadata +111 -38
  103. data/lib/masterview/extras/rails_init.rb +0 -72
  104. data/test/import_render_test.rb +0 -30
  105. 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
- MasterView now by default generates five masterview template files instead of one, though you can specify the --single-file option to only generate one file. Using one masterview template file gives the most DRY implementation but since all the views are in one file, it can become a point of contention and is a little more difficult for designers to work with. This Version 0.1.0 upgrade fixes that by generating one masterview template for each action (list, new, edit, show, destroy). The layout and message partials are defined in the list template and are imported into the other files so that you can have a complete page rendering when working with style and design of page. Similarly new defines the form partial which is imported into edit, and show defines a _show partial which is imported into destroy.
6
-
7
- One can edit the layout or other partials in the file they are defined in, so for instance to edit the layout, edit the list template and once finished, you can trigger the other templates to be rebuilt with the current information. MasterView now contains an MasterView admin controller/view to visually see all the status and details about the templates. You can rebuild any out of sync templates from this page. Alternatively you can view and rebuild templates from the command line as well using the built in rake commands (mv:list, mv:list_all, mv:rebuild TEMPLATE=foo.html, mv:rebuild_all).
8
-
9
- To make it easy to add additional actions which also import the layout, MasterView now has a way to generate a starter template file for your action by simply choosing from which other template file you want to import the layout from. For instance say you want to add an action called hello to your Product controller. Find the masterview template you want to get the layout imported from which could be (product_list.html, product_new.html, product_edit.html, ...), you can choose any of the templates that have the layout you want (it doesn't matter whether they defined the layout or simply imported it. To generate the starter template go to the MasterView Admin page http://yourserver/masterview and click copy link next to the appropriate template. On the next screen indicate the name of the action you wish to add (in this case 'hello') and click the submit button. MasterView generates a starter template file product_hello.html which imports the layout from the template file you chose and it creates some placeholder divs in the template that you can edit to add your hello view code. Alternatively there is also a rake mv:copy_layout TEMPLATE=product_list.html ACTION=hello command to allow you to do the same thing via command line.
10
-
11
- Note that you don't have to use the starter or generated files to use MasterView (you can just add MasterView attribute directives manually), but I found that once you had things started and wanted to reuse that same information, that having an automated way to get the layout imported makes it much easier and quicker to get things going. You can also change the default action div that is generated by simply creating your own file in app/views/masterview/admin/empty.rhtml which if found the copy_layout will use it, otherwise it uses the one from the gem/plugin.
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 then generate a lightweight plugin which mainly refers to the gem *or* you can simply install as a plugin which is self contained. I personally prefer installing as a gem for ease of management, however if you are running at a shared hosting environment you might not have authority to install this gem so you may install as a self contained plugin.
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
- Rubyforge project:: masterview
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
- == Installation
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
- Now your gem is installed and you can skip these steps in the future. After creating your rails directory, change directory to it and run the following to create a very lightweight plugin instance for this application mainly consisting of an init.rb file which will get loaded at runtime. This init.rb refers to the gem for everything but allows you to override any constants or setup that has been provided. See MasterView module masterview.rb for a list of the available constants.
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
- script/generate masterview_plugin
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
- script/plugin install svn://rubyforge.org/var/svn/masterview/tags/latest
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
- This will copy entire MasterView system into your vendor/plugin/masterview directory. You may tweak its init.rb to override any MasterView constants at runtime. See MasterView module masterview.rb for a list of available constants. Note that if you don't have svn (subversion) installed, you may also retrieve the plugin package (masterview_plugin.tgz or masterview_plugin.zip) from http://rubyforge.org/projects/masterview and simply extract into vendor/plugins/masterview
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
- You may add MasterView attributes to existing (x)html or you may use the masterview generator to create a complete working application. The generator can create controllers, models, and the MasterView template file similar to how the built-in generator works. Simply change directory to your rails application and run the following
76
-
77
- script/generate masterview YourModelName [YourControllerName] [--style [cssStylesheet]] [--single-file] [--show-all | --show-only list]
78
-
79
- The generator by default will generate five masterview template files, one for each distinct page, list, new, edit, show, and destroy. They exist in the app/views/masterview directory with the filename controller_action.html. The layout and message partial are defined in the list template file and imported into the others. Similarly the new template defines the form partial which is imported into edit, and finally the show file defines a _show partial which is imported into destroy. Thus there is one definition of each part (layout and partial) and they are imported into the other files where needed to provide accurate WYSIWYG design time editing. By generating separate files, teams can work on a project easier, however MasterView also supports generating all parts to a single file for the ultimate in DRY.
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
- Since it can be difficult to import a layout by hand into a new file, the MasterView admin controller has a link where you can copy the layout into a new file by providing the new files Action. It will take the layout from the template chosen and create a new file controller_action.html with the layout imported and a shell for the new Action code. You can also do this from command line using rake mv:copy_layout TEMPLATE=foo_list.html ACTION=newaction command.
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
- desc "Delete tar.gz / zip / rdoc"
32
- task :cleanup => [ :rm_packages, :clobber_rdoc ]
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 the unit tests
35
- Rake::TestTask.new(:test) do |t|
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
- # Run parser on masterview html files
43
- desc "Run parser on masterview html files"
44
- task :mvparse do
45
- TmpOutputDir = 'tmp/views'
46
- filelist = Dir.glob('examples/**/*.html')
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
- task :install => [:package] do
54
- `gem install pkg/#{PKG_FILE_NAME}.gem`
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
- task :syntax do
58
- filelist = Dir.glob('**/*.rb')
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
- # Genereate the RDoc documentation
71
- Rake::RDocTask.new { |rdoc|
72
- rdoc.rdoc_dir = 'doc'
73
- rdoc.title = "MasterView Template Engine"
74
- rdoc.options << '--line-numbers' << '--inline-source'
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
- Dir.foreach("lib") { |file_name|
84
- next unless file_name =~ /.*rb/
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("lib/" + file_name)
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 => ['masterview_plugin:package',
125
- 'masterview:package',
126
- 'masterview_generator:package',
127
- 'masterview_plugin_generator:package',
128
- 'masterview_gem_pack:package']
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 => ['masterview_plugin:repackage',
132
- 'masterview:repackage',
133
- 'masterview_generator:repackage',
134
- 'masterview_plugin_generator:repackage',
135
- 'masterview_gem_pack:repackage']
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 => ['masterview_plugin:release_files',
139
- 'masterview:release_files',
140
- 'masterview_generator:release_files',
141
- 'masterview_plugin_generator:release_files',
142
- 'masterview_gem_pack:release_files']
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
- PKG_FILES = FileList[
153
- "lib/**/*",
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
- PKG_FILES = FileList[
230
- "[A-Z]*",
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
- PKG_FILES = FileList[
303
- "lib/**/*",
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( "rake package" )
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( "rake repackage" )
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
- PKG_FILES = FileList[
446
- "generators/masterview_plugin/**/*",
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( "rake package" )
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( "rake repackage" )
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