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.
Files changed (59) hide show
  1. data/Rakefile +1 -0
  2. data/VERSION +1 -1
  3. data/assets/distil.js +9 -7
  4. data/bin/distil +36 -60
  5. data/distil.gemspec +17 -32
  6. data/distil.tmproj +46 -15
  7. data/lib/distil/browser.rb +30 -26
  8. data/lib/distil/configurable.rb +64 -153
  9. data/lib/distil/error-reporter.rb +22 -20
  10. data/lib/distil/file-vendor.rb +29 -0
  11. data/lib/distil/hash-additions.rb +45 -0
  12. data/lib/distil/javascript-code.rb +12 -0
  13. data/lib/distil/{task/validate-js-task.rb → javascript-file-validator.rb} +19 -23
  14. data/lib/distil/library.rb +243 -0
  15. data/lib/distil/product/cache-manifest-product.rb +21 -0
  16. data/lib/distil/product/css-product.rb +41 -23
  17. data/lib/distil/product/html-product.rb +20 -0
  18. data/lib/distil/product/javascript-product.rb +122 -111
  19. data/lib/distil/product.rb +90 -76
  20. data/lib/distil/project.rb +370 -104
  21. data/lib/distil/recursive-http-fetcher.rb +72 -0
  22. data/lib/distil/server.rb +43 -0
  23. data/lib/distil/source-file/css-file.rb +56 -3
  24. data/lib/distil/source-file/html-file.rb +5 -6
  25. data/lib/distil/source-file/javascript-file.rb +96 -8
  26. data/lib/distil/source-file/json-file.rb +2 -4
  27. data/lib/distil/source-file/yui-minifiable-file.rb +19 -0
  28. data/lib/distil/source-file.rb +50 -92
  29. data/lib/distil/subclass-tracker.rb +13 -0
  30. data/lib/distil.rb +21 -37
  31. metadata +40 -39
  32. data/assets/mime.types +0 -1240
  33. data/lib/distil/configurable/file-set.rb +0 -85
  34. data/lib/distil/configurable/interpolated.rb +0 -36
  35. data/lib/distil/configurable/output-path.rb +0 -25
  36. data/lib/distil/configurable/project-path.rb +0 -25
  37. data/lib/distil/product/concatenated.rb +0 -83
  38. data/lib/distil/product/debug.rb +0 -32
  39. data/lib/distil/product/javascript-base-product.rb +0 -35
  40. data/lib/distil/product/javascript-doc-product.rb +0 -61
  41. data/lib/distil/product/minified.rb +0 -41
  42. data/lib/distil/product/page-product.rb +0 -27
  43. data/lib/distil/product/pdoc-product.rb +0 -42
  44. data/lib/distil/project/distil-project.rb +0 -157
  45. data/lib/distil/project/external-project.rb +0 -58
  46. data/lib/distil/project/remote-project.rb +0 -43
  47. data/lib/distil/target.rb +0 -251
  48. data/lib/distil/task/css-dependency-task.rb +0 -64
  49. data/lib/distil/task/jsl-dependency-task.rb +0 -50
  50. data/lib/distil/task/nib-task.rb +0 -72
  51. data/lib/distil/task.rb +0 -50
  52. data/lib/jsdoc.conf +0 -18
  53. data/lib/test/HtmlTestReporter.js +0 -127
  54. data/lib/test/Test.js +0 -248
  55. data/lib/test/TestReporter.js +0 -79
  56. data/lib/test/TestRunner.js +0 -132
  57. data/lib/test/browser.rb +0 -97
  58. data/lib/test/scriptwrapper.html +0 -10
  59. data/lib/test/unittest.html +0 -127
data/Rakefile CHANGED
@@ -16,6 +16,7 @@ begin
16
16
  gemspec.add_dependency('json', '>= 1.4.3')
17
17
  gemspec.add_dependency('rubyzip', '>=0.9.4')
18
18
  gemspec.add_dependency('treetop', '>=1.4.8')
19
+ gemspec.add_dependency('directory_watcher', [">= 1.1.1"])
19
20
  end
20
21
 
