distil 0.13.6 → 0.14.0.b
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/assets/distil.js +9 -7
- data/bin/distil +36 -60
- data/distil.gemspec +17 -32
- data/distil.tmproj +46 -15
- data/lib/distil/browser.rb +30 -26
- data/lib/distil/configurable.rb +64 -153
- data/lib/distil/error-reporter.rb +22 -20
- data/lib/distil/file-vendor.rb +29 -0
- data/lib/distil/hash-additions.rb +45 -0
- data/lib/distil/javascript-code.rb +12 -0
- data/lib/distil/{task/validate-js-task.rb → javascript-file-validator.rb} +19 -23
- data/lib/distil/library.rb +243 -0
- data/lib/distil/product/cache-manifest-product.rb +21 -0
- data/lib/distil/product/css-product.rb +41 -23
- data/lib/distil/product/html-product.rb +20 -0
- data/lib/distil/product/javascript-product.rb +122 -111
- data/lib/distil/product.rb +90 -76
- data/lib/distil/project.rb +370 -104
- data/lib/distil/recursive-http-fetcher.rb +72 -0
- data/lib/distil/server.rb +43 -0
- data/lib/distil/source-file/css-file.rb +56 -3
- data/lib/distil/source-file/html-file.rb +5 -6
- data/lib/distil/source-file/javascript-file.rb +96 -8
- data/lib/distil/source-file/json-file.rb +2 -4
- data/lib/distil/source-file/yui-minifiable-file.rb +19 -0
- data/lib/distil/source-file.rb +50 -92
- data/lib/distil/subclass-tracker.rb +13 -0
- data/lib/distil.rb +21 -37
- metadata +40 -39
- data/assets/mime.types +0 -1240
- data/lib/distil/configurable/file-set.rb +0 -85
- data/lib/distil/configurable/interpolated.rb +0 -36
- data/lib/distil/configurable/output-path.rb +0 -25
- data/lib/distil/configurable/project-path.rb +0 -25
- data/lib/distil/product/concatenated.rb +0 -83
- data/lib/distil/product/debug.rb +0 -32
- data/lib/distil/product/javascript-base-product.rb +0 -35
- data/lib/distil/product/javascript-doc-product.rb +0 -61
- data/lib/distil/product/minified.rb +0 -41
- data/lib/distil/product/page-product.rb +0 -27
- data/lib/distil/product/pdoc-product.rb +0 -42
- data/lib/distil/project/distil-project.rb +0 -157
- data/lib/distil/project/external-project.rb +0 -58
- data/lib/distil/project/remote-project.rb +0 -43
- data/lib/distil/target.rb +0 -251
- data/lib/distil/task/css-dependency-task.rb +0 -64
- data/lib/distil/task/jsl-dependency-task.rb +0 -50
- data/lib/distil/task/nib-task.rb +0 -72
- data/lib/distil/task.rb +0 -50
- data/lib/jsdoc.conf +0 -18
- data/lib/test/HtmlTestReporter.js +0 -127
- data/lib/test/Test.js +0 -248
- data/lib/test/TestReporter.js +0 -79
- data/lib/test/TestRunner.js +0 -132
- data/lib/test/browser.rb +0 -97
- data/lib/test/scriptwrapper.html +0 -10
- data/lib/test/unittest.html +0 -127
@@ -1,85 +0,0 @@
|
|
1
|
-
module Distil
|
2
|
-
|
3
|
-
class FileSet
|
4
|
-
include Enumerable
|
5
|
-
include ErrorReporter
|
6
|
-
|
7
|
-
def initialize(value=[], owner=nil)
|
8
|
-
@owner= owner
|
9
|
-
@source_set= value
|
10
|
-
end
|
11
|
-
|
12
|
-
def files
|
13
|
-
return @files if @files
|
14
|
-
@files=[]
|
15
|
-
case
|
16
|
-
when (@source_set.is_a?(String))
|
17
|
-
include_file(@source_set)
|
18
|
-
when (@source_set.is_a?(Array))
|
19
|
-
@source_set.each { |f| include_file(f) }
|
20
|
-
end
|
21
|
-
@files
|
22
|
-
end
|
23
|
-
|
24
|
-
def files=(set)
|
25
|
-
@files= nil
|
26
|
-
@source_set= set
|
27
|
-
end
|
28
|
-
|
29
|
-
def include?(file)
|
30
|
-
files.include?(file)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.from_options(set, owner)
|
34
|
-
self.new(set, owner)
|
35
|
-
end
|
36
|
-
|
37
|
-
def include_file(file)
|
38
|
-
files if !@files
|
39
|
-
|
40
|
-
if file.is_a?(SourceFile)
|
41
|
-
@files << file if !@files.include?(file)
|
42
|
-
return
|
43
|
-
end
|
44
|
-
|
45
|
-
if @owner
|
46
|
-
full_path= File.expand_path(File.join([@owner.source_folder, file].compact))
|
47
|
-
else
|
48
|
-
full_path= File.expand_path(file)
|
49
|
-
end
|
50
|
-
|
51
|
-
if File.directory?(full_path)
|
52
|
-
Dir.foreach(full_path) { |f|
|
53
|
-
next if f[/^\./]
|
54
|
-
include_file(File.join(file, f))
|
55
|
-
}
|
56
|
-
return
|
57
|
-
end
|
58
|
-
|
59
|
-
files= Dir.glob(full_path)
|
60
|
-
if (files.length>0)
|
61
|
-
files.each { |f|
|
62
|
-
source_file= SourceFile.from_path(f)
|
63
|
-
next if (@files.include?(source_file))
|
64
|
-
@files << source_file
|
65
|
-
}
|
66
|
-
return
|
67
|
-
end
|
68
|
-
|
69
|
-
# file not found by globbing (would also find explicit reference)
|
70
|
-
source_file= @owner.find_file(file) if @owner
|
71
|
-
if !source_file
|
72
|
-
error("File not found: #{file}")
|
73
|
-
return
|
74
|
-
end
|
75
|
-
return if (@files.include?(source_file))
|
76
|
-
@files << source_file
|
77
|
-
end
|
78
|
-
|
79
|
-
def each
|
80
|
-
files.each { |f| yield f }
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Distil
|
2
|
-
|
3
|
-
class Interpolated
|
4
|
-
|
5
|
-
def initialize(value, owner=nil)
|
6
|
-
@value=value
|
7
|
-
@owner=owner
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.from_options(set, owner)
|
11
|
-
self.new(set, owner)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.value_of(value, owner)
|
15
|
-
return value if !owner
|
16
|
-
|
17
|
-
value.gsub(/\$\((\w+)\)/) { |match|
|
18
|
-
v= case
|
19
|
-
when owner.respond_to?($1)
|
20
|
-
owner.send $1
|
21
|
-
when owner.is_a?(Configurable)
|
22
|
-
owner.get_option($1)
|
23
|
-
end
|
24
|
-
|
25
|
-
v || "$(#{$1})"
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
def value_of(owner=nil)
|
30
|
-
owner||=@owner
|
31
|
-
self.class.value_of(@value, owner)
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'distil/configurable/project-path'
|
2
|
-
|
3
|
-
module Distil
|
4
|
-
|
5
|
-
class OutputPath < Interpolated
|
6
|
-
|
7
|
-
def self.value_of(value, owner)
|
8
|
-
return value if !owner
|
9
|
-
|
10
|
-
value= super(value, owner)
|
11
|
-
|
12
|
-
return value if 0==value.index(File::SEPARATOR)
|
13
|
-
return value if !owner.is_a?(Configurable)
|
14
|
-
|
15
|
-
path= owner.get_option("output_folder")
|
16
|
-
return value if !path || path.empty?
|
17
|
-
|
18
|
-
return value if value!=path && 0==value.index(path)
|
19
|
-
|
20
|
-
File.join(path, value)
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'distil/configurable/interpolated'
|
2
|
-
|
3
|
-
module Distil
|
4
|
-
|
5
|
-
class ProjectPath < Interpolated
|
6
|
-
|
7
|
-
def self.value_of(value, owner)
|
8
|
-
return value if !owner
|
9
|
-
|
10
|
-
value= super(value, owner)
|
11
|
-
|
12
|
-
return value if 0==value.index(File::SEPARATOR)
|
13
|
-
return value if !owner.is_a?(Configurable)
|
14
|
-
|
15
|
-
path= owner.get_option("path")
|
16
|
-
return value if !path || path.empty?
|
17
|
-
|
18
|
-
return value if value!=path && 0==value.index(path)
|
19
|
-
|
20
|
-
File.join(path, value)
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
module Distil
|
2
|
-
|
3
|
-
# Mix in for concatenating products
|
4
|
-
module Concatenated
|
5
|
-
|
6
|
-
# files -> an enumerable collection of SourceFiles
|
7
|
-
# join_string -> a string to use to join the files together
|
8
|
-
# target -> the container of the files
|
9
|
-
|
10
|
-
def before_files(f)
|
11
|
-
end
|
12
|
-
|
13
|
-
def after_files(f)
|
14
|
-
end
|
15
|
-
|
16
|
-
def before_externals(f)
|
17
|
-
end
|
18
|
-
|
19
|
-
def after_externals(f)
|
20
|
-
end
|
21
|
-
|
22
|
-
def before_file(f, file)
|
23
|
-
end
|
24
|
-
|
25
|
-
def after_file(f, file)
|
26
|
-
end
|
27
|
-
|
28
|
-
def filename
|
29
|
-
concatenated_name
|
30
|
-
end
|
31
|
-
|
32
|
-
def external_files
|
33
|
-
return @external_files if @external_files
|
34
|
-
@external_files= []
|
35
|
-
|
36
|
-
target.include_projects.each { |ext|
|
37
|
-
@external_files << ext.product_name(:concatenated, File.extname(filename)[1..-1])
|
38
|
-
}
|
39
|
-
@external_files
|
40
|
-
end
|
41
|
-
|
42
|
-
def write_output
|
43
|
-
return if up_to_date
|
44
|
-
@up_to_date= true
|
45
|
-
|
46
|
-
File.open(filename, "w") { |f|
|
47
|
-
f.write(target.notice_text)
|
48
|
-
|
49
|
-
f.write("\n\n")
|
50
|
-
before_externals(f)
|
51
|
-
f.write("\n\n")
|
52
|
-
|
53
|
-
external_files.each { |ext|
|
54
|
-
next if !File.exist?(ext)
|
55
|
-
f.write(join_string)
|
56
|
-
f.write(target.get_content_for_file(ext))
|
57
|
-
}
|
58
|
-
|
59
|
-
f.write("\n\n")
|
60
|
-
after_externals(f)
|
61
|
-
f.write("\n\n")
|
62
|
-
|
63
|
-
f.write("\n\n")
|
64
|
-
before_files(f)
|
65
|
-
f.write("\n\n")
|
66
|
-
|
67
|
-
files.each { |file|
|
68
|
-
f.write(join_string)
|
69
|
-
before_file(f, file)
|
70
|
-
f.write(target.get_content_for_file(file))
|
71
|
-
after_file(f, file)
|
72
|
-
}
|
73
|
-
|
74
|
-
f.write("\n\n")
|
75
|
-
after_files(f)
|
76
|
-
f.write("\n\n");
|
77
|
-
|
78
|
-
}
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
data/lib/distil/product/debug.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
module Distil
|
2
|
-
|
3
|
-
# Mix in for concatenating products
|
4
|
-
module Debug
|
5
|
-
|
6
|
-
# files -> an enumerable collection of SourceFiles
|
7
|
-
# join_string -> a string to use to join the files together
|
8
|
-
# target -> the container of the files
|
9
|
-
|
10
|
-
def before_files(f)
|
11
|
-
end
|
12
|
-
|
13
|
-
def after_files(f)
|
14
|
-
end
|
15
|
-
|
16
|
-
def filename
|
17
|
-
debug_name
|
18
|
-
end
|
19
|
-
|
20
|
-
def external_files
|
21
|
-
return @external_files if @external_files
|
22
|
-
@external_files= []
|
23
|
-
|
24
|
-
target.include_projects.each { |ext|
|
25
|
-
@external_files << ext.product_name(:debug, File.extname(filename)[1..-1])
|
26
|
-
}
|
27
|
-
@external_files
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Distil
|
2
|
-
|
3
|
-
class JavascriptBaseProduct < Product
|
4
|
-
option :bootstrap_script, "#{ASSETS_DIR}/distil.js"
|
5
|
-
option :bootstrap
|
6
|
-
|
7
|
-
def initialize(settings, target)
|
8
|
-
super(settings, target)
|
9
|
-
|
10
|
-
@join_string=<<-eos
|
11
|
-
|
12
|
-
/*jsl:ignore*/;/*jsl:end*/
|
13
|
-
|
14
|
-
eos
|
15
|
-
|
16
|
-
if bootstrap.nil?
|
17
|
-
self.bootstrap= (APP_TYPE==target.target_type)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def can_embed_file?(file)
|
22
|
-
["html", "js"].include?(file.content_type)
|
23
|
-
end
|
24
|
-
|
25
|
-
def bootstrap_source
|
26
|
-
@bootstrap_source||=File.read(bootstrap_script).strip
|
27
|
-
end
|
28
|
-
|
29
|
-
def copy_bootstrap_script
|
30
|
-
FileUtils.cp bootstrap_script, target.project.output_folder if !bootstrap
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module Distil
|
2
|
-
|
3
|
-
JSDOC_COMMAND= "#{VENDOR_DIR}/jsdoc-toolkit/jsrun.sh"
|
4
|
-
|
5
|
-
class JavascriptDocProduct < Product
|
6
|
-
|
7
|
-
option :jsdoc_conf, "#{LIB_DIR}/jsdoc.conf"
|
8
|
-
option :jsdoc_template, "#{VENDOR_DIR}/jsdoc-extras/templates/coherent"
|
9
|
-
option :jsdoc_plugins, "#{VENDOR_DIR}/jsdoc-extras/plugins"
|
10
|
-
option :doc_folder, Interpolated, "$(path)/doc"
|
11
|
-
|
12
|
-
extension "js"
|
13
|
-
|
14
|
-
def filename
|
15
|
-
File.join(doc_folder, 'index.html')
|
16
|
-
end
|
17
|
-
|
18
|
-
def write_output
|
19
|
-
return if up_to_date
|
20
|
-
@up_to_date= true
|
21
|
-
|
22
|
-
return if (!File.exists?(JSDOC_COMMAND))
|
23
|
-
|
24
|
-
tmp= Tempfile.new("jsdoc.conf")
|
25
|
-
|
26
|
-
template= File.read(jsdoc_conf)
|
27
|
-
doc_files= []
|
28
|
-
|
29
|
-
files.each { |f|
|
30
|
-
next if !handles_file?(f)
|
31
|
-
p= f.file_path || f.to_s
|
32
|
-
doc_files << "\"#{p}\""
|
33
|
-
}
|
34
|
-
|
35
|
-
conf= replace_tokens(template, {
|
36
|
-
"DOC_FILES"=>doc_files.join(",\n"),
|
37
|
-
"DOC_OUTPUT_DIR"=>doc_folder,
|
38
|
-
"DOC_TEMPLATE_DIR"=>jsdoc_template,
|
39
|
-
"DOC_PLUGINS_DIR"=>jsdoc_plugins
|
40
|
-
})
|
41
|
-
|
42
|
-
tmp << conf
|
43
|
-
tmp.close()
|
44
|
-
|
45
|
-
command= "#{JSDOC_COMMAND} -c=#{tmp.path}"
|
46
|
-
|
47
|
-
stdin, stdout, stderr= Open3.popen3(command)
|
48
|
-
stdin.close
|
49
|
-
output= stdout.read
|
50
|
-
errors= stderr.read
|
51
|
-
|
52
|
-
tmp.delete
|
53
|
-
|
54
|
-
puts errors
|
55
|
-
puts output
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Distil
|
2
|
-
|
3
|
-
COMPRESSOR= File.expand_path("#{VENDOR_DIR}/yuicompressor-2.4.2.jar")
|
4
|
-
|
5
|
-
module Minified
|
6
|
-
|
7
|
-
def filename
|
8
|
-
minified_name
|
9
|
-
end
|
10
|
-
|
11
|
-
def external_files
|
12
|
-
[]
|
13
|
-
end
|
14
|
-
|
15
|
-
def write_output
|
16
|
-
return if up_to_date
|
17
|
-
@up_to_date= true
|
18
|
-
|
19
|
-
# Run the Y!UI Compressor
|
20
|
-
if (!File.exist?(concatenated_name))
|
21
|
-
error("Missing source file for minify: #{concatenated_name}")
|
22
|
-
return
|
23
|
-
end
|
24
|
-
|
25
|
-
result= system "java -jar #{COMPRESSOR} \"#{concatenated_name}\" -o \"#{filename}\""
|
26
|
-
if (!result)
|
27
|
-
error("Failed to minify: #{concatenated_name}")
|
28
|
-
return
|
29
|
-
end
|
30
|
-
|
31
|
-
if 'css'==extension
|
32
|
-
buffer= File.read(filename)
|
33
|
-
File.open(filename, "w") { |f|
|
34
|
-
f.write(buffer.gsub(/\}/,"}\n").gsub(/.*@import url\(\".*\"\);/,''))
|
35
|
-
}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Distil
|
2
|
-
|
3
|
-
class PageProduct < Product
|
4
|
-
extension "html"
|
5
|
-
|
6
|
-
def filename
|
7
|
-
File.join(target.project.output_folder, "index.html")
|
8
|
-
end
|
9
|
-
|
10
|
-
def write_output
|
11
|
-
output_folder= target.project.output_folder
|
12
|
-
mode= target.project.mode
|
13
|
-
|
14
|
-
files.each { |f|
|
15
|
-
if (RELEASE_MODE==mode)
|
16
|
-
FileUtils.cp f, output_folder
|
17
|
-
else
|
18
|
-
product_path= File.join(output_folder, File.basename(f))
|
19
|
-
FileUtils.rm product_path if File.exists? product_path
|
20
|
-
File.symlink f.relative_to_folder(output_folder), product_path
|
21
|
-
end
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Distil
|
2
|
-
|
3
|
-
require "#{VENDOR_DIR}/pdoc/lib/pdoc"
|
4
|
-
|
5
|
-
class PDocProduct < Product
|
6
|
-
|
7
|
-
option :pdoc_template, "#{VENDOR_DIR}/pdoc-template"
|
8
|
-
option :doc_folder, Interpolated, "$(path)/doc"
|
9
|
-
|
10
|
-
extension "js"
|
11
|
-
|
12
|
-
def filename
|
13
|
-
File.join(doc_folder, 'index.html')
|
14
|
-
end
|
15
|
-
|
16
|
-
def write_output
|
17
|
-
return if up_to_date
|
18
|
-
@up_to_date= true
|
19
|
-
|
20
|
-
PDoc.run({
|
21
|
-
:source_files => files,
|
22
|
-
:destination => doc_folder,
|
23
|
-
:templates => pdoc_template,
|
24
|
-
:syntax_highlighter => :pygments,
|
25
|
-
:markdown_parser => :bluecloth,
|
26
|
-
# :src_code_href => proc { |entity|
|
27
|
-
# "http://github.com/example/ex/#{entity.file}##{entity.line_number}"
|
28
|
-
# },
|
29
|
-
:pretty_urls => true,
|
30
|
-
:bust_cache => true,
|
31
|
-
:name => 'Example JavaScript Framework',
|
32
|
-
:short_name => 'Ex',
|
33
|
-
:home_url => 'http://example.com',
|
34
|
-
:doc_url => 'http://example.com/api',
|
35
|
-
:version => "1.2.0",
|
36
|
-
:copyright_notice => 'This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-Share Alike 3.0 Unported License</a>.'
|
37
|
-
})
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
@@ -1,157 +0,0 @@
|
|
1
|
-
module Distil
|
2
|
-
|
3
|
-
class DistilProject < Project
|
4
|
-
|
5
|
-
attr_reader :project_file, :targets
|
6
|
-
|
7
|
-
option :ignore_warnings, false
|
8
|
-
option :warnings_are_errors, false
|
9
|
-
option :external_projects, [], :aliases=>['external']
|
10
|
-
option :distileries, Array, :aliases=>['distilleries', 'distilery', 'distillery']
|
11
|
-
|
12
|
-
|
13
|
-
def initialize(project_file, settings={}, parent=nil)
|
14
|
-
|
15
|
-
begin
|
16
|
-
|
17
|
-
@project_file= File.expand_path(project_file)
|
18
|
-
@projects_by_name={}
|
19
|
-
|
20
|
-
project_info= YAML.load_file(@project_file)
|
21
|
-
project_info["path"]= File.dirname(@project_file)
|
22
|
-
|
23
|
-
super(project_info, parent)
|
24
|
-
get_options(settings, parent)
|
25
|
-
|
26
|
-
FileUtils.mkdir_p(output_folder)
|
27
|
-
|
28
|
-
load_external_projects
|
29
|
-
find_targets
|
30
|
-
load_distileries
|
31
|
-
|
32
|
-
rescue ValidationError => err
|
33
|
-
puts "#{APP_NAME}: #{SourceFile.path_relative_to_folder(project_file, Dir.pwd)}: #{err.message}\n"
|
34
|
-
exit 1
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
def find_targets
|
40
|
-
@targets= []
|
41
|
-
target_list= @extras['targets']
|
42
|
-
|
43
|
-
if !target_list
|
44
|
-
@targets << Target.new(@extras.clone, self)
|
45
|
-
return @targets
|
46
|
-
end
|
47
|
-
|
48
|
-
@targets= target_list.map { |target|
|
49
|
-
Target.new(target, self)
|
50
|
-
}
|
51
|
-
end
|
52
|
-
|
53
|
-
def load_external_projects
|
54
|
-
return if !external_projects
|
55
|
-
projects= []
|
56
|
-
|
57
|
-
external_projects.each { |config|
|
58
|
-
project= Project.from_config(config, self)
|
59
|
-
next if !project
|
60
|
-
projects << project
|
61
|
-
@projects_by_name[project.name]= project
|
62
|
-
}
|
63
|
-
|
64
|
-
self.external_projects= projects
|
65
|
-
end
|
66
|
-
|
67
|
-
def external_project_with_name(name)
|
68
|
-
@projects_by_name[name]
|
69
|
-
end
|
70
|
-
|
71
|
-
def launch
|
72
|
-
build if !up_to_date
|
73
|
-
|
74
|
-
require 'webrick'
|
75
|
-
mime_types = WEBrick::HTTPUtils::load_mime_types(File.join(ASSETS_DIR, "mime.types"))
|
76
|
-
config= {
|
77
|
-
:Port => 8888,
|
78
|
-
:MimeTypes => mime_types
|
79
|
-
}
|
80
|
-
|
81
|
-
server= WEBrick::HTTPServer.new(config)
|
82
|
-
server.mount("/", WEBrick::HTTPServlet::FileHandler, output_folder)
|
83
|
-
|
84
|
-
['INT', 'TERM'].each { |signal|
|
85
|
-
trap(signal){ server.shutdown}
|
86
|
-
}
|
87
|
-
b= Browser.new
|
88
|
-
b.open("http://localhost:8888/")
|
89
|
-
server.start
|
90
|
-
end
|
91
|
-
alias :server :launch
|
92
|
-
|
93
|
-
def load_distileries
|
94
|
-
return if distileries.nil?
|
95
|
-
|
96
|
-
distileries.each { |d|
|
97
|
-
if (File.exists?(d))
|
98
|
-
require d
|
99
|
-
next
|
100
|
-
end
|
101
|
-
path= Gem.required_location(d, 'distilery.rb')
|
102
|
-
if (path.nil?)
|
103
|
-
puts "Missing distilery: #{d}"
|
104
|
-
end
|
105
|
-
next if path.nil?
|
106
|
-
require path
|
107
|
-
}
|
108
|
-
end
|
109
|
-
|
110
|
-
def up_to_date
|
111
|
-
return false if !external_projects.all?{ |project| project.up_to_date }
|
112
|
-
return targets.all? { |target| target.up_to_date }
|
113
|
-
end
|
114
|
-
|
115
|
-
def clean
|
116
|
-
# clean_external_projects
|
117
|
-
targets.each { |target|
|
118
|
-
target.clean
|
119
|
-
}
|
120
|
-
end
|
121
|
-
|
122
|
-
def build
|
123
|
-
build_external_projects
|
124
|
-
build_targets
|
125
|
-
end
|
126
|
-
|
127
|
-
def build_external_projects
|
128
|
-
external_projects.each { |project|
|
129
|
-
project.build
|
130
|
-
}
|
131
|
-
end
|
132
|
-
|
133
|
-
def build_targets
|
134
|
-
targets.each { |target|
|
135
|
-
target.build
|
136
|
-
}
|
137
|
-
end
|
138
|
-
|
139
|
-
def find_file(file, source_file=nil)
|
140
|
-
return nil if external_projects.nil?
|
141
|
-
|
142
|
-
parts= file.split(File::SEPARATOR)
|
143
|
-
project_name= parts[0]
|
144
|
-
|
145
|
-
external_project= external_project_with_name(project_name)
|
146
|
-
return nil if !external_project
|
147
|
-
|
148
|
-
if 1==parts.length
|
149
|
-
return SourceFile::from_path(external_project.product_name(:import, source_file.content_type))
|
150
|
-
else
|
151
|
-
return SourceFile::from_path(File.join(external_project.output_folder, *parts[1..-1]))
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|
156
|
-
|
157
|
-
end
|