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
@@ -2,10 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
4
|
currentPath = File.dirname(__FILE__)
|
5
|
-
require File.join( currentPath, '
|
6
|
-
require File.join( currentPath, 'test_helper' )
|
5
|
+
require File.join( currentPath, '../../lib/masterview' )
|
6
|
+
require File.join( currentPath, '../test_helper' )
|
7
7
|
|
8
8
|
class TestTemplate < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
MasterView::IOMgr.erb = MasterView::StringHashMIOTree.new({}, '.rhtml', :logging => true)
|
11
|
+
end
|
9
12
|
|
10
13
|
def test_attr
|
11
14
|
template = <<-END
|
@@ -59,11 +62,11 @@ class TestTemplate < Test::Unit::TestCase
|
|
59
62
|
assert_template_result expected, template
|
60
63
|
end
|
61
64
|
|
62
|
-
def
|
65
|
+
def test_multi_gen_partial
|
63
66
|
template = <<-END
|
64
67
|
<div mv:generate='foo/bar'>
|
65
68
|
<span mv:replace="h product[:price]">foo bar</span>
|
66
|
-
<div mv:
|
69
|
+
<div mv:gen_partial=":partial => 'baz/caz'">
|
67
70
|
<span mv:content="h product[:name]">hello world</span>
|
68
71
|
</div>
|
69
72
|
</div>
|
@@ -75,22 +78,6 @@ class TestTemplate < Test::Unit::TestCase
|
|
75
78
|
assert_template_result expected, template
|
76
79
|
end
|
77
80
|
|
78
|
-
def test_multi_spec_dir
|
79
|
-
template = <<-END
|
80
|
-
<div mv:generate='foo/bar'>
|
81
|
-
<span mv:replace="h product[:price]">foo bar</span>
|
82
|
-
<div mv:generate='baz/caz'>
|
83
|
-
<span mv:content="h product[:name]">hello world</span>
|
84
|
-
</div>
|
85
|
-
</div>
|
86
|
-
END
|
87
|
-
expected = {
|
88
|
-
'/a/b/foo/bar' => "<div><%= h product[:price] %></div>",
|
89
|
-
'/a/b/baz/caz' => "<div><span><%= h product[:name] %></span></div>"
|
90
|
-
}
|
91
|
-
assert_template_result expected, template, :output_dir => '/a/b'
|
92
|
-
end
|
93
|
-
|
94
81
|
def test_replace
|
95
82
|
template = <<-END
|
96
83
|
<div mv:generate='foo/bar'>
|
@@ -357,11 +344,11 @@ class TestTemplate < Test::Unit::TestCase
|
|
357
344
|
assert_template_result expected, template
|
358
345
|
end
|
359
346
|
|
360
|
-
def
|
347
|
+
def test_omit_tag_root_with_nested_gen_partial
|
361
348
|
template = <<-END
|
362
349
|
<div mv:generate='foo/bar' mv:omit_tag="">
|
363
350
|
first layer
|
364
|
-
<foo mv:
|
351
|
+
<foo mv:gen_partial=":partial => 'baz/cat'" mv:omit_tag="">hello world</foo>
|
365
352
|
</div>
|
366
353
|
END
|
367
354
|
expected = {
|
@@ -371,4 +358,118 @@ class TestTemplate < Test::Unit::TestCase
|
|
371
358
|
assert_template_result expected, template
|
372
359
|
end
|
373
360
|
|
361
|
+
|
362
|
+
# Only simplify elements that are specified in the DTD as being empty, collapsing others can cause parsing
|
363
|
+
# or rendering problems in browsers. Uses constant XHTMLEmptyElementNameSet to find elements that should be
|
364
|
+
# collapsed.
|
365
|
+
# http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict
|
366
|
+
# xhtml-1.0-Strict empty elements are:
|
367
|
+
# base, meta, link, hr, br, param, img, area, input, col
|
368
|
+
def test_simplify_empty_elements
|
369
|
+
template = <<-END
|
370
|
+
<div mv:generate='foo/bar'>
|
371
|
+
<script src="boo"></script>
|
372
|
+
<foo></foo>
|
373
|
+
<base foo="bar"></base>
|
374
|
+
<meta foo="baz"></meta>
|
375
|
+
<link src="cat"></link>
|
376
|
+
<hr/>
|
377
|
+
<hr clear="left"/>
|
378
|
+
<hr clear="left" />
|
379
|
+
<hr clear="left"></hr>
|
380
|
+
<hr></hr>
|
381
|
+
<br></br>
|
382
|
+
<br/>
|
383
|
+
<param foo="bar"></param>
|
384
|
+
<img src="foo"></img>
|
385
|
+
<img src="foo"/>
|
386
|
+
<img src="foo" />
|
387
|
+
<area foo="bar"></area>
|
388
|
+
<input type="hidden"></input>
|
389
|
+
<col></col>
|
390
|
+
<!-- test -->
|
391
|
+
<![CDATA[ hello ]]>
|
392
|
+
1 < 2
|
393
|
+
</div>
|
394
|
+
END
|
395
|
+
expected = {
|
396
|
+
'foo/bar' => %q{<div><script src="boo"></script><foo></foo><base foo="bar" />}+
|
397
|
+
%q{<meta foo="baz" /><link src="cat" /><hr /><hr clear="left" /><hr clear="left" /><hr clear="left" />}+
|
398
|
+
%q{<hr /><br /><br /><param foo="bar" /><img src="foo" /><img src="foo" /><img src="foo" />}+
|
399
|
+
%q{<area foo="bar" /><input type="hidden" /><col /><!-- test --><![CDATA[ hello ]]>1 < 2 </div>}
|
400
|
+
}
|
401
|
+
assert_template_result expected, template
|
402
|
+
end
|
403
|
+
|
404
|
+
|
405
|
+
def test_keyword_expansion_template_path
|
406
|
+
template = <<-END
|
407
|
+
<div mv:generate='{template_path}'>hello world</div>]
|
408
|
+
END
|
409
|
+
expected = {
|
410
|
+
'one/two_three.rhtml' => "<div>hello world</div>"
|
411
|
+
}
|
412
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
413
|
+
end
|
414
|
+
|
415
|
+
def test_keyword_expansion_template_path_foo_ext
|
416
|
+
begin
|
417
|
+
original_default_extension = MasterView::IOMgr.erb.default_extension
|
418
|
+
MasterView::IOMgr.erb.default_extension = '.foo'
|
419
|
+
template = <<-END
|
420
|
+
<div mv:generate='{template_path}'>hello world</div>]
|
421
|
+
END
|
422
|
+
expected = {
|
423
|
+
'one/two_three.foo' => "<div>hello world</div>"
|
424
|
+
}
|
425
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
426
|
+
rescue
|
427
|
+
raise
|
428
|
+
ensure
|
429
|
+
MasterView::IOMgr.erb.default_extension = original_default_extension
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
def test_keyword_expansion_template_path_original
|
434
|
+
template = <<-END
|
435
|
+
<div mv:generate='{template_dir_path}/{template_basename}{extension}'>hello world</div>]
|
436
|
+
END
|
437
|
+
expected = {
|
438
|
+
'one/two_three.four' => "<div>hello world</div>"
|
439
|
+
}
|
440
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
441
|
+
end
|
442
|
+
|
443
|
+
def test_keyword_expansion_controller_action
|
444
|
+
template = <<-END
|
445
|
+
<div mv:generate='{template_dir_path}/{template_basename}'>
|
446
|
+
hello world
|
447
|
+
</div>
|
448
|
+
END
|
449
|
+
expected = {
|
450
|
+
'one/two_three' => "<div>hello world </div>"
|
451
|
+
}
|
452
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
453
|
+
end
|
454
|
+
|
455
|
+
def test_keyword_expansion_gen_partial
|
456
|
+
template = <<-END
|
457
|
+
<div mv:generate='foo/bar'>
|
458
|
+
<span mv:replace="h product[:price]">foo bar</span>
|
459
|
+
<div mv:gen_partial=":partial => '{template_dir_path}/{template_basename}'">
|
460
|
+
<span mv:content="h product[:name]">hello world</span>
|
461
|
+
</div>
|
462
|
+
</div>
|
463
|
+
END
|
464
|
+
expected = {
|
465
|
+
'foo/bar' => "<div><%= h product[:price] %><%= render( :partial => 'one/two_three' ) %></div>",
|
466
|
+
'one/_two_three.rhtml' => "<div><span><%= h product[:name] %></span></div>"
|
467
|
+
}
|
468
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
469
|
+
end
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
|
374
475
|
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# File: config-mv-logger_config.rb
|
2
|
+
#
|
3
|
+
# Xtra testing stuff - requires manual installation and usage to exercise
|
4
|
+
#
|
5
|
+
# MasterView initialization logger configuration tests.
|
6
|
+
# Preferable to integrate into automated test case,
|
7
|
+
# but in the meantime here's some config settings code
|
8
|
+
# that can be used by hand to test/check MV logger initialization
|
9
|
+
# from the Configuration settings and the services for working
|
10
|
+
# with the logging level, since the levels and their names vary
|
11
|
+
# depending on the configured logger.
|
12
|
+
#
|
13
|
+
# This was used as a rails app config/masterview/environments/development.rb.
|
14
|
+
# Use it that way or call as your own 'logtest' environment or slam into
|
15
|
+
# your existing settings.rb or env. config settings. Whatever ya like.
|
16
|
+
#
|
17
|
+
# [DJL 14-Jun-2006]
|
18
|
+
#
|
19
|
+
#--
|
20
|
+
#------------------------------------------------------------------------------
|
21
|
+
#++
|
22
|
+
# Development environment config settings for the MasterView plugin.
|
23
|
+
#
|
24
|
+
# The MasterView configuration specification is referenced through +config+.
|
25
|
+
#
|
26
|
+
# Settings specified here will take precedence over those specified in the
|
27
|
+
# general MasterView config in +config/masterview/settings.rb+.
|
28
|
+
#
|
29
|
+
|
30
|
+
STDOUT.puts "****Loading config/masterview/environments/development.rb"
|
31
|
+
STDOUT.puts "....config=#{config}" if defined?(config)
|
32
|
+
|
33
|
+
# Activate/deactive the following to verify Log4r vs. ruby Logger, initial log_level config
|
34
|
+
#config.logger = 'logger'
|
35
|
+
#config.logger = 'nosuchlogger' # test backstop is a standard ruby Logger
|
36
|
+
#config.log_level = 'WARN'
|
37
|
+
#config.log_level = 'UNDEFINED' # test backstop falls back to logger's default
|
38
|
+
|
39
|
+
# Enable/disable to verify the results of the std logging levels
|
40
|
+
TEST_LOG_LEVELS = true
|
41
|
+
|
42
|
+
STDOUT.puts "...config.logger=#{config.logger}"
|
43
|
+
STDOUT.puts "...config.log_level=#{config.log_level || 'nil'}"
|
44
|
+
config.after_initialize {
|
45
|
+
# actual log levels [NOTE: early test code, superseded by MasterView::LogLevels and services]
|
46
|
+
if defined?(Log4r)
|
47
|
+
log_type = 'log4r'
|
48
|
+
log_level_names = Log4r::LNAMES
|
49
|
+
log_levels = {}
|
50
|
+
log_level_names.each { |ln| log_levels[ln] = log_level_names.index(ln) }
|
51
|
+
else
|
52
|
+
log_type = 'logger'
|
53
|
+
log_level_names = Logger::SEV_LABEL
|
54
|
+
log_levels = {}
|
55
|
+
log_level_names.each { |ln| log_levels[ln] = (ln == 'ANY' ? 'nil' : Logger.const_get(ln)) }
|
56
|
+
end
|
57
|
+
# x-check level name mapping [NOTE: this exercise the std facilities added to MasterView for working with log levels]
|
58
|
+
ll_map = LogLevels.invert
|
59
|
+
ll_indices = ll_map.keys.reject{ | lindex | lindex.nil? } #sigh - Logger::ANY
|
60
|
+
ll_map_entries = ll_indices.sort.collect { | lindex | "#{ll_map[lindex]} (#{lindex})" }
|
61
|
+
LogLevels.each_pair { | lname, lindex | ( ll_map_entries << "#{lname} (nil)") if lindex.nil? }
|
62
|
+
# right then, so let's report what's happened in MasterView logging land
|
63
|
+
STDOUT.puts "\nMasterView #after_initialize - plugin loading and init now complete!!"
|
64
|
+
STDOUT.puts "...MasterView::ConfigSettings=#{MasterView::ConfigSettings}"
|
65
|
+
STDOUT.puts "...MasterView::Log=#{MasterView::Log}"
|
66
|
+
STDOUT.puts "...MasterView::LogLevels=#{ll_map_entries.join(', ')}"
|
67
|
+
#STDOUT.puts "...MasterView::Log.level=#{Log4r::LNAMES[MasterView::Log.level]}"
|
68
|
+
STDOUT.puts "...configured logger of type '#{log_type}' at level #{log_levels.index(MasterView::Log.level)} (#{MasterView::Log.level})"
|
69
|
+
STDOUT.puts "...supported levels for logger type '#{log_type}':\n " + (log_level_names.collect {|ln| "#{ln} (#{log_levels[ln]})"}).join(', ')
|
70
|
+
if TEST_LOG_LEVELS
|
71
|
+
STDOUT.puts "...TEST: verify changing the log level"
|
72
|
+
initial_log_level = MasterView.log_level
|
73
|
+
STDOUT.puts "...MasterView.log_level=#{initial_log_level} (#{MasterView.log_level(:index)}) <-** initial **"
|
74
|
+
MasterView::Log.debug 'TEST: log a debug message'
|
75
|
+
MasterView::Log.warn 'TEST: log a warning message'
|
76
|
+
MasterView::Log.error 'TEST: log an error message'
|
77
|
+
['DEBUG', 'WARN', 'ERROR'].each { | lname |
|
78
|
+
MasterView.set_log_level(lname)
|
79
|
+
STDOUT.puts "...MasterView.log_level=#{MasterView.log_level} (#{MasterView.log_level(:index)})"
|
80
|
+
MasterView::Log.debug 'TEST: log a debug message'
|
81
|
+
MasterView::Log.warn 'TEST: log a warning message'
|
82
|
+
MasterView::Log.error 'TEST: log an error message'
|
83
|
+
}
|
84
|
+
MasterView.set_log_level(initial_log_level)
|
85
|
+
STDOUT.puts "...MasterView.log_level=#{MasterView.log_level} <- ** reset to initial **"
|
86
|
+
STDOUT.puts '...done checking logging level changes'
|
87
|
+
end
|
88
|
+
if TEST_LOG_LEVELS
|
89
|
+
STDOUT.puts "\nMasterView #after_initialize: test log_level setter vs. assignment"
|
90
|
+
[ 'ERROR', :WARN, 2 ].each { |level|
|
91
|
+
STDOUT.puts "...CHECK: set log level using #{level.class} value #{level.inspect}"
|
92
|
+
MasterView.log_level = level
|
93
|
+
STDOUT.puts "...assignment 'MasterView.log_level = #{level.inspect}' => current state is MasterView.log_level=#{MasterView.log_level} (#{MasterView.log_level(:index)})"
|
94
|
+
MasterView::Log.warn 'TEST: log a warning message'
|
95
|
+
MasterView::Log.error 'TEST: log an error message'
|
96
|
+
MasterView.set_log_level(level)
|
97
|
+
STDOUT.puts "...setter 'MasterView.set_log_level( #{level.inspect} )' => current state is MasterView.log_level=#{MasterView.log_level} (#{MasterView.log_level(:index)})"
|
98
|
+
MasterView::Log.warn 'TEST: log a warning message'
|
99
|
+
MasterView::Log.error 'TEST: log an error message'
|
100
|
+
MasterView.set_log_level(initial_log_level)
|
101
|
+
}
|
102
|
+
MasterView.set_log_level(initial_log_level)
|
103
|
+
STDOUT.puts "...MasterView.log_level=#{MasterView.log_level} <- ** reset to initial **"
|
104
|
+
STDOUT.puts '...done checking logging level setter/assignment protocol'
|
105
|
+
end
|
106
|
+
}
|
107
|
+
|
108
|
+
STDOUT.puts "...masterview #{config.environment} settings loaded"
|
109
|
+
STDOUT.puts "...MasterView::ConfigSettings=%s" % (MasterView.const_defined?(:ConfigSettings) ? MasterView::ConfigSettings : '(not yet installed)')
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
# We want to load MasterView in a standalone configuration mode
|
6
|
+
# so that the template engine is anchored on our test directories
|
7
|
+
currentPath = File.dirname(__FILE__)
|
8
|
+
#require File.join( currentPath, '../../lib/masterview' )
|
9
|
+
require File.join( currentPath, '../../lib/masterview/initializer.rb' )
|
10
|
+
mv_test_dir = File.expand_path( "#{currentPath}/../." )
|
11
|
+
mv_code_base_dir = File.expand_path( "#{currentPath}/../../lib" )
|
12
|
+
#ISSUE: Initializer#load_plugin needs to be made smarter to handle following automatically [DJL 17-Jun-2006]
|
13
|
+
$LOAD_PATH << mv_code_base_dir # needed so "require 'masterview'" resolves
|
14
|
+
mv_config = MasterView::Configuration.new( :app_root_path => mv_test_dir ) #"#{mv_test_dir}/tmp"
|
15
|
+
mv_config.template_src_dir_path = 'tmp/templates_src'
|
16
|
+
mv_config.template_dst_dir_path = 'tmp/views'
|
17
|
+
# our test case will replicate the standard Rails dev configuration
|
18
|
+
#mv_config.parse_masterview_templates_at_startup = true
|
19
|
+
#mv_config.reparse_changed_masterview_templates = true
|
20
|
+
MasterView::Initializer.run(:process, mv_config)
|
21
|
+
|
22
|
+
class TestStandaloneAppConfiguration < Test::Unit::TestCase
|
23
|
+
|
24
|
+
MVTestDir = File.expand_path( File.join(File.dirname(__FILE__), '..' ) )
|
25
|
+
TemplateSrcDir = "#{MVTestDir}/tmp/templates_src"
|
26
|
+
TemplateFilenamePattern = '*.html'
|
27
|
+
TemplateDstDir = "#{MVTestDir}/tmp/views"
|
28
|
+
|
29
|
+
DEBUG_TRACE = false
|
30
|
+
if DEBUG_TRACE
|
31
|
+
STDOUT.puts "\nTEST INITIALIZING MasterView FOR STANDALONE OPERATION OUTSIDE RAILS"
|
32
|
+
STDOUT.puts "\nTest case root directories:"
|
33
|
+
STDOUT.puts "...MvTestDir=#{MVTestDir}"
|
34
|
+
STDOUT.puts "...TemplateSrcDir=#{TemplateSrcDir}"
|
35
|
+
STDOUT.puts "...TemplateDstDir=#{TemplateDstDir}"
|
36
|
+
end
|
37
|
+
if DEBUG_TRACE and true
|
38
|
+
STDOUT.puts "\nMasterView root directories configuration:"
|
39
|
+
STDOUT.puts "...MasterView::ConfigSettings.root_path=#{MasterView::ConfigSettings.root_path}"
|
40
|
+
#assert_equal TemplateSrcDir, MasterView::COnfigSettings.template_src_dir_path
|
41
|
+
STDOUT.puts "...MasterView::ConfigSettings.template_src_dir_path=#{MasterView::ConfigSettings.template_src_dir_path}"
|
42
|
+
#assert_equal TemplateDstDir, MasterView::COnfigSettings.template_dst_dir_path
|
43
|
+
STDOUT.puts "...MasterView::ConfigSettings.template_dst_dir_path=#{MasterView::ConfigSettings.template_dst_dir_path}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_test_app_roots
|
47
|
+
config = MasterView::ConfigSettings
|
48
|
+
assert_equal MVTestDir, config.root_path
|
49
|
+
assert_equal TemplateSrcDir, config.template_src_dir_path
|
50
|
+
assert_equal TemplateDstDir, config.template_dst_dir_path
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: masterview
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2006-06-21 00:00:00 -05:00
|
8
8
|
summary: A (x)html friendly template engine for rails with the power of layouts, and partials.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -42,15 +42,21 @@ files:
|
|
42
42
|
- lib/facets/core/string/blank.rb
|
43
43
|
- lib/masterview/directives
|
44
44
|
- lib/masterview/extras
|
45
|
+
- lib/masterview/io.rb
|
45
46
|
- lib/masterview/plugin_load_tracking.rb
|
46
|
-
- lib/masterview/
|
47
|
-
- lib/masterview/analyzer.rb
|
48
|
-
- lib/masterview/runtime_helpers.rb
|
47
|
+
- lib/masterview/initializer.rb
|
49
48
|
- lib/masterview/string_extensions.rb
|
49
|
+
- lib/masterview/analyzer.rb
|
50
50
|
- lib/masterview/template_spec.rb
|
51
|
-
- lib/masterview/directive_base.rb
|
52
51
|
- lib/masterview/masterview_version.rb
|
53
52
|
- lib/masterview/parser.rb
|
53
|
+
- lib/masterview/mtime_tracking_hash.rb
|
54
|
+
- lib/masterview/directive_helpers.rb
|
55
|
+
- lib/masterview/runtime_helpers.rb
|
56
|
+
- lib/masterview/pathname_extensions.rb
|
57
|
+
- lib/masterview/filter_helpers.rb
|
58
|
+
- lib/masterview/directive_base.rb
|
59
|
+
- lib/masterview/keyword_expander.rb
|
54
60
|
- lib/masterview/directives/global_inline_erb.rb
|
55
61
|
- lib/masterview/directives/link_to_if.rb
|
56
62
|
- lib/masterview/directives/preview.rb
|
@@ -77,52 +83,119 @@ files:
|
|
77
83
|
- lib/masterview/directives/content.rb
|
78
84
|
- lib/masterview/directives/text_area.rb
|
79
85
|
- lib/masterview/extras/app
|
80
|
-
- lib/masterview/extras/
|
86
|
+
- lib/masterview/extras/init_logger.rb
|
81
87
|
- lib/masterview/extras/watcher.rb
|
88
|
+
- lib/masterview/extras/init_rails_reparse_checking.rb
|
89
|
+
- lib/masterview/extras/init_rails_erb_mv_direct.rb
|
82
90
|
- lib/masterview/extras/app/controllers
|
83
91
|
- lib/masterview/extras/app/views
|
84
92
|
- lib/masterview/extras/app/controllers/masterview_controller.rb
|
85
93
|
- lib/masterview/extras/app/views/masterview
|
86
94
|
- lib/masterview/extras/app/views/masterview/admin
|
95
|
+
- lib/masterview/extras/app/views/masterview/admin/view_rhtml.rhtml
|
87
96
|
- lib/masterview/extras/app/views/masterview/admin/list.rhtml
|
88
97
|
- lib/masterview/extras/app/views/masterview/admin/empty.rhtml
|
89
98
|
- lib/masterview/extras/app/views/masterview/admin/create.rhtml
|
90
|
-
-
|
99
|
+
- Rakefile
|
100
|
+
- init.rb
|
101
|
+
- doc/stylesheets
|
102
|
+
- doc/directives.html
|
103
|
+
- doc/guide.html
|
104
|
+
- doc/api
|
105
|
+
- doc/installation.html
|
106
|
+
- doc/configuration.html
|
107
|
+
- doc/index.html
|
108
|
+
- doc/troubleshooting.html
|
109
|
+
- doc/stylesheets/mv-directives.css
|
110
|
+
- doc/stylesheets/mv-installation.css
|
111
|
+
- doc/stylesheets/mv-config.css
|
112
|
+
- doc/stylesheets/masterview.css
|
113
|
+
- examples/rails_app_config
|
114
|
+
- examples/product.html.old
|
115
|
+
- examples/product.html
|
116
|
+
- examples/test.import
|
117
|
+
- examples/rails_app_config/masterview
|
118
|
+
- examples/rails_app_config/masterview/environment
|
119
|
+
- examples/rails_app_config/masterview/settings.rb
|
120
|
+
- examples/rails_app_config/masterview/environment/development.rb
|
121
|
+
- examples/rails_app_config/masterview/environment/production.rb
|
122
|
+
- test/unit
|
123
|
+
- test/xtras
|
124
|
+
- test/fixtures
|
125
|
+
- test/tmp
|
91
126
|
- test/test_helper.rb
|
92
|
-
- test/
|
93
|
-
- test/
|
94
|
-
- test/
|
95
|
-
- test/
|
96
|
-
- test/
|
97
|
-
- test/
|
98
|
-
- test/
|
99
|
-
- test/
|
100
|
-
- test/parser_test.rb
|
101
|
-
- test/
|
102
|
-
- test/
|
103
|
-
- test/
|
104
|
-
- test/
|
105
|
-
- test/
|
106
|
-
- test/
|
107
|
-
- test/
|
108
|
-
- test/
|
109
|
-
- test/
|
110
|
-
- test/
|
111
|
-
- test/
|
112
|
-
- test/
|
113
|
-
- test/
|
114
|
-
- test/
|
115
|
-
- test/
|
116
|
-
- test/
|
117
|
-
- test/
|
118
|
-
- test/
|
127
|
+
- test/unit/config_settings_test.rb
|
128
|
+
- test/unit/run_parser_test.rb
|
129
|
+
- test/unit/mio_test.rb
|
130
|
+
- test/unit/directive_global_inline_erb_test.rb
|
131
|
+
- test/unit/directive_text_field_test.rb
|
132
|
+
- test/unit/directive_else_test.rb
|
133
|
+
- test/unit/mtime_string_hash_mio_tree_test.rb
|
134
|
+
- test/unit/directive_block_test.rb
|
135
|
+
- test/unit/parser_test.rb
|
136
|
+
- test/unit/directive_hidden_field_test.rb
|
137
|
+
- test/unit/directive_if_test.rb
|
138
|
+
- test/unit/directive_link_to_test.rb
|
139
|
+
- test/unit/directive_elsif_test.rb
|
140
|
+
- test/unit/directive_form_test.rb
|
141
|
+
- test/unit/filter_helpers_test.rb
|
142
|
+
- test/unit/directive_javascript_include_test.rb
|
143
|
+
- test/unit/directive_import_test.rb
|
144
|
+
- test/unit/directive_link_to_if_test.rb
|
145
|
+
- test/unit/template_test.rb
|
146
|
+
- test/unit/file_mio_test.rb
|
147
|
+
- test/unit/template_spec_test.rb
|
148
|
+
- test/unit/template_file_watcher_test.rb
|
149
|
+
- test/unit/example_test.rb
|
150
|
+
- test/unit/mtime_tracking_hash_test.rb
|
151
|
+
- test/unit/directive_submit_test.rb
|
152
|
+
- test/unit/directive_omit_tag_test.rb
|
153
|
+
- test/unit/directive_password_field_test.rb
|
154
|
+
- test/unit/directive_stylesheet_link_test.rb
|
155
|
+
- test/unit/directive_import_render_test.rb
|
156
|
+
- test/unit/directive_attr_test.rb
|
157
|
+
- test/unit/directive_content_test.rb
|
158
|
+
- test/unit/directive_replace_test.rb
|
159
|
+
- test/unit/keyword_expander_test.rb
|
160
|
+
- test/unit/directive_text_area_test.rb
|
161
|
+
- test/unit/pathname_extensions_test.rb
|
162
|
+
- test/unit/string_hash_mio_test.rb
|
163
|
+
- test/xtras/config_initialize_standalone.rb
|
164
|
+
- test/xtras/config-mv-logger_config.rb
|
165
|
+
- test/fixtures/configs
|
166
|
+
- test/fixtures/templates
|
167
|
+
- test/fixtures/configs/fake_rails_app
|
168
|
+
- test/fixtures/configs/fake_rails_app_with_config
|
169
|
+
- test/fixtures/configs/fake_rails_app_with_config/config
|
170
|
+
- test/fixtures/configs/fake_rails_app_with_config/config/masterview
|
171
|
+
- test/fixtures/configs/fake_rails_app_with_config/config/masterview/environments
|
172
|
+
- test/fixtures/configs/fake_rails_app_with_config/config/masterview/settings.rb
|
173
|
+
- test/fixtures/configs/fake_rails_app_with_config/config/masterview/environments/development.rb
|
174
|
+
- test/fixtures/configs/fake_rails_app_with_config/config/masterview/environments/production.rb
|
175
|
+
- test/fixtures/templates/product.html
|
176
|
+
- test/fixtures/templates/test.import
|
177
|
+
- test/tmp/template
|
178
|
+
- test/tmp/erb
|
179
|
+
- test/tmp/templates_src
|
180
|
+
- test/tmp/views
|
181
|
+
- test/tmp/template/foo.txt
|
182
|
+
- test/tmp/templates_src/product.html
|
183
|
+
- test/tmp/views/product
|
184
|
+
- test/tmp/views/layouts
|
185
|
+
- test/tmp/views/product/_form.rhtml
|
186
|
+
- test/tmp/views/product/new.rhtml
|
187
|
+
- test/tmp/views/product/edit.rhtml
|
188
|
+
- test/tmp/views/product/_product.rhtml
|
189
|
+
- test/tmp/views/product/list.rhtml
|
190
|
+
- test/tmp/views/product/_show.rhtml
|
191
|
+
- test/tmp/views/product/show.rhtml
|
192
|
+
- test/tmp/views/product/destroy.rhtml
|
193
|
+
- test/tmp/views/layouts/product.rhtml
|
119
194
|
- CHANGELOG
|
120
|
-
- MIT-LICENSE
|
121
|
-
- Rakefile
|
122
195
|
- TODO
|
123
196
|
- RELEASE_NOTES
|
124
197
|
- README
|
125
|
-
-
|
198
|
+
- MIT-LICENSE
|
126
199
|
test_files: []
|
127
200
|
|
128
201
|
rdoc_options: []
|
@@ -1,72 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
#--
|
4
|
-
# Copyright (c) 2006 Jeff Barczewski
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
-
# a copy of this software and associated documentation files (the
|
8
|
-
# "Software"), to deal in the Software without restriction, including
|
9
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
10
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
12
|
-
# the following conditions:
|
13
|
-
#
|
14
|
-
# The above copyright notice and this permission notice shall be
|
15
|
-
# included in all copies or substantial portions of the Software.
|
16
|
-
#
|
17
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
-
#++
|
25
|
-
#
|
26
|
-
# = MasterView - Rails-optimized (x)html friendly template engine
|
27
|
-
#
|
28
|
-
# MasterView is a ruby/rails optimized HTML/XHTML friendly template engine.
|
29
|
-
# It is designed to use the full power and productivity of rails including
|
30
|
-
# layouts, partials, and rails html helpers while still being editable/styleable
|
31
|
-
# in a WYSIWYG HTML editor.
|
32
|
-
|
33
|
-
# setup hook so that masterview output files are always current
|
34
|
-
# always checks mtimes before each call when perform_caching is off (development)
|
35
|
-
# otherwise only checks the first time system is hit
|
36
|
-
require 'masterview'
|
37
|
-
require 'masterview/extras/watcher'
|
38
|
-
|
39
|
-
if MasterView::EnableMasterViewAdminPages
|
40
|
-
# add our app directories to the load path
|
41
|
-
Dir[File.join(File.dirname(__FILE__), 'app/**/*')].select{ |d| File.directory?(d) }.each{|d| $LOAD_PATH.push d }
|
42
|
-
end
|
43
|
-
|
44
|
-
# only run if auto parsing and when launching server, check if need to update mv files
|
45
|
-
if MasterView::AutoParseMasterViewFiles && $PROGRAM_NAME =~ /server|dispatch/
|
46
|
-
mvtemplate_src_root = File.join( ActionController::Base.template_root, MasterView::TemplateSrcRelativePath)
|
47
|
-
mvtemplate_dst_root = File.join( ActionController::Base.template_root, MasterView::TemplateDestRelativePath)
|
48
|
-
MasterView::TemplateFileWatcher.check(mvtemplate_src_root, MasterView::TemplateFilenamePattern, true) do |f|
|
49
|
-
MasterView::Parser.parse_file( f, mvtemplate_dst_root)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
if MasterView::AutoParseMasterViewFiles
|
55
|
-
# if not caching then check for masterview updates on every request
|
56
|
-
unless ActionController::Base.perform_caching
|
57
|
-
module ::ActionController
|
58
|
-
class Base
|
59
|
-
alias :process_orig :process
|
60
|
-
def process(request, response, method = :perform_action, *arguments)
|
61
|
-
mvtemplate_src_root = File.join(self.class.view_root, MasterView::TemplateSrcRelativePath)
|
62
|
-
mvtemplate_dst_root = File.join(self.class.view_root, MasterView::TemplateDestRelativePath)
|
63
|
-
MasterView::TemplateFileWatcher.check(mvtemplate_src_root, MasterView::TemplateFilenamePattern, true) do |f|
|
64
|
-
MasterView::Parser.parse_file( f, mvtemplate_dst_root )
|
65
|
-
end
|
66
|
-
process_orig(request, response, method, *arguments)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
data/test/import_render_test.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
currentPath = File.dirname(__FILE__)
|
5
|
-
require File.join( currentPath, '../lib/masterview' )
|
6
|
-
require File.join( currentPath, '../lib/masterview/directives/import_render')
|
7
|
-
|
8
|
-
class TestImportRender < Test::Unit::TestCase
|
9
|
-
include MasterView::Directives
|
10
|
-
include MasterView::DirectiveHelpers
|
11
|
-
|
12
|
-
def setup
|
13
|
-
@directives = MasterView::DirectiveSet.new
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_import_render
|
17
|
-
import_render_tag = MasterView::Tag.new(@directives, 'bar', {}, :normal, nil)
|
18
|
-
@directives.directives = []
|
19
|
-
attr_value = ':partial => foo/bar'
|
20
|
-
@directives << Import_render.new(attr_value)
|
21
|
-
dcs = @directives.determine_dcs(:stag)
|
22
|
-
dcs.context = import_render_tag.create_context
|
23
|
-
assert_equal nil, dcs.render
|
24
|
-
|
25
|
-
dcs = @directives.determine_dcs(:etag)
|
26
|
-
dcs.context = import_render_tag.create_context
|
27
|
-
assert_equal ERB_EVAL+'render( '+attr_value+' )'+ERB_END, dcs.render.join
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|