distil 0.10.4 → 0.11.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/Rakefile +2 -1
- data/VERSION +1 -1
- data/assets/distil.js +359 -0
- data/bin/distil +33 -10
- data/distil.gemspec +35 -24
- data/lib/distil/configurable/file-set.rb +86 -0
- data/lib/distil/configurable/interpolated.rb +36 -0
- data/lib/distil/configurable/output-path.rb +25 -0
- data/lib/distil/configurable/project-path.rb +25 -0
- data/lib/distil/configurable.rb +164 -0
- data/lib/distil/error-reporter.rb +63 -0
- data/lib/distil/product/concatenated.rb +85 -0
- data/lib/distil/product/css-product.rb +37 -0
- data/lib/distil/product/debug.rb +34 -0
- data/lib/distil/product/javascript-base-product.rb +35 -0
- data/lib/distil/product/javascript-doc-product.rb +61 -0
- data/lib/distil/product/javascript-product.rb +131 -0
- data/lib/distil/product/minified.rb +32 -0
- data/lib/distil/product.rb +97 -0
- data/lib/distil/project/distil-project.rb +99 -0
- data/lib/distil/project/external-project.rb +53 -0
- data/lib/distil/project.rb +78 -0
- data/lib/distil/source-file/css-file.rb +14 -0
- data/lib/distil/source-file/html-file.rb +14 -0
- data/lib/distil/source-file/javascript-file.rb +17 -0
- data/lib/distil/source-file/json-file.rb +16 -0
- data/lib/distil/source-file.rb +172 -0
- data/lib/distil/target.rb +235 -0
- data/lib/distil/task/css-dependency-task.rb +64 -0
- data/lib/distil/task/jsl-dependency-task.rb +49 -0
- data/lib/distil/task/nib-task.rb +72 -0
- data/lib/distil/task/validate-js-task.rb +75 -0
- data/lib/distil/task.rb +50 -0
- data/lib/distil.rb +72 -0
- data/lib/jsl.conf +4 -0
- data/vendor/jsl-0.3.0/src/Makefile.ref +16 -6
- data/vendor/jsl-0.3.0/src/config.mk +32 -2
- data/vendor/jsl-0.3.0/src/fdlibm/Makefile.ref +1 -2
- data/vendor/jsl-0.3.0/src/jsl.c +124 -13
- data/vendor/jsl-0.3.0/src/rules.mk +2 -1
- metadata +49 -28
- data/lib/bootstrap-template.js +0 -58
- data/lib/configurable.rb +0 -161
- data/lib/file-set.rb +0 -49
- data/lib/file-types/css-file.rb +0 -12
- data/lib/file-types/html-file.rb +0 -11
- data/lib/file-types/javascript-file.rb +0 -24
- data/lib/file-types/json-file.rb +0 -17
- data/lib/filter.rb +0 -41
- data/lib/filters/css-filter.rb +0 -58
- data/lib/filters/file-reference-filter.rb +0 -30
- data/lib/filters/jsl-dependency-filter.rb +0 -44
- data/lib/project.rb +0 -174
- data/lib/source-file.rb +0 -197
- data/lib/target.rb +0 -102
- data/lib/task.rb +0 -212
- data/lib/tasks/copy-task.rb +0 -17
- data/lib/tasks/css-task.rb +0 -12
- data/lib/tasks/javascript-task.rb +0 -206
- data/lib/tasks/multiple-output-task.rb +0 -140
- data/lib/tasks/output-task.rb +0 -76
- data/lib/tasks/single-output-task.rb +0 -104
- data/lib/tasks/test-task.rb +0 -280
@@ -1,104 +0,0 @@
|
|
1
|
-
require "#{$script_dir}/tasks/output-task.rb"
|
2
|
-
|
3
|
-
class SingleOutputTask < OutputTask
|
4
|
-
|
5
|
-
option :output_name, ""
|
6
|
-
|
7
|
-
def initialize(target, options)
|
8
|
-
super(target, options)
|
9
|
-
|
10
|
-
type= output_extension
|
11
|
-
return if (!type)
|
12
|
-
|
13
|
-
if (!output_name.empty?)
|
14
|
-
target_name= "#{output_name}"
|
15
|
-
prefix= "#{output_folder}/"
|
16
|
-
else
|
17
|
-
target_name= "#{target.target_name}".downcase
|
18
|
-
prefix= "#{output_folder}/#{project_name}"
|
19
|
-
if ("all"==target_name)
|
20
|
-
target_name= ""
|
21
|
-
else
|
22
|
-
prefix= "#{prefix}-"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
@name_concat= "#{prefix}#{target_name}-uncompressed#{type}"
|
27
|
-
@name_min= "#{prefix}#{target_name}#{type}"
|
28
|
-
@name_gz= "#{prefix}#{target_name}#{type}.gz"
|
29
|
-
@name_debug= "#{prefix}#{target_name}-debug#{type}"
|
30
|
-
|
31
|
-
@concatenation_join_string= ""
|
32
|
-
@products= [@name_concat, @name_min, @name_gz, @name_debug]
|
33
|
-
|
34
|
-
@concat = ""
|
35
|
-
@debug = ""
|
36
|
-
end
|
37
|
-
|
38
|
-
def process_file(file)
|
39
|
-
if (!@concat.empty?)
|
40
|
-
@concat << @concatenation_join_string||""
|
41
|
-
end
|
42
|
-
@concat << file.filtered_content(options)
|
43
|
-
@debug << file.debug_content(options)
|
44
|
-
end
|
45
|
-
|
46
|
-
def process_files
|
47
|
-
@included_files.each { |f| process_file(f) }
|
48
|
-
end
|
49
|
-
|
50
|
-
def uncompressed_preamble
|
51
|
-
""
|
52
|
-
end
|
53
|
-
|
54
|
-
def uncompressed_postscript
|
55
|
-
""
|
56
|
-
end
|
57
|
-
|
58
|
-
def finish
|
59
|
-
return if (!output_type)
|
60
|
-
|
61
|
-
# Clear old files
|
62
|
-
[@name_concat, @name_min, @name_gz, @name_debug].each { |file|
|
63
|
-
next if (!File.exists?(file))
|
64
|
-
File.delete(file)
|
65
|
-
}
|
66
|
-
|
67
|
-
return if (""==@concat)
|
68
|
-
|
69
|
-
params= {
|
70
|
-
"VERSION"=>@options.version
|
71
|
-
}
|
72
|
-
|
73
|
-
concat= replace_tokens(@concat, params)
|
74
|
-
|
75
|
-
File.open(@name_concat, "w") { |f|
|
76
|
-
f.write(notice_text)
|
77
|
-
f.write(uncompressed_preamble)
|
78
|
-
f.write(concat)
|
79
|
-
f.write(uncompressed_postscript)
|
80
|
-
}
|
81
|
-
|
82
|
-
minified= minify(concat)
|
83
|
-
|
84
|
-
File.open(@name_min, "w") { |f|
|
85
|
-
f.write(notice_text)
|
86
|
-
f.write(minified)
|
87
|
-
}
|
88
|
-
|
89
|
-
Zlib::GzipWriter.open(@name_gz) { |f|
|
90
|
-
f.write(notice_text)
|
91
|
-
f.write(minified)
|
92
|
-
}
|
93
|
-
|
94
|
-
return if (""==@debug)
|
95
|
-
|
96
|
-
File.open(@name_debug, "w") { |f|
|
97
|
-
f.write(notice_text)
|
98
|
-
debug= replace_tokens(@debug, params)
|
99
|
-
f.write(debug)
|
100
|
-
}
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
data/lib/tasks/test-task.rb
DELETED
@@ -1,280 +0,0 @@
|
|
1
|
-
#######
|
2
|
-
# NOT READY FOR USE
|
3
|
-
#######
|
4
|
-
|
5
|
-
|
6
|
-
require 'webrick'
|
7
|
-
require "#{$script_dir}/test/browser.rb"
|
8
|
-
|
9
|
-
include WEBrick
|
10
|
-
|
11
|
-
$unit_test_html= File.read("#{$script_dir}/test/unittest.html")
|
12
|
-
$script_wrapper_html= File.read("#{$script_dir}/test/scriptwrapper.html")
|
13
|
-
|
14
|
-
def replace_tokens(string, params)
|
15
|
-
return string.gsub(/(\n[\t ]*)?@([^@ \t\r\n]*)@/) { |m|
|
16
|
-
key= $2
|
17
|
-
ws= $1
|
18
|
-
value= params[key]||m;
|
19
|
-
if (ws && ws.length)
|
20
|
-
ws + value.split("\n").join(ws);
|
21
|
-
else
|
22
|
-
value
|
23
|
-
end
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
def relative_path(file, output_folder)
|
28
|
-
outputFolder= File.expand_path(output_folder).to_s
|
29
|
-
file= File.expand_path(file).to_s
|
30
|
-
|
31
|
-
# Remove leading slash and split into parts
|
32
|
-
file_parts= file.slice(1..-1).split('/');
|
33
|
-
output_parts= outputFolder.slice(1..-1).split('/');
|
34
|
-
|
35
|
-
common_prefix_length= 0
|
36
|
-
|
37
|
-
file_parts.each_index { |i|
|
38
|
-
common_prefix_length= i
|
39
|
-
break if file_parts[i]!=output_parts[i]
|
40
|
-
}
|
41
|
-
|
42
|
-
return '../'*(output_parts.length-common_prefix_length) + file_parts[common_prefix_length..-1].join('/')
|
43
|
-
end
|
44
|
-
|
45
|
-
def order_files(file, ordered_files= Array.new, probed= Set.new)
|
46
|
-
return if probed.include?(file)
|
47
|
-
return if ordered_files.include?(file)
|
48
|
-
probed << file
|
49
|
-
|
50
|
-
file.dependencies.each { |d| order_files(d, ordered_files, probed) }
|
51
|
-
ordered_files << file
|
52
|
-
|
53
|
-
ordered_files
|
54
|
-
end
|
55
|
-
|
56
|
-
# Create an HTML wrapper file for a JavaScript file. The wrapper will include
|
57
|
-
# one script tag for each imported file in the script. This means you don't
|
58
|
-
# have to write lots of silly wrapper HTML files for your tests.
|
59
|
-
def html_wrapper_for_script_file(script_file)
|
60
|
-
source_file= SourceFile.from_path(script_file)
|
61
|
-
|
62
|
-
files= order_files(source_file)
|
63
|
-
|
64
|
-
current_dir= File.expand_path('.')
|
65
|
-
|
66
|
-
files.map! { |file|
|
67
|
-
# file= file.gsub(/-uncompressed\.js/, '-debug.js')
|
68
|
-
file.relative_to_folder(current_dir)
|
69
|
-
}
|
70
|
-
|
71
|
-
scripts= files.map { |file|
|
72
|
-
"<script src=\"#{file}\" type=\"text/javascript\" charset=\"utf-8\"></script>"
|
73
|
-
}
|
74
|
-
|
75
|
-
replace_tokens($script_wrapper_html, {
|
76
|
-
"scripts" => scripts.join("\n"),
|
77
|
-
"title" => "#{script_file}"
|
78
|
-
})
|
79
|
-
end
|
80
|
-
|
81
|
-
class ScriptWrapper < HTTPServlet::AbstractServlet
|
82
|
-
|
83
|
-
def do_GET(request, response)
|
84
|
-
response.status = 200
|
85
|
-
response['Content-Type'] = 'text/html'
|
86
|
-
|
87
|
-
file= request.query.to_s
|
88
|
-
response.body = html_wrapper_for_script_file(file)
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
class WEBrick::HTTPServlet::AbstractServlet
|
94
|
-
def prevent_caching(res)
|
95
|
-
res['ETag'] = nil
|
96
|
-
res['Last-Modified'] = Time.now + 100**4
|
97
|
-
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
|
98
|
-
res['Pragma'] = 'no-cache'
|
99
|
-
res['Expires'] = Time.now - 100**4
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
class NonCachingFileHandler < WEBrick::HTTPServlet::FileHandler
|
104
|
-
def do_GET(req, res)
|
105
|
-
super
|
106
|
-
set_default_content_type(res, req.path)
|
107
|
-
prevent_caching(res)
|
108
|
-
end
|
109
|
-
|
110
|
-
def set_default_content_type(res, path)
|
111
|
-
res['Content-Type'] = case path
|
112
|
-
when /\.js$/ then 'text/javascript'
|
113
|
-
when /\.html$/ then 'text/html'
|
114
|
-
when /\.css$/ then 'text/css'
|
115
|
-
else 'text/plain'
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
class BrowserTestServlet < HTTPServlet::AbstractServlet
|
121
|
-
|
122
|
-
def initialize(server, browser_test)
|
123
|
-
super(server)
|
124
|
-
@browser_test= browser_test
|
125
|
-
end
|
126
|
-
|
127
|
-
def generate_file(filename)
|
128
|
-
params= {
|
129
|
-
'file'=>filename
|
130
|
-
}
|
131
|
-
return replace_tokens($unit_test_html, params)
|
132
|
-
end
|
133
|
-
|
134
|
-
def do_GET(request, response)
|
135
|
-
prevent_caching(response)
|
136
|
-
|
137
|
-
file= request.query.to_s
|
138
|
-
if ("first_file"==file)
|
139
|
-
response.status= 302
|
140
|
-
response['Location']= @browser_test.next_file
|
141
|
-
response.body= "Forwarded..."
|
142
|
-
return
|
143
|
-
end
|
144
|
-
|
145
|
-
response.status = 200
|
146
|
-
response['Content-Type'] = 'text/html'
|
147
|
-
response.body = $unit_test_html
|
148
|
-
end
|
149
|
-
|
150
|
-
def do_POST(request, response)
|
151
|
-
prevent_caching(response)
|
152
|
-
q= request.query
|
153
|
-
|
154
|
-
failures= []
|
155
|
-
|
156
|
-
q['failures'].split('~!~').each { |line|
|
157
|
-
failures << "#{line}"
|
158
|
-
}
|
159
|
-
|
160
|
-
location= @browser_test.send_results({
|
161
|
-
'failures' => failures,
|
162
|
-
'passed' => q['numberOfPasses'].to_i,
|
163
|
-
'failed' => q['numberOfFailures'].to_i,
|
164
|
-
'skipped' => q['numberOfSkipped'].to_i
|
165
|
-
})
|
166
|
-
|
167
|
-
response.status= 302
|
168
|
-
response['Location']= location
|
169
|
-
response.body="Redirected..."
|
170
|
-
end
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
class TestTask < Task
|
175
|
-
|
176
|
-
option :browsers, ['safari']
|
177
|
-
option :tests, FileSet
|
178
|
-
option :run_tests, false
|
179
|
-
|
180
|
-
def initialize(target, options)
|
181
|
-
super(target, options)
|
182
|
-
@result_queue= Queue.new
|
183
|
-
@file_queue= Queue.new
|
184
|
-
|
185
|
-
@files_to_include= @options.tests.to_a
|
186
|
-
|
187
|
-
@passed= 0
|
188
|
-
@failed= 0
|
189
|
-
@skipped= 0
|
190
|
-
end
|
191
|
-
|
192
|
-
def handles_file?(file_name)
|
193
|
-
"#{file_name}"[/\.js$/] || "#{file_name}"[/\.html$/]
|
194
|
-
end
|
195
|
-
|
196
|
-
def start_webserver()
|
197
|
-
access_log_stream = File.open('/dev/null', 'w')
|
198
|
-
access_log = [[access_log_stream, AccessLog::COMBINED_LOG_FORMAT]]
|
199
|
-
|
200
|
-
# @server = HTTPServer.new(:Port=>8000)
|
201
|
-
#
|
202
|
-
@server = HTTPServer.new(:Port=>8000, :Logger=>Log.new(nil, BasicLog::WARN),
|
203
|
-
:AccessLog=>[])
|
204
|
-
|
205
|
-
@server.mount "/wrapped", ScriptWrapper
|
206
|
-
@server.mount "/lib", NonCachingFileHandler, $script_dir
|
207
|
-
@server.mount "/", NonCachingFileHandler, "."
|
208
|
-
|
209
|
-
trap "INT" do @server.shutdown end
|
210
|
-
t= Thread.new { @server.start }
|
211
|
-
end
|
212
|
-
|
213
|
-
def next_file()
|
214
|
-
file= @file_queue.pop
|
215
|
-
file= relative_path(file, Dir.getwd)
|
216
|
-
|
217
|
-
if (file[/\.js$/])
|
218
|
-
file= "/wrapped?#{file}"
|
219
|
-
end
|
220
|
-
return file
|
221
|
-
end
|
222
|
-
|
223
|
-
def send_results(results)
|
224
|
-
@result_queue.push(results)
|
225
|
-
next_file
|
226
|
-
end
|
227
|
-
|
228
|
-
def cleanup()
|
229
|
-
# find the files again, because tests often include output files, which may
|
230
|
-
# not be present in a clean build
|
231
|
-
find_files
|
232
|
-
|
233
|
-
return if (!@options.run_tests || 'false'===@options.run_tests || 'no'===@options.run_tests)
|
234
|
-
return if (0==@included_files.length)
|
235
|
-
|
236
|
-
start_webserver
|
237
|
-
@server.mount "/unittest", BrowserTestServlet, self
|
238
|
-
|
239
|
-
puts "browsers=#{@options.browsers.inspect}"
|
240
|
-
browsers= @options.browsers.map { |b| "#{b}".downcase }
|
241
|
-
|
242
|
-
browsers.each { |b|
|
243
|
-
browser= ($browsers[b]).new
|
244
|
-
next if !browser.supported?
|
245
|
-
|
246
|
-
browser.setup
|
247
|
-
browser.visit("http://localhost:8000/unittest")
|
248
|
-
|
249
|
-
@included_files.each { |f|
|
250
|
-
|
251
|
-
@file_queue.push(f)
|
252
|
-
status= @result_queue.pop
|
253
|
-
|
254
|
-
file= File.expand_path(f)
|
255
|
-
|
256
|
-
@passed= status['passed']
|
257
|
-
@failed= status['failed']
|
258
|
-
@skipped= status['skipped']
|
259
|
-
|
260
|
-
status['failures'].each { |line|
|
261
|
-
puts "#{file}: #{line}"
|
262
|
-
}
|
263
|
-
|
264
|
-
}
|
265
|
-
|
266
|
-
# release waiting call to send_results
|
267
|
-
@file_queue.push('about:blank');
|
268
|
-
|
269
|
-
puts "#{b}: #{@passed} passed #{@failed} failed #{@skipped} skipped\n"
|
270
|
-
}
|
271
|
-
|
272
|
-
@server.unmount "/unittest"
|
273
|
-
@server.shutdown
|
274
|
-
end
|
275
|
-
|
276
|
-
def need_to_build
|
277
|
-
true
|
278
|
-
end
|
279
|
-
|
280
|
-
end
|