masterview 0.3.2 → 0.3.3
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 +15 -0
- data/RELEASE_NOTES +26 -2
- data/Rakefile +35 -10
- data/ReleaseAnnouncement +124 -0
- data/TODO +6 -0
- data/doc/configuration.html +39 -0
- data/doc/guide.html +14 -13
- data/doc/index.html +1 -1
- data/doc/installation.html +1 -1
- data/doc/media_list.html +19 -3
- data/examples/rails_app_config/masterview/settings.rb +5 -0
- data/lib/masterview/analyzer.rb +13 -1
- data/lib/masterview/directives/form.rb +4 -1
- data/lib/masterview/directives/stylesheet_link.rb +1 -1
- data/lib/masterview/extras/auto_copy.rb +80 -0
- data/lib/masterview/initializer.rb +87 -4
- data/lib/masterview/io.rb +11 -0
- data/lib/masterview/masterview_version.rb +1 -1
- data/lib/masterview/mtime_tracking_hash.rb +12 -3
- data/lib/masterview/parser.rb +2 -2
- data/lib/masterview/rails_ext/action_controller_reparse_checking.rb +10 -9
- data/lib/masterview/rails_ext/action_view_erb_direct.rb +53 -34
- data/lib/masterview/rails_ext/short_path_calc.rb +127 -0
- data/lib/masterview/template_spec.rb +27 -9
- data/lib/masterview.rb +1 -1
- data/test/tmp/dst/public/images/FOO.GIF +1 -0
- data/test/tmp/dst/public/images/bar/baz.png +1 -0
- data/test/tmp/dst/public/images/blank.gif +1 -0
- data/test/tmp/dst/public/images/cat/dog/mouse.JPG +1 -0
- data/test/tmp/dst/public/images/star.jpg +1 -0
- data/test/tmp/dst/public/images/test.png +1 -0
- data/test/tmp/dst/public/javascript/custom/script.js +1 -0
- data/test/tmp/dst/public/javascript/nested/custom/foo.js +1 -0
- data/test/tmp/dst/public/javascript/prototype.js +1 -0
- data/test/tmp/dst/public/javascript/scriptaculous.js +1 -0
- data/test/tmp/dst/public/stylesheets/client/standard/great1.css +1 -0
- data/test/tmp/dst/public/stylesheets/custom/blue.css +1 -0
- data/test/tmp/dst/public/stylesheets/style.css +1 -0
- data/test/tmp/src/css/client/standard/great1.css +1 -0
- data/test/tmp/src/css/custom/blue.css +1 -0
- data/test/tmp/src/css/style.css +1 -0
- data/test/tmp/src/images/FOO.GIF +1 -0
- data/test/tmp/src/images/bar/baz.png +1 -0
- data/test/tmp/src/images/blank.gif +1 -0
- data/test/tmp/src/images/cat/dog/mouse.JPG +1 -0
- data/test/tmp/src/images/star.jpg +1 -0
- data/test/tmp/src/images/test.png +1 -0
- data/test/tmp/src/mixed/FOO.GIF +1 -0
- data/test/tmp/src/mixed/bar/baz.png +1 -0
- data/test/tmp/src/mixed/blank.gif +1 -0
- data/test/tmp/src/mixed/cat/dog/mouse.JPG +1 -0
- data/test/tmp/src/mixed/client/standard/great1.css +1 -0
- data/test/tmp/src/mixed/custom/blue.css +1 -0
- data/test/tmp/src/mixed/custom/script.js +1 -0
- data/test/tmp/src/mixed/nested/custom/foo.js +1 -0
- data/test/tmp/src/mixed/prototype.js +1 -0
- data/test/tmp/src/mixed/scriptaculous.js +1 -0
- data/test/tmp/src/mixed/star.jpg +1 -0
- data/test/tmp/src/mixed/style.css +1 -0
- data/test/tmp/src/mixed/test.png +1 -0
- data/test/tmp/src/scripts/custom/script.js +1 -0
- data/test/tmp/src/scripts/nested/custom/foo.js +1 -0
- data/test/tmp/src/scripts/prototype.js +1 -0
- data/test/tmp/src/scripts/scriptaculous.js +1 -0
- data/test/unit/auto_copy_test.rb +181 -0
- data/test/unit/directive_form_test.rb +63 -0
- data/test/unit/directive_stylesheet_link_test.rb +3 -3
- data/test/unit/file_mio_test.rb +24 -8
- data/test/unit/mtime_string_hash_mio_tree_test.rb +19 -6
- data/test/unit/short_path_calc_test.rb +135 -0
- data/test/unit/string_hash_mio_test.rb +18 -5
- data/test/unit/template_test.rb +37 -0
- metadata +85 -2
@@ -12,7 +12,7 @@ module MasterView
|
|
12
12
|
Conflicts = 'Conflict(s)'
|
13
13
|
InvalidXHTML = 'Invalid XHTML'
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def initialize(path = nil)
|
17
17
|
@path = path
|
18
18
|
@status = ''
|
@@ -20,7 +20,7 @@ module MasterView
|
|
20
20
|
@gen_parts = []
|
21
21
|
@build_list = []
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
# get short base name of path
|
25
25
|
def basename
|
26
26
|
File.basename @path
|
@@ -69,7 +69,7 @@ module MasterView
|
|
69
69
|
def self.scan_template(template, path, content_hash = {})
|
70
70
|
template_spec = TemplateSpec.new(path)
|
71
71
|
listener = MasterView::Analyzer::Listener.new( :template_pathname => Pathname.for_path(path) )
|
72
|
-
begin
|
72
|
+
begin
|
73
73
|
MasterView::Parser.parse( template, :rescue_exceptions => false, :listeners => [listener])
|
74
74
|
template_spec.build_list = listener.list
|
75
75
|
conflicts = content_hash.keys & listener.content.keys
|
@@ -105,7 +105,7 @@ module MasterView
|
|
105
105
|
invalid
|
106
106
|
end
|
107
107
|
|
108
|
-
# rebuild template updating all imports, returns the string contents,
|
108
|
+
# rebuild template updating all imports, returns the string contents,
|
109
109
|
# if options[:write_to_file] = true then it will write the contents to file if different and return true, if identical then returns false
|
110
110
|
# otherwise this method returns the content of the template
|
111
111
|
# raise error for any other problems. options[:backup] = true to make backup before rebuilding, uses MasterView::IOMgr.backup to determine
|
@@ -148,6 +148,24 @@ module MasterView
|
|
148
148
|
IOMgr.backup.path(backup_path).write(contents_to_backup)
|
149
149
|
end
|
150
150
|
|
151
|
+
# remove file
|
152
|
+
def remove_rhtml(options={})
|
153
|
+
removed = []
|
154
|
+
self.gen_parts.each do |gen_rhtml|
|
155
|
+
mio = IOMgr.erb.path(gen_rhtml)
|
156
|
+
if mio.exist?
|
157
|
+
mio.remove
|
158
|
+
removed << gen_rhtml
|
159
|
+
end
|
160
|
+
end
|
161
|
+
removed
|
162
|
+
end
|
163
|
+
|
164
|
+
# file exist?
|
165
|
+
def file_exist?
|
166
|
+
IOMgr.template.path(self.path).exist?
|
167
|
+
end
|
168
|
+
|
151
169
|
# create empty shell file consisting of layout and a comment for where to insert new content, return contents
|
152
170
|
def self.create_empty_shell(template_spec_to_copy, content_hash, content_to_insert, options = {} )
|
153
171
|
from_spec = template_spec_to_copy
|
@@ -168,9 +186,9 @@ module MasterView
|
|
168
186
|
class CreateShellERBValues
|
169
187
|
attr_reader :controller_name, :action_name, :controller_file_name, :controller_view_dir_name
|
170
188
|
def initialize(controller_name, action_name)
|
171
|
-
@controller_name = Inflector.underscore(Inflector.singularize(controller_name))
|
172
|
-
@action_name = Inflector.underscore(Inflector.singularize(action_name))
|
173
|
-
@controller_file_name = @controller_name
|
189
|
+
@controller_name = Inflector.underscore(Inflector.singularize(controller_name))
|
190
|
+
@action_name = Inflector.underscore(Inflector.singularize(action_name))
|
191
|
+
@controller_file_name = @controller_name
|
174
192
|
@controller_view_dir_name = @controller_file_name
|
175
193
|
end
|
176
194
|
|
@@ -181,9 +199,9 @@ module MasterView
|
|
181
199
|
|
182
200
|
|
183
201
|
# create empty shell file consisting of layout and a comment for where to insert new content. Use action_to_create
|
184
|
-
# to infer the destination name controller_action.html and to customize the inserted place holder. Pass the
|
202
|
+
# to infer the destination name controller_action.html and to customize the inserted place holder. Pass the
|
185
203
|
# empty insert erb (rhtml) content in which will be rendered with appropriate controller and action values.
|
186
|
-
# Valid options:
|
204
|
+
# Valid options:
|
187
205
|
# :write_to_file => true (write to file and return filename, if false then simply return generated contents)
|
188
206
|
# :template_source => source_for_template (use this source instead of reading from file)
|
189
207
|
# :content_hash => use this content_hash, otherwise it will scan the masterview template directory to create content_hash
|
data/lib/masterview.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
updated
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1 @@
|
|
1
|
+
testfile
|
@@ -0,0 +1,181 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
currentPath = File.dirname(__FILE__)
|
5
|
+
require File.join( currentPath, '../../lib/masterview' )
|
6
|
+
|
7
|
+
class TestAutoCopy < Test::Unit::TestCase
|
8
|
+
|
9
|
+
MVTestDir = File.expand_path( File.join(File.dirname(__FILE__), '..' ) )
|
10
|
+
|
11
|
+
ImageSrcDir = "#{MVTestDir}/tmp/src/images"
|
12
|
+
ImageDstDir = "#{MVTestDir}/tmp/dst/public/images"
|
13
|
+
|
14
|
+
CSSSrcDir = "#{MVTestDir}/tmp/src/css"
|
15
|
+
CSSDstDir = "#{MVTestDir}/tmp/dst/public/stylesheets"
|
16
|
+
|
17
|
+
JavascriptSrcDir = "#{MVTestDir}/tmp/src/scripts"
|
18
|
+
JavascriptDstDir = "#{MVTestDir}/tmp/dst/public/javascript"
|
19
|
+
|
20
|
+
AllDirs = [ImageSrcDir, ImageDstDir, CSSSrcDir, CSSDstDir, JavascriptSrcDir, JavascriptDstDir]
|
21
|
+
|
22
|
+
ImageSrcMIO = MasterView::MIO::FileMIOTree.new(ImageSrcDir)
|
23
|
+
ImageDstMIO = MasterView::MIO::FileMIOTree.new(ImageDstDir)
|
24
|
+
|
25
|
+
CSSSrcMIO = MasterView::MIO::FileMIOTree.new(CSSSrcDir)
|
26
|
+
CSSDstMIO = MasterView::MIO::FileMIOTree.new(CSSDstDir)
|
27
|
+
|
28
|
+
JavascriptSrcMIO = MasterView::MIO::FileMIOTree.new(JavascriptSrcDir)
|
29
|
+
JavascriptDstMIO = MasterView::MIO::FileMIOTree.new(JavascriptDstDir)
|
30
|
+
|
31
|
+
ImageFiles = ['blank.gif', 'star.jpg', 'test.png', 'FOO.GIF', 'bar/baz.png', 'cat/dog/mouse.JPG']
|
32
|
+
CSSFiles = ['style.css', 'custom/blue.css', 'client/standard/great1.css']
|
33
|
+
JavascriptFiles = ['prototype.js', 'scriptaculous.js', 'custom/script.js', 'nested/custom/foo.js']
|
34
|
+
|
35
|
+
ModImageFiles = [ImageFiles[0], ImageFiles[4]]
|
36
|
+
ModCSSFiles = [CSSFiles[0], CSSFiles[2]]
|
37
|
+
ModJavascriptFiles = [JavascriptFiles[2]]
|
38
|
+
|
39
|
+
MixedSrcDir = "#{MVTestDir}/tmp/src/mixed"
|
40
|
+
|
41
|
+
|
42
|
+
def setup
|
43
|
+
AllDirs.each do |dir| # clear out old tree, and insure that it exists
|
44
|
+
pathname = Pathname.new(dir)
|
45
|
+
pathname.rmtree if pathname.exist?
|
46
|
+
pathname.mkpath
|
47
|
+
end
|
48
|
+
|
49
|
+
ImageFiles.each { |f| ImageSrcMIO.path(f).write('testfile') } # create each test file
|
50
|
+
CSSFiles.each { |f| CSSSrcMIO.path(f).write('testfile') } # create each test file
|
51
|
+
JavascriptFiles.each { |f| JavascriptSrcMIO.path(f).write('testfile') } # create each test file
|
52
|
+
|
53
|
+
@image_auto_copy = MasterView::AutoCopy.new(ImageSrcMIO, ImageDstMIO)
|
54
|
+
@css_auto_copy = MasterView::AutoCopy.new(CSSSrcMIO, CSSDstMIO)
|
55
|
+
@javascript_auto_copy = MasterView::AutoCopy.new(JavascriptSrcMIO, JavascriptDstMIO)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
#------------------------------------------------------------------------------
|
60
|
+
# Test Cases
|
61
|
+
#------------------------------------------------------------------------------
|
62
|
+
|
63
|
+
def test_instance_auto_copy_wildcarded
|
64
|
+
sleep(1) # make sure time (seconds) change before updating so timestamp will be different
|
65
|
+
copied_files = @image_auto_copy.copy_updated_files
|
66
|
+
assert_equal(ImageFiles.sort, copied_files.sort)
|
67
|
+
ModImageFiles.each { |f| ImageSrcMIO.path(f).write('updated') }
|
68
|
+
assert_equal(ModImageFiles.sort, @image_auto_copy.copy_updated_files.sort)
|
69
|
+
|
70
|
+
copied_files = @css_auto_copy.copy_updated_files
|
71
|
+
assert_equal(CSSFiles.sort, copied_files.sort)
|
72
|
+
ModCSSFiles.each { |f| CSSSrcMIO.path(f).write('updated') }
|
73
|
+
assert_equal(ModCSSFiles.sort, @css_auto_copy.copy_updated_files.sort)
|
74
|
+
|
75
|
+
copied_files = @javascript_auto_copy.copy_updated_files
|
76
|
+
assert_equal(JavascriptFiles.sort, copied_files.sort)
|
77
|
+
ModJavascriptFiles.each { |f| JavascriptSrcMIO.path(f).write('updated') }
|
78
|
+
assert_equal(ModJavascriptFiles.sort, @javascript_auto_copy.copy_updated_files.sort)
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def test_instance_auto_copy_pattern_specified
|
83
|
+
sleep(1) # make sure time (seconds) change before updating so timestamp will be different
|
84
|
+
@image_auto_copy = MasterView::AutoCopy.new(ImageSrcMIO, ImageDstMIO, ['*.gif', '*.jpg', '*.png', '*.GIF', '*.JPG'])
|
85
|
+
@css_auto_copy = MasterView::AutoCopy.new(CSSSrcMIO, CSSDstMIO, ['*.css'])
|
86
|
+
@javascript_auto_copy = MasterView::AutoCopy.new(JavascriptSrcMIO, JavascriptDstMIO, ['*.js'])
|
87
|
+
|
88
|
+
copied_files = @image_auto_copy.copy_updated_files
|
89
|
+
assert_equal(ImageFiles.sort, copied_files.sort)
|
90
|
+
ModImageFiles.each { |f| ImageSrcMIO.path(f).write('updated') }
|
91
|
+
assert_equal(ModImageFiles.sort, @image_auto_copy.copy_updated_files.sort)
|
92
|
+
|
93
|
+
copied_files = @css_auto_copy.copy_updated_files
|
94
|
+
assert_equal(CSSFiles.sort, copied_files.sort)
|
95
|
+
ModCSSFiles.each { |f| CSSSrcMIO.path(f).write('updated') }
|
96
|
+
assert_equal(ModCSSFiles.sort, @css_auto_copy.copy_updated_files.sort)
|
97
|
+
|
98
|
+
copied_files = @javascript_auto_copy.copy_updated_files
|
99
|
+
assert_equal(JavascriptFiles.sort, copied_files.sort)
|
100
|
+
ModJavascriptFiles.each { |f| JavascriptSrcMIO.path(f).write('updated') }
|
101
|
+
assert_equal(ModJavascriptFiles.sort, @javascript_auto_copy.copy_updated_files.sort)
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
def test_instance_mixed_files_copied_to_different_directories
|
106
|
+
mixedSourceMIO = MasterView::MIO::FileMIOTree.new(MixedSrcDir)
|
107
|
+
allFiles = ImageFiles+CSSFiles+JavascriptFiles
|
108
|
+
allFiles.each { |f| mixedSourceMIO.path(f).write('testfile') } # create each test file
|
109
|
+
sleep(1) # so timestamp will differ on update
|
110
|
+
@image_auto_copy = MasterView::AutoCopy.new(mixedSourceMIO, ImageDstMIO, ['*.gif', '*.jpg', '*.png', '*.GIF', '*.JPG'])
|
111
|
+
@css_auto_copy = MasterView::AutoCopy.new(mixedSourceMIO, CSSDstMIO, ['*.css'])
|
112
|
+
@javascript_auto_copy = MasterView::AutoCopy.new(mixedSourceMIO, JavascriptDstMIO, ['*.js'])
|
113
|
+
|
114
|
+
copied_files = @image_auto_copy.copy_updated_files
|
115
|
+
assert_equal(ImageFiles.sort, copied_files.sort)
|
116
|
+
ModImageFiles.each { |f| mixedSourceMIO.path(f).write('updated') }
|
117
|
+
assert_equal(ModImageFiles.sort, @image_auto_copy.copy_updated_files.sort)
|
118
|
+
|
119
|
+
copied_files = @css_auto_copy.copy_updated_files
|
120
|
+
assert_equal(CSSFiles.sort, copied_files.sort)
|
121
|
+
ModCSSFiles.each { |f| mixedSourceMIO.path(f).write('updated') }
|
122
|
+
assert_equal(ModCSSFiles.sort, @css_auto_copy.copy_updated_files.sort)
|
123
|
+
|
124
|
+
copied_files = @javascript_auto_copy.copy_updated_files
|
125
|
+
assert_equal(JavascriptFiles.sort, copied_files.sort)
|
126
|
+
ModJavascriptFiles.each { |f| mixedSourceMIO.path(f).write('updated') }
|
127
|
+
assert_equal(ModJavascriptFiles.sort, @javascript_auto_copy.copy_updated_files.sort)
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_instance_auto_copy_pattern_lc_only
|
131
|
+
@image_auto_copy = MasterView::AutoCopy.new(ImageSrcMIO, ImageDstMIO, ['*.gif', '*.jpg', '*.png'])
|
132
|
+
copied_files = @image_auto_copy.copy_updated_files
|
133
|
+
assert_equal([ImageFiles[0], ImageFiles[1], ImageFiles[2], ImageFiles[4]].sort, copied_files.sort) # only lowercase ones copied
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_instance_auto_copy_pattern_lc_only_symbol_extensions
|
137
|
+
symbol_extensions = [:gif, :jpg, :png]
|
138
|
+
filename_patterns = symbol_extensions.collect{ |s| "*.#{s.to_s}" }
|
139
|
+
@image_auto_copy = MasterView::AutoCopy.new(ImageSrcMIO, ImageDstMIO, filename_patterns)
|
140
|
+
copied_files = @image_auto_copy.copy_updated_files
|
141
|
+
assert_equal([ImageFiles[0], ImageFiles[1], ImageFiles[2], ImageFiles[4]].sort, copied_files.sort) # only lowercase ones copied
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_registered_auto_copy
|
145
|
+
sleep(1) # make sure time (seconds) change before updating so timestamp will be different
|
146
|
+
MasterView::AutoCopy.clear_registrations
|
147
|
+
MasterView::AutoCopy.register(ImageSrcMIO, ImageDstMIO)
|
148
|
+
MasterView::AutoCopy.register(CSSSrcMIO, CSSDstMIO, ['*.css'])
|
149
|
+
MasterView::AutoCopy.register(JavascriptSrcMIO, JavascriptDstMIO)
|
150
|
+
expected_array_copied = ImageFiles+CSSFiles+JavascriptFiles
|
151
|
+
assert_equal(expected_array_copied.sort, MasterView::AutoCopy.copy_all_updated_files.sort)
|
152
|
+
|
153
|
+
ModImageFiles.each { |f| ImageSrcMIO.path(f).write('updated') }
|
154
|
+
ModCSSFiles.each { |f| CSSSrcMIO.path(f).write('updated') }
|
155
|
+
ModJavascriptFiles.each { |f| JavascriptSrcMIO.path(f).write('updated') }
|
156
|
+
expected_array_copied = ModImageFiles+ModCSSFiles+ModJavascriptFiles
|
157
|
+
assert_equal(expected_array_copied.sort, MasterView::AutoCopy.copy_all_updated_files.sort)
|
158
|
+
end
|
159
|
+
|
160
|
+
# test the clear, after clear will only copy the one set
|
161
|
+
def test_clear_registered_auto_copy
|
162
|
+
sleep(1) # make sure time (seconds) change before updating so timestamp will be different
|
163
|
+
MasterView::AutoCopy.clear_registrations
|
164
|
+
MasterView::AutoCopy.register(ImageSrcMIO, ImageDstMIO)
|
165
|
+
MasterView::AutoCopy.register(CSSSrcMIO, CSSDstMIO, ['*.css'])
|
166
|
+
MasterView::AutoCopy.register(JavascriptSrcMIO, JavascriptDstMIO)
|
167
|
+
expected_array_copied = ImageFiles+CSSFiles+JavascriptFiles
|
168
|
+
assert_equal(expected_array_copied.sort, MasterView::AutoCopy.copy_all_updated_files.sort)
|
169
|
+
|
170
|
+
|
171
|
+
sleep(1) # make sure time (seconds) change before updating so timestamp will be different
|
172
|
+
MasterView::AutoCopy.clear_registrations
|
173
|
+
MasterView::AutoCopy.register(ImageSrcMIO, ImageDstMIO)
|
174
|
+
ImageFiles.each { |f| ImageSrcMIO.path(f).write('updated') }
|
175
|
+
CSSFiles.each { |f| CSSSrcMIO.path(f).write('updated') }
|
176
|
+
JavascriptFiles.each { |f| JavascriptSrcMIO.path(f).write('updated') }
|
177
|
+
expected_array_copied = ImageFiles # only the image files this time after clear and reset
|
178
|
+
assert_equal(expected_array_copied.sort, MasterView::AutoCopy.copy_all_updated_files.sort)
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
@@ -55,4 +55,67 @@ class TestForm < Test::Unit::TestCase
|
|
55
55
|
assert_equal "<%= form_tag( { :action => 'create' }, :method => \"POST\" ) %>", render_element_event(:stag)
|
56
56
|
end
|
57
57
|
|
58
|
+
def test_put
|
59
|
+
create_template_element ELEMENT_TAG, :attributes => { 'method' => 'put' }
|
60
|
+
attr_value = ":action => 'update'"
|
61
|
+
create_directive Form, attr_value
|
62
|
+
assert_equal "<%= form_tag( { :action => 'update' }, :method => \"put\" ) %>", render_element_event(:stag)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_put_uppercase
|
66
|
+
create_template_element ELEMENT_TAG, :attributes => { 'method' => 'PUT' }
|
67
|
+
attr_value = ":action => 'update'"
|
68
|
+
create_directive Form, attr_value
|
69
|
+
assert_equal "<%= form_tag( { :action => 'update' }, :method => \"PUT\" ) %>", render_element_event(:stag)
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def test_multipart_form
|
74
|
+
create_template_element ELEMENT_TAG, :attributes => { 'method' => 'post', 'enctype' => 'multipart/form-data' }
|
75
|
+
attr_value = ":action => 'create'"
|
76
|
+
create_directive Form, attr_value
|
77
|
+
assert_equal "<%= form_tag( { :action => 'create' }, :method => \"post\", :multipart => true ) %>", render_element_event(:stag)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_multipart_form_uppercase
|
81
|
+
create_template_element ELEMENT_TAG, :attributes => { 'method' => 'post', 'enctype' => 'MULTIPART/FORM-DATA' }
|
82
|
+
attr_value = ":action => 'create'"
|
83
|
+
create_directive Form, attr_value
|
84
|
+
assert_equal "<%= form_tag( { :action => 'create' }, :method => \"post\", :multipart => true ) %>", render_element_event(:stag)
|
85
|
+
end
|
86
|
+
|
87
|
+
# test for using string for action
|
88
|
+
def test_string_action
|
89
|
+
create_template_element ELEMENT_TAG
|
90
|
+
attr_value = "'/create'"
|
91
|
+
create_directive Form, attr_value
|
92
|
+
assert_equal "<%= form_tag( '/create' ) %>", render_element_event(:stag)
|
93
|
+
assert_equal "</form>", render_element_event(:etag)
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_string_action2
|
97
|
+
create_template_element ELEMENT_TAG
|
98
|
+
attr_value = "'/create/foo'"
|
99
|
+
create_directive Form, attr_value
|
100
|
+
assert_equal "<%= form_tag( '/create/foo' ) %>", render_element_event(:stag)
|
101
|
+
assert_equal "</form>", render_element_event(:etag)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_string_action_get
|
105
|
+
create_template_element ELEMENT_TAG, :attributes => { 'method' => 'get' }
|
106
|
+
attr_value = "'/foo/create'"
|
107
|
+
create_directive Form, attr_value
|
108
|
+
assert_equal "<%= form_tag( '/foo/create', :method => \"get\" ) %>", render_element_event(:stag)
|
109
|
+
end
|
110
|
+
|
111
|
+
# test for using parameters
|
112
|
+
def test_params
|
113
|
+
create_template_element ELEMENT_TAG, :attributes => { 'method' => 'get' }
|
114
|
+
attr_value = "{:action => 'create'}, {}, foo, bar"
|
115
|
+
create_directive Form, attr_value
|
116
|
+
assert_equal "<%= form_tag( {:action => 'create'}, {:method => \"get\"}, foo, bar ) %>", render_element_event(:stag)
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
|
58
121
|
end
|
@@ -30,7 +30,7 @@ class StylesheetLinkTest < Test::Unit::TestCase
|
|
30
30
|
|
31
31
|
def test_empty_infer_path
|
32
32
|
link_tag = create_template_element ELEMENT_TAG,
|
33
|
-
:attributes => { '
|
33
|
+
:attributes => { 'href' => '../../public/stylesheets/foo.css' }
|
34
34
|
attr_value = ""
|
35
35
|
create_directive StylesheetLink, attr_value
|
36
36
|
assert_equal '', render_element_event(:stag)
|
@@ -40,7 +40,7 @@ class StylesheetLinkTest < Test::Unit::TestCase
|
|
40
40
|
|
41
41
|
def test_empty_infer_path_sub
|
42
42
|
link_tag = create_template_element ELEMENT_TAG,
|
43
|
-
:attributes => { '
|
43
|
+
:attributes => { 'href' => '../../public/stylesheets/bar/foo.css' }
|
44
44
|
attr_value = ""
|
45
45
|
create_directive StylesheetLink, attr_value
|
46
46
|
assert_equal '', render_element_event(:stag)
|
@@ -50,7 +50,7 @@ class StylesheetLinkTest < Test::Unit::TestCase
|
|
50
50
|
|
51
51
|
def test_empty_use_src
|
52
52
|
link_tag = create_template_element ELEMENT_TAG,
|
53
|
-
:attributes => { '
|
53
|
+
:attributes => { 'href' => '/mystylesheets/foo.css' }
|
54
54
|
attr_value = ""
|
55
55
|
create_directive StylesheetLink, attr_value
|
56
56
|
assert_equal '', render_element_event(:stag)
|
data/test/unit/file_mio_test.rb
CHANGED
@@ -43,7 +43,7 @@ class TestFileMIO < Test::Unit::TestCase
|
|
43
43
|
#------------------------------------------------------------------------------
|
44
44
|
|
45
45
|
# ensure that sandbox limits writing to files outside of root path even if dot dot exists in path
|
46
|
-
def test_sandbox_dotdot
|
46
|
+
def test_sandbox_dotdot
|
47
47
|
assert_raise(InvalidIOPathError){ f = IOMgr.template.path( '../bad') }
|
48
48
|
assert_raise(InvalidIOPathError){ f = IOMgr.template.path( 'bad/../dog/../../foo') }
|
49
49
|
assert_raise(InvalidIOPathError){ f = IOMgr.template.path( 'bad/../../foo') }
|
@@ -97,8 +97,8 @@ class TestFileMIO < Test::Unit::TestCase
|
|
97
97
|
|
98
98
|
file_content_changed = "foo\nbar"
|
99
99
|
File.open( HelloWorldFullPath, 'w' ){ |file| file.write(file_content_changed) }
|
100
|
-
#verify_mio_handler_read( HelloWorldPath, file_content, IOMgr.template ) # still hitting cache #todo turn this on when caching is ready for testing
|
101
|
-
verify_mio_handler_read_no_cache( HelloWorldPath, HelloWorldFullPath, file_content_changed, IOMgr.template )
|
100
|
+
#verify_mio_handler_read( HelloWorldPath, file_content, IOMgr.template ) # still hitting cache #todo turn this on when caching is ready for testing
|
101
|
+
verify_mio_handler_read_no_cache( HelloWorldPath, HelloWorldFullPath, file_content_changed, IOMgr.template )
|
102
102
|
end
|
103
103
|
|
104
104
|
def test_write_string
|
@@ -130,7 +130,7 @@ class TestFileMIO < Test::Unit::TestCase
|
|
130
130
|
|
131
131
|
file_content_strings = [ 'hello', 'world']
|
132
132
|
file_content = file_content_strings.join('')
|
133
|
-
IOMgr.template.path( TestWritePath).write do |f|
|
133
|
+
IOMgr.template.path( TestWritePath).write do |f|
|
134
134
|
file_content_strings.each { |str| f.write(str) }
|
135
135
|
end
|
136
136
|
verify_mio_handler_read( TestWritePath, TestWriteFullPath, file_content, IOMgr.template )
|
@@ -158,6 +158,22 @@ class TestFileMIO < Test::Unit::TestCase
|
|
158
158
|
assert_equal true, IOMgr.template.path( TestWritePath).exist?
|
159
159
|
end
|
160
160
|
|
161
|
+
def test_remove
|
162
|
+
file_content = "foo"
|
163
|
+
|
164
|
+
TestFileMIOTemplatePathname.rmtree if TestFileMIOTemplatePathname.exist?
|
165
|
+
IOMgr.template.path( TestWritePath).write(file_content)
|
166
|
+
assert_equal true, IOMgr.template.path( TestWritePath).exist?
|
167
|
+
IOMgr.template.path(TestWritePath).remove
|
168
|
+
assert_equal false, IOMgr.template.path( TestWritePath).exist?
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_remove_file_doesnt_exist
|
172
|
+
TestFileMIOTemplatePathname.rmtree if TestFileMIOTemplatePathname.exist?
|
173
|
+
assert_equal false, IOMgr.template.path( TestWritePath).exist?
|
174
|
+
assert_raise(Errno::ENOENT){ IOMgr.template.path(TestWritePath).remove }
|
175
|
+
end
|
176
|
+
|
161
177
|
def test_identical
|
162
178
|
file_content = "hello\nworld"
|
163
179
|
file_content_foo = "foo"
|
@@ -243,7 +259,7 @@ class TestFileMIO < Test::Unit::TestCase
|
|
243
259
|
assert_equal 'sub/two/baz.txt', found[2].pathname.to_s
|
244
260
|
end
|
245
261
|
|
246
|
-
def test_findfiles_single_dir_pattern
|
262
|
+
def test_findfiles_single_dir_pattern
|
247
263
|
TestFileMIOTemplatePathname.rmtree if TestFileMIOTemplatePathname.exist?
|
248
264
|
IOMgr.template.path( 'sub/two/apple.txt').write('foo')
|
249
265
|
IOMgr.template.path( 'sub/two/bar.log').write('foo')
|
@@ -257,7 +273,7 @@ class TestFileMIO < Test::Unit::TestCase
|
|
257
273
|
assert_equal 'sub/two/baz.txt', found[1].pathname.to_s
|
258
274
|
end
|
259
275
|
|
260
|
-
def test_findfiles_multi_dir_root
|
276
|
+
def test_findfiles_multi_dir_root
|
261
277
|
TestFileMIOTemplatePathname.rmtree if TestFileMIOTemplatePathname.exist?
|
262
278
|
IOMgr.template.path( 'one/two/three.txt').write('foo')
|
263
279
|
IOMgr.template.path( 'sub/two/apple.txt').write('foo')
|
@@ -276,7 +292,7 @@ class TestFileMIO < Test::Unit::TestCase
|
|
276
292
|
assert_equal 'sub/two/baz.txt', found[3].pathname.to_s
|
277
293
|
end
|
278
294
|
|
279
|
-
def test_findfiles_multi_dir_pattern
|
295
|
+
def test_findfiles_multi_dir_pattern
|
280
296
|
TestFileMIOTemplatePathname.rmtree if TestFileMIOTemplatePathname.exist?
|
281
297
|
IOMgr.template.path( 'one/two/three.txt').write('foo')
|
282
298
|
IOMgr.template.path( 'sub/two/apple.txt').write('foo')
|
@@ -293,7 +309,7 @@ class TestFileMIO < Test::Unit::TestCase
|
|
293
309
|
assert_equal 'sub/two/baz.txt', found[2].pathname.to_s
|
294
310
|
end
|
295
311
|
|
296
|
-
def test_findfiles_multi_dir_pattern_deep
|
312
|
+
def test_findfiles_multi_dir_pattern_deep
|
297
313
|
TestFileMIOTemplatePathname.rmtree if TestFileMIOTemplatePathname.exist?
|
298
314
|
IOMgr.template.path( 'one/two/three.txt').write('foo')
|
299
315
|
IOMgr.template.path( 'sub/two/apple.txt').write('foo')
|
@@ -133,8 +133,8 @@ class TestMTimeStringHashMIO < Test::Unit::TestCase
|
|
133
133
|
|
134
134
|
def test_write_multi_block
|
135
135
|
@template_hash.delete(TestWritePath)
|
136
|
-
IOMgr.template.path( TestWritePath).write do |f|
|
137
|
-
f.write('hello')
|
136
|
+
IOMgr.template.path( TestWritePath).write do |f|
|
137
|
+
f.write('hello')
|
138
138
|
f.write('world')
|
139
139
|
end
|
140
140
|
assert_equal "helloworld", IOMgr.template.path( TestWritePath).read
|
@@ -154,6 +154,19 @@ class TestMTimeStringHashMIO < Test::Unit::TestCase
|
|
154
154
|
assert_equal true, IOMgr.template.path( TestWritePath).exist?
|
155
155
|
end
|
156
156
|
|
157
|
+
def test_remove
|
158
|
+
IOMgr.template.path( TestWritePath).write("foo")
|
159
|
+
assert_equal true, IOMgr.template.path( TestWritePath).exist?
|
160
|
+
IOMgr.template.path(TestWritePath).remove
|
161
|
+
assert_equal false, IOMgr.template.path( TestWritePath).exist?
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_remove_file_doesnt_exist
|
165
|
+
@template_hash.clear
|
166
|
+
assert_equal false, IOMgr.template.path( TestWritePath).exist?
|
167
|
+
assert_nil(IOMgr.template.path(TestWritePath).remove)
|
168
|
+
end
|
169
|
+
|
157
170
|
def test_identical
|
158
171
|
@template_hash.clear
|
159
172
|
assert_equal false, IOMgr.template.path( TestWritePath).identical?("hello\nworld")
|
@@ -209,7 +222,7 @@ class TestMTimeStringHashMIO < Test::Unit::TestCase
|
|
209
222
|
assert_equal 'sub/two/baz.txt', found[2].pathname.to_s
|
210
223
|
end
|
211
224
|
|
212
|
-
def test_findfiles_single_dir_pattern
|
225
|
+
def test_findfiles_single_dir_pattern
|
213
226
|
@template_hash.clear
|
214
227
|
IOMgr.template.path( 'sub/two/apple.txt').write('foo')
|
215
228
|
IOMgr.template.path( 'sub/two/bar.log').write('foo')
|
@@ -222,7 +235,7 @@ class TestMTimeStringHashMIO < Test::Unit::TestCase
|
|
222
235
|
assert_equal 'sub/two/baz.txt', found[1].pathname.to_s
|
223
236
|
end
|
224
237
|
|
225
|
-
def test_findfiles_multi_dir_root
|
238
|
+
def test_findfiles_multi_dir_root
|
226
239
|
@template_hash.clear
|
227
240
|
IOMgr.template.path( 'one/two/three.txt').write('foo')
|
228
241
|
IOMgr.template.path( 'sub/two/apple.txt').write('foo')
|
@@ -240,7 +253,7 @@ class TestMTimeStringHashMIO < Test::Unit::TestCase
|
|
240
253
|
assert_equal 'sub/two/baz.txt', found[3].pathname.to_s
|
241
254
|
end
|
242
255
|
|
243
|
-
def test_findfiles_multi_dir_pattern
|
256
|
+
def test_findfiles_multi_dir_pattern
|
244
257
|
@template_hash.clear
|
245
258
|
IOMgr.template.path( 'one/two/three.txt').write('foo')
|
246
259
|
IOMgr.template.path( 'sub/two/apple.txt').write('foo')
|
@@ -256,7 +269,7 @@ class TestMTimeStringHashMIO < Test::Unit::TestCase
|
|
256
269
|
assert_equal 'sub/two/baz.txt', found[2].pathname.to_s
|
257
270
|
end
|
258
271
|
|
259
|
-
def test_findfiles_multi_dir_pattern_deep
|
272
|
+
def test_findfiles_multi_dir_pattern_deep
|
260
273
|
@template_hash.clear
|
261
274
|
IOMgr.template.path( 'one/two/three.txt').write('foo')
|
262
275
|
IOMgr.template.path( 'sub/two/apple.txt').write('foo')
|