21
22
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.6
1
+ 0.14.0.b
data/assets/distil.js CHANGED
@@ -153,7 +153,7 @@
153
153
  return {
154
154
  type: type,
155
155
  url: url,
156
- callback: callback,
156
+ callbacks: callback ? [callback]: [],
157
157
  scope: scope,
158
158
  userData: userData,
159
159
  loadQueue: [],
@@ -217,8 +217,8 @@
217
217
  }
218
218
 
219
219
  resource.callbacksExecuted= true;
220
- if (resource.callback)
221
- resource.callback.call(resource.scope, resource.userData);
220
+ while (resource.callbacks.length)
221
+ (resource.callbacks.shift()).call(resource.scope, resource.userData);
222
222
 
223
223
  resource= resource.parent;
224
224
  }
@@ -332,7 +332,7 @@
332
332
  if (rootResource.callbacksExecuted)
333
333
  window.setTimeout(callback, 0);
334
334
  else
335
- rootResource.callback= callback;
335
+ rootResource.callbacks.push(callback);
336
336
  }
337
337
 
338
338
  distil.complete= function(name)
@@ -373,15 +373,17 @@
373
373
  injectionComplete(currentResource);
374
374
  }
375
375
 
376
- distil.kick= function()
376
+ distil.moduleDidLoad= function(moduleName)
377
377
  {
378
378
  if (rootResource===currentResource)
379
379
  injectionComplete(currentResource);
380
380
  }
381
381
 
382
+ distil.kick= distil.moduleDidLoad;
383
+
382
384
  distil.urlForAssetWithNameInModule= function(asset, moduleName)
383
385
  {
384
- var module= moduleName ? moduleIndex[moduleName] : distil.mainModule;
386
+ var module= name ? moduleIndex[moduleName] : distil.mainModule;
385
387
  if (!module)
386
388
  throw new Error(NO_MODULE_ERROR + moduleName);
387
389
  if (!module.asset_map)
@@ -391,7 +393,7 @@
391
393
 
392
394
  distil.dataForAssetWithNameInModule= function(asset, moduleName)
393
395
  {
394
- var module= moduleName ? moduleIndex[moduleName] : distil.mainModule;
396
+ var module= name ? moduleIndex[moduleName] : distil.mainModule;
395
397
  if (!module)
396
398
  throw new Error(NO_MODULE_ERROR + moduleName);
397
399
  if (!module.assets)
data/bin/distil CHANGED
@@ -1,78 +1,54 @@
1
1
  #!/usr/bin/env ruby
2
+
2
3
  module Distil
3
-
4
+
4
5
  LIB_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
5
6
  VENDOR_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "vendor"))
6
7
  ASSETS_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "assets"))
7
8
  APP_NAME= File.basename($0)
8
-
9
+ APP_SCRIPT= $0
10
+
9
11
  $:.unshift(LIB_DIR)
10
12
 
11
- end
12
-
13
- require "distil"
13
+ require 'distil'
14
14
 
15
- arg_settings= {}
16
- project_file= nil
17
- args= []
15
+ help = <<-HELP
16
+ Distil is a tool for building HTML applications from its component CSS & Javascript files.
18
17
 
19
- ARGV.each { |v|
20
- if (!v[/^-/])
21
- args << v
22
- next
23
- end
24
-
25
- v= v.gsub(/^-+/, '')
26
-
27
- key,value= v.split("=")
28
- key.gsub!("-", "_")
29
-
30
- value=true if !value
31
-
32
- if ("f"==key || "file"==key || "buildfile"==key)
33
- project_file= value
34
- next
35
- end
18
+ HELP
36
19
 
37
- arg_settings[key]= value
38
- }
20
+ require 'optparse'
39
21
 
40
- def find_project_file(dir=nil)
41
- dir ||= Dir.pwd
22
+ options = {}
23
+ opts = OptionParser.new do |opts|
24
+ opts.banner = help
42
25
 
43
- immediate_projects= Dir.glob(File.join(dir, "*.jsproj"))
44
- if (!immediate_projects.empty? && 1==immediate_projects.length)
45
- return immediate_projects[0]
26
+ opts.on("--server [PORT]", "Start web server (default port 8888)") do |port|
27
+ options['server'] = true
28
+ options['server_port'] = port unless port.nil?
29
+ end
30
+
31
+ opts.on("--base URL", "The base path for the server") do |url|
32
+ options['url']= url
33
+ end
46
34
  end
