distil 0.13.6 → 0.14.0.b
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 +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
data/lib/distil/product.rb
CHANGED
@@ -1,108 +1,122 @@
|
|
1
1
|
module Distil
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
option :force, false
|
10
|
-
|
11
|
-
include ErrorReporter
|
12
|
-
|
13
|
-
attr_accessor :assets, :target, :join_string
|
14
|
-
class_attr :extension
|
3
|
+
RELEASE_VARIANT= :release
|
4
|
+
DEBUG_VARIANT= :debug
|
5
|
+
|
6
|
+
class Product
|
7
|
+
class_attr :content_type
|
8
|
+
class_attr :variants
|
15
9
|
|
16
|
-
|
17
|
-
|
10
|
+
attr_reader :project, :files, :language, :variant, :assets, :libraries
|
11
|
+
|
12
|
+
def initialize(project, language, variant=nil)
|
13
|
+
@project= project
|
14
|
+
@language= language ? language.to_s : language
|
18
15
|
@files= []
|
16
|
+
@libraries= []
|
19
17
|
@assets= Set.new
|
20
|
-
|
18
|
+
@variant= variant
|
21
19
|
end
|
22
20
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
def notice_comment
|
22
|
+
return @notice_comment if @notice_comment
|
23
|
+
notice_text= project.notice_text
|
24
|
+
return @notice_command= "" if !notice_text || notice_text.empty?
|
25
|
+
|
26
|
+
@notice_comment= "/*!\n "
|
27
|
+
@notice_comment<< project.notice_text.split("\n").join("\n ")
|
28
|
+
@notice_comment<< "\n */\n"
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
|
31
|
+
def filename
|
32
|
+
filename= "#{project.name}"
|
33
|
+
filename << "-#{language}" if language
|
34
|
+
filename << "-#{variant}" if variants.length>1
|
35
|
+
filename << ".#{content_type}"
|
33
36
|
end
|
34
37
|
|
35
|
-
def
|
36
|
-
|
38
|
+
def output_path
|
39
|
+
@output_path ||= File.join(project.output_path, filename)
|
37
40
|
end
|
38
41
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@assets.merge(f.assets)
|
44
|
-
}
|
42
|
+
def handles_file?(file)
|
43
|
+
# puts "#{self.class}#handles_file: #{file} file-lang=#{file.language} prod-lang=#{language} equal=#{file.language==language}"
|
44
|
+
return (file.extension==content_type) &&
|
45
|
+
(language.nil? || file.language.nil? || file.language==language)
|
45
46
|
end
|
46
|
-
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
|
48
|
+
def include_file(file)
|
49
|
+
if file.is_a?(Library)
|
50
|
+
return true if @libraries.include?(file)
|
51
|
+
@libraries << file
|
52
|
+
return true
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
max_asset_modified= File.stat(target.project.project_file).mtime
|
55
|
+
return true if @files.include?(file)
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
if handles_file?(file)
|
58
|
+
@files << file
|
59
|
+
@assets.merge(file.assets) if file.assets
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def up_to_date?
|
64
|
+
count= files.length
|
65
|
+
return true if 0==@files.length
|
66
|
+
return false unless File.exists?(output_path)
|
67
|
+
product_last_modified= File.stat(output_path).mtime
|
59
68
|
files.each { |f|
|
60
|
-
|
61
|
-
}
|
62
|
-
|
63
|
-
external_files.each { |f|
|
64
|
-
next if !File.exist?(f)
|
65
|
-
last_modified= File.stat(f).mtime
|
66
|
-
max_asset_modified= last_modified if last_modified > max_asset_modified
|
69
|
+
return false if f.last_modified > product_last_modified
|
67
70
|
}
|
71
|
+
true
|
72
|
+
end
|
68
73
|
|
69
|
-
|
74
|
+
def build
|
75
|
+
return if up_to_date?
|
76
|
+
|
77
|
+
FileUtils.mkdir_p(File.dirname(output_path))
|
78
|
+
self.send "build_#{variant}"
|
79
|
+
minimise
|
80
|
+
gzip
|
81
|
+
end
|
82
|
+
|
83
|
+
def clean
|
84
|
+
FileUtils.rm output_path if File.exists?(output_path)
|
85
|
+
return unless RELEASE_VARIANT==variant
|
86
|
+
FileUtils.rm minimised_filename if File.exists?(minimised_filename)
|
87
|
+
FileUtils.rm gzip_filename if File.exists?(gzip_filename)
|
70
88
|
end
|
71
89
|
|
72
|
-
def
|
73
|
-
|
90
|
+
def minimised_filename
|
91
|
+
@minimised_filename if @minimised_filename
|
92
|
+
|
93
|
+
minimised_filename= "#{project.name}"
|
94
|
+
minimised_filename << "-#{language}" if language
|
95
|
+
minimised_filename << ".#{content_type}"
|
96
|
+
@minimised_filename= File.join(project.output_path, minimised_filename)
|
74
97
|
end
|
75
98
|
|
76
|
-
def
|
77
|
-
|
99
|
+
def minimise
|
100
|
+
return unless RELEASE_VARIANT==variant
|
101
|
+
system("java -jar #{COMPRESSOR} --type #{content_type} -o #{minimised_filename} #{output_path}")
|
78
102
|
end
|
79
103
|
|
80
|
-
def
|
81
|
-
|
104
|
+
def gzip_filename
|
105
|
+
@gzip_filename ||= "#{minimised_filename}.gz"
|
82
106
|
end
|
83
107
|
|
84
|
-
def
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
source_folder= target.project.source_folder
|
90
|
-
|
91
|
-
path=file.relative_to_folder(source_folder) if 0==file_path.index(source_folder)
|
92
|
-
path=file.relative_to_folder(output_folder) if 0==file_path.index(output_folder)
|
93
|
-
path
|
108
|
+
def gzip
|
109
|
+
return unless RELEASE_VARIANT==variant
|
110
|
+
Zlib::GzipWriter.open(gzip_filename) do |gz|
|
111
|
+
gz.write File.read(minimised_filename)
|
112
|
+
end
|
94
113
|
end
|
95
|
-
|
114
|
+
|
96
115
|
end
|
97
116
|
|
98
117
|
end
|
99
118
|
|
100
|
-
|
101
|
-
|
102
|
-
require
|
103
|
-
|
104
|
-
require 'distil/product/javascript-base-product'
|
105
|
-
require 'distil/product/javascript-product'
|
106
|
-
require 'distil/product/javascript-doc-product'
|
107
|
-
require 'distil/product/pdoc-product'
|
108
|
-
require 'distil/product/page-product'
|
119
|
+
# load all the other file types
|
120
|
+
Dir.glob("#{Distil::LIB_DIR}/distil/product/*.rb") { |file|
|
121
|
+
require file
|
122
|
+
}
|