35
+ opts.parse!
47
36
 
48
- while dir.length > 1
49
- Dir.glob(File.join(dir, '*.jsproj')) { |file|
50
- return file if File.basename(dir)===File.basename(file, '.jsproj')
51
- }
52
- dir = File.dirname(dir)
37
+ project= Project.find(Dir.pwd)
38
+ unless project
39
+ puts "#{APP_NAME}: Could not find project to build"
40
+ exit 1
53
41
  end
54
42
 
43
+ puts "\n#{project.name}:\n\n"
44
+ commands= ARGV.empty? ? ['build'] : ARGV
45
+ commands.each { |cmd|
46
+ project.send cmd
47
+ }
48
+ project.report
49
+
50
+ if true==options['server']
51
+ start_server(project, options)
52
+ end
53
+
55
54
  end
56
-
57
-
58
- # Change working directory to the folder containing the build YML file.
59
- project_file||= find_project_file
60
-
61
- if !project_file
62
- puts "#{Distil::APP_NAME}: can't find project file"
63
- exit
64
- end
65
-
66
- Dir.chdir(File.dirname(project_file))
67
-
68
- project= Distil::DistilProject.new(project_file, arg_settings)
69
-
70
- if 0==args.length
71
- args << "build"
72
- end
73
-
74
- args.each { |cmd|
75
- project.send cmd
76
- exit 1 if project.total_error_count > 0
77
- exit 1 if project.warnings_are_errors && project.total_warning_count > 0
78
- }
data/distil.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{distil}
8
- s.version = "0.13.6"
8
+ s.version = "0.14.0.b"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Watkins"]
12
- s.date = %q{2010-12-05}
12
+ s.date = %q{2010-12-21}
13
13
  s.default_executable = %q{distil}
14
14
  s.description = %q{A build tool for Javascript and CSS that takes advantage of best-of-breed helper applications Javascript Lint and JSDoc Toolkit}
15
15
  s.executables = ["distil"]
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
19
19
  "Rakefile",
20
20
  "VERSION",
21
21
  "assets/distil.js",
22
- "assets/mime.types",
23
22
  "bin/distil",
24
23
  "bin/distil-old",
25
24
  "distil.gemspec",
@@ -27,45 +26,28 @@ Gem::Specification.new do |s|
27
26
  "lib/distil.rb",
28
27
  "lib/distil/browser.rb",
29
28
  "lib/distil/configurable.rb",
30
- "lib/distil/configurable/file-set.rb",
31
- "lib/distil/configurable/interpolated.rb",
32
- "lib/distil/configurable/output-path.rb",
33
- "lib/distil/configurable/project-path.rb",
34
29
  "lib/distil/error-reporter.rb",
30
+ "lib/distil/file-vendor.rb",
31
+ "lib/distil/hash-additions.rb",
32
+ "lib/distil/javascript-code.rb",
33
+ "lib/distil/javascript-file-validator.rb",
34
+ "lib/distil/library.rb",
35
35
  "lib/distil/product.rb",
36
- "lib/distil/product/concatenated.rb",
36
+ "lib/distil/product/cache-manifest-product.rb",
37
37
  "lib/distil/product/css-product.rb",
38
- "lib/distil/product/debug.rb",
39
- "lib/distil/product/javascript-base-product.rb",
40
- "lib/distil/product/javascript-doc-product.rb",
38
+ "lib/distil/product/html-product.rb",
41
39
  "lib/distil/product/javascript-product.rb",
42
- "lib/distil/product/minified.rb",
43
- "lib/distil/product/page-product.rb",
44
- "lib/distil/product/pdoc-product.rb",
45
40
  "lib/distil/project.rb",
46
- "lib/distil/project/distil-project.rb",
47
- "lib/distil/project/external-project.rb",
48
- "lib/distil/project/remote-project.rb",
41
+ "lib/distil/recursive-http-fetcher.rb",
42
+ "lib/distil/server.rb",
49
43
  "lib/distil/source-file.rb",
50
44
  "lib/distil/source-file/css-file.rb",
51
45
  "lib/distil/source-file/html-file.rb",
52
46
  "lib/distil/source-file/javascript-file.rb",
53
47
  "lib/distil/source-file/json-file.rb",
54
- "lib/distil/target.rb",
55
- "lib/distil/task.rb",
56
- "lib/distil/task/css-dependency-task.rb",
57
- "lib/distil/task/jsl-dependency-task.rb",
58
- "lib/distil/task/nib-task.rb",
59
- "lib/distil/task/validate-js-task.rb",
60
- "lib/jsdoc.conf",
48
+ "lib/distil/source-file/yui-minifiable-file.rb",
49
+ "lib/distil/subclass-tracker.rb",
61
50
  "lib/jsl.conf",
62
- "lib/test/HtmlTestReporter.js",
63
- "lib/test/Test.js",
64
- "lib/test/TestReporter.js",
65
- "lib/test/TestRunner.js",
66
- "lib/test/browser.rb",
67
- "lib/test/scriptwrapper.html",
68
- "lib/test/unittest.html",
69
51
  "vendor/Makefile",
70
52
  "vendor/extconf.rb",
71
53
  "vendor/jsdoc-extras/plugins/distil-plugin.js",
@@ -778,15 +760,18 @@ Gem::Specification.new do |s|
778
760
  s.add_runtime_dependency(%q<json>, [">= 1.4.3"])
779
761
  s.add_runtime_dependency(%q<rubyzip>, [">= 0.9.4"])
780
762
  s.add_runtime_dependency(%q<treetop>, [">= 1.4.8"])
763
+ s.add_runtime_dependency(%q<directory_watcher>, [">= 1.1.1"])
781
764
  else
782
765
  s.add_dependency(%q<json>, [">= 1.4.3"])
783
766
  s.add_dependency(%q<rubyzip>, [">= 0.9.4"])
784
767
  s.add_dependency(%q<treetop>, [">= 1.4.8"])
768
+ s.add_dependency(%q<directory_watcher>, [">= 1.1.1"])
785
769
  end
786
770
  else
787
771
  s.add_dependency(%q<json>, [">= 1.4.3"])
788
772
  s.add_dependency(%q<rubyzip>, [">= 0.9.4"])
789
773
  s.add_dependency(%q<treetop>, [">= 1.4.8"])
774
+ s.add_dependency(%q<directory_watcher>, [">= 1.1.1"])
790
775
  end
791
776
  end
792
777
 
data/distil.tmproj CHANGED
@@ -3,7 +3,7 @@
3
3
  <plist version="1.0">
4
4
  <dict>
5
5
  <key>currentDocument</key>
6
- <string>Rakefile</string>
6
+ <string>lib/distil/source-file.rb</string>
7
7
  <key>documents</key>
8
8
  <array>
9
9
  <dict>
@@ -21,58 +21,89 @@
21
21
  <integer>270</integer>
22
22
  <key>metaData</key>
23
23
  <dict>
24
- <key>Rakefile</key>
24
+ <key>lib/distil/product.rb</key>
25
25
  <dict>
26
26
  <key>caret</key>
27
27
  <dict>
28
28
  <key>column</key>
29
- <integer>48</integer>
29
+ <integer>0</integer>
30
30
  <key>line</key>
31
- <integer>17</integer>
31
+ <integer>57</integer>
32
32
  </dict>
33
33
  <key>firstVisibleColumn</key>
34
34
  <integer>0</integer>
35
35
  <key>firstVisibleLine</key>
36
- <integer>0</integer>
36
+ <integer>42</integer>
37
37
  </dict>
38
- <key>lib/distil/product.rb</key>
38
+ <key>lib/distil/product/javascript-product.rb</key>
39
39
  <dict>
40
40
  <key>caret</key>
41
41
  <dict>
42
42
  <key>column</key>
43
- <integer>25</integer>
43
+ <integer>47</integer>
44
44
  <key>line</key>
45
- <integer>106</integer>
45
+ <integer>40</integer>
46
46
  </dict>
47
+ <key>columnSelection</key>
48
+ <false/>
47
49
  <key>firstVisibleColumn</key>
48
50
  <integer>0</integer>
49
51
  <key>firstVisibleLine</key>
50
- <integer>65</integer>
52
+ <integer>20</integer>
53
+ <key>selectFrom</key>
54
+ <dict>
55
+ <key>column</key>
56
+ <integer>34</integer>
57
+ <key>line</key>
58
+ <integer>40</integer>
59
+ </dict>
60
+ <key>selectTo</key>
61
+ <dict>
62
+ <key>column</key>
63
+ <integer>58</integer>
64
+ <key>line</key>
65
+ <integer>40</integer>
66
+ </dict>
51
67
  </dict>
52
- <key>lib/distil/product/pdoc-product.rb</key>
68
+ <key>lib/distil/project.rb</key>
53
69
  <dict>
54
70
  <key>caret</key>
55
71
  <dict>
56
72
  <key>column</key>
57
- <integer>10</integer>
73
+ <integer>32</integer>
58
74
  <key>line</key>
59
- <integer>2</integer>
75
+ <integer>220</integer>
60
76
  </dict>
61
77
  <key>firstVisibleColumn</key>
62
78
  <integer>0</integer>
63
79
  <key>firstVisibleLine</key>
80
+ <integer>195</integer>
81
+ </dict>
82
+ <key>lib/distil/source-file.rb</key>
83
+ <dict>
84
+ <key>caret</key>
85
+ <dict>
86
+ <key>column</key>
87
+ <integer>13</integer>
88
+ <key>line</key>
89
+ <integer>30</integer>
90
+ </dict>
91
+ <key>firstVisibleColumn</key>
64
92
  <integer>0</integer>
93
+ <key>firstVisibleLine</key>
94
+ <integer>10</integer>
65
95
  </dict>
66
96
  </dict>
67
97
  <key>openDocuments</key>
68
98
  <array>
69
- <string>Rakefile</string>
99
+ <string>lib/distil/project.rb</string>
100
+ <string>lib/distil/source-file.rb</string>
101
+ <string>lib/distil/product/javascript-product.rb</string>
70
102
  <string>lib/distil/product.rb</string>
71
- <string>lib/distil/product/pdoc-product.rb</string>
72
103
  </array>
73
104
  <key>showFileHierarchyDrawer</key>
74
105
  <false/>
75
106
  <key>windowFrame</key>
76
- <string>{{831, 300}, {1089, 878}}</string>
107
+ <string>{{833, 300}, {1087, 878}}</string>
77
108
  </dict>
78
109
  </plist>
@@ -1,34 +1,38 @@
1
- class Browser
2
- def supported?; true; end
3
- def setup ; end
4
- def open(url) ; end
5
- def teardown ; end
1
+ module Distil
2
+
3
+ class Browser
4
+ def supported?; true; end
5
+ def setup ; end
6
+ def open(url) ; end
7
+ def teardown ; end
6
8
 
7
- def host
8
- require 'rbconfig'
9
- Config::CONFIG['host']
10
- end
9
+ def host
10
+ require 'rbconfig'
11
+ Config::CONFIG['host']
12
+ end
11
13
 
12
- def macos?
13
- host.include?('darwin')
14
- end
14
+ def macos?
15
+ host.include?('darwin')
16
+ end
15
17
 
16
- def windows?
17
- host.include?('mswin')
18
- end
18
+ def windows?
19
+ host.include?('mswin')
20
+ end
19
21
 
20
- def linux?
21
- host.include?('linux')
22
- end
22
+ def linux?
23
+ host.include?('linux')
24
+ end
23
25
 
24
- def open(url)
25
- case
26
- when macos?
27
- `open #{url}`
28
- when windows?
29
- `start #{url}`
30
- else
31
- puts "I don't know how to open a browser for #{url} on your system"
26
+ def open(url)
27
+ case
28
+ when macos?
29
+ `open #{url}`
30
+ when windows?
31
+ `start #{url}`
32
+ else
33
+ puts "I don't know how to open a browser for #{url} on your system"
34
+ end
32
35
  end
33
36
  end
37
+
34
38
  end