distil 0.10.4 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/Rakefile +2 -1
  2. data/VERSION +1 -1
  3. data/assets/distil.js +359 -0
  4. data/bin/distil +33 -10
  5. data/distil.gemspec +35 -24
  6. data/lib/distil/configurable/file-set.rb +86 -0
  7. data/lib/distil/configurable/interpolated.rb +36 -0
  8. data/lib/distil/configurable/output-path.rb +25 -0
  9. data/lib/distil/configurable/project-path.rb +25 -0
  10. data/lib/distil/configurable.rb +164 -0
  11. data/lib/distil/error-reporter.rb +63 -0
  12. data/lib/distil/product/concatenated.rb +85 -0
  13. data/lib/distil/product/css-product.rb +37 -0
  14. data/lib/distil/product/debug.rb +34 -0
  15. data/lib/distil/product/javascript-base-product.rb +35 -0
  16. data/lib/distil/product/javascript-doc-product.rb +61 -0
  17. data/lib/distil/product/javascript-product.rb +131 -0
  18. data/lib/distil/product/minified.rb +32 -0
  19. data/lib/distil/product.rb +97 -0
  20. data/lib/distil/project/distil-project.rb +99 -0
  21. data/lib/distil/project/external-project.rb +53 -0
  22. data/lib/distil/project.rb +78 -0
  23. data/lib/distil/source-file/css-file.rb +14 -0
  24. data/lib/distil/source-file/html-file.rb +14 -0
  25. data/lib/distil/source-file/javascript-file.rb +17 -0
  26. data/lib/distil/source-file/json-file.rb +16 -0
  27. data/lib/distil/source-file.rb +172 -0
  28. data/lib/distil/target.rb +235 -0
  29. data/lib/distil/task/css-dependency-task.rb +64 -0
  30. data/lib/distil/task/jsl-dependency-task.rb +49 -0
  31. data/lib/distil/task/nib-task.rb +72 -0
  32. data/lib/distil/task/validate-js-task.rb +75 -0
  33. data/lib/distil/task.rb +50 -0
  34. data/lib/distil.rb +72 -0
  35. data/lib/jsl.conf +4 -0
  36. data/vendor/jsl-0.3.0/src/Makefile.ref +16 -6
  37. data/vendor/jsl-0.3.0/src/config.mk +32 -2
  38. data/vendor/jsl-0.3.0/src/fdlibm/Makefile.ref +1 -2
  39. data/vendor/jsl-0.3.0/src/jsl.c +124 -13
  40. data/vendor/jsl-0.3.0/src/rules.mk +2 -1
  41. metadata +49 -28
  42. data/lib/bootstrap-template.js +0 -58
  43. data/lib/configurable.rb +0 -161
  44. data/lib/file-set.rb +0 -49
  45. data/lib/file-types/css-file.rb +0 -12
  46. data/lib/file-types/html-file.rb +0 -11
  47. data/lib/file-types/javascript-file.rb +0 -24
  48. data/lib/file-types/json-file.rb +0 -17
  49. data/lib/filter.rb +0 -41
  50. data/lib/filters/css-filter.rb +0 -58
  51. data/lib/filters/file-reference-filter.rb +0 -30
  52. data/lib/filters/jsl-dependency-filter.rb +0 -44
  53. data/lib/project.rb +0 -174
  54. data/lib/source-file.rb +0 -197
  55. data/lib/target.rb +0 -102
  56. data/lib/task.rb +0 -212
  57. data/lib/tasks/copy-task.rb +0 -17
  58. data/lib/tasks/css-task.rb +0 -12
  59. data/lib/tasks/javascript-task.rb +0 -206
  60. data/lib/tasks/multiple-output-task.rb +0 -140
  61. data/lib/tasks/output-task.rb +0 -76
  62. data/lib/tasks/single-output-task.rb +0 -104
  63. data/lib/tasks/test-task.rb +0 -280
data/Rakefile CHANGED
@@ -9,10 +9,11 @@ begin
9
9
  gemspec.summary= "A build tool for Javascript and CSS that takes advantage of best-of-breed helper applications Javascript Lint and JSDoc Toolkit"
10
10
  gemspec.homepage= "http://code.google.com/p/distil-js/"
11
11
  gemspec.description= gemspec.summary
12
- gemspec.files= Dir['lib/**/*', 'bin/*', '[A-Za-z]*', 'vendor/**/*']
12
+ gemspec.files= Dir['assets/*', 'lib/**/*', 'bin/*', '[A-Za-z]*', 'vendor/**/*']
13
13
  gemspec.files.reject! { |f| File.directory?(f) }
14
14
  gemspec.executables= ['distil']
15
15
  gemspec.extensions= ['vendor/extconf.rb']
16
+ gemspec.add_dependency('json', '>= 1.4.3')
16
17
  end
17
18
 
18
19
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.4
1
+ 0.11.0
data/assets/distil.js ADDED
@@ -0,0 +1,359 @@
1
+ /*jsl:declare distil*/
2
+
3
+ /** A resource module defined in the module that provides the module.
4
+ */
5
+
6
+ (function(distil, window, document){
7
+
8
+ var moduleIndex= {};
9
+ var fetched= {};
10
+ var root= document.documentElement;
11
+ var head= document.getElementsByTagName('head')[0]||root;
12
+
13
+ var XHR= window.XMLHttpRequest || (function(){
14
+ var progIdCandidates= ['Msxml2.XMLHTTP.4.0', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP'];
15
+ var len= progIdCandidates.length;
16
+
17
+ var progId;
18
+ var xhr;
19
+
20
+ function ConstructXhr()
21
+ {
22
+ return new window.ActiveXObject(ConstructXhr.progId);
23
+ }
24
+
25
+ while (len--)
26
+ {
27
+ try
28
+ {
29
+ progId= progIdCandidates[len];
30
+ xhr= new window.ActiveXObject(progId);
31
+ // ActiveXObject constructor throws an exception
32
+ // if the component isn't available.
33
+ xhr= null;
34
+ ConstructXhr.progId= progId;
35
+ return ConstructXhr;
36
+ }
37
+ catch (e)
38
+ {
39
+ // Ignore the error
40
+ }
41
+ }
42
+ throw new Error('No XMLHttpRequest implementation found');
43
+ })();
44
+
45
+ var noop= function(){};
46
+ var fetchAsset= function(url, callback, scope, userData)
47
+ {
48
+ if (url in fetched)
49
+ {
50
+ // The callback will ALWAYS be called after the calling program
51
+ // finishes executing.
52
+ window.setTimeout(function(){ callback.call(scope, userData); }, 0);
53
+ return;
54
+ }
55
+
56
+ var xhr= new XHR();
57
+ xhr.open('GET', url, true);
58
+
59
+ xhr.onreadystatechange= function()
60
+ {
61
+ if (4!==xhr.readyState)
62
+ return;
63
+ fetched[url]= true;
64
+ var status= xhr.status;
65
+ var succeeded= 0==status || (status>=200 && status<300) || 304==status;
66
+
67
+ if (!succeeded)
68
+ throw new Error('Failed to load resource: status=' + status + ' url=' + url);
69
+
70
+ callback.call(scope, userData);
71
+ xhr.onreadystatechange= noop;
72
+ xhr= null;
73
+ }
74
+ xhr.send(null);
75
+ };
76
+
77
+ var SCRIPT_TYPE= 'js';
78
+ var JSNIB_TYPE= 'jsnib';
79
+ var CSS_TYPE= 'css';
80
+ var MODULE_TYPE= 'module';
81
+ var NO_MODULE_ERROR= 'No module with name: ';
82
+
83
+ var injectScript= distil.injectScript= function(url, callback, scope, userData)
84
+ {
85
+ var tag= document.createElement('script');
86
+
87
+ var complete= function()
88
+ {
89
+ if (callback)
90
+ callback.call(scope, userData);
91
+ tag.onreadystatechage= noop;
92
+ tag= null;
93
+ };
94
+
95
+ window.__filename__= url;
96
+
97
+ tag.onreadystatechange= function()
98
+ {
99
+ var readyState= tag && tag.readyState;
100
+ if ('complete'===readyState || 'loaded'===readyState)
101
+ complete();
102
+ }
103
+ tag.onload= complete;
104
+ tag.type= "text/javascript";
105
+ tag.src= url;
106
+ root.insertBefore(tag, root.firstChild);
107
+ };
108
+
109
+ var injectStylesheet= distil.injectStylesheet= function(url, callback, scope, userData)
110
+ {
111
+ var link= document.createElement('link');
112
+ link.type='text/css';
113
+ link.rel='stylesheet';
114
+ link.href='url';
115
+ head.appendChild(link);
116
+
117
+ if (callback)
118
+ callback.call(scope, url, userData);
119
+ };
120
+
121
+ var getRunningScriptSource= function()
122
+ {
123
+ var scripts= document.getElementsByTagName("script");
124
+ if (!scripts || !scripts.length)
125
+ throw new Error("Could not find script");
126
+
127
+ var l= scripts.length;
128
+ var s, src, lastSlash;
129
+
130
+ while (l--)
131
+ {
132
+ if ((src= scripts[l].src))
133
+ return src;
134
+ }
135
+
136
+ throw new Error("No script tags with src attribute.");
137
+ };
138
+
139
+ var ResourceInfo= function(type, url, callback, scope, userData)
140
+ {
141
+ if (!type)
142
+ {
143
+ var lastDot= url.lastIndexOf('.');
144
+ type= (-1!==lastDot)?url.substring(lastDot+1):"";
145
+ type= type.split('?')[0];
146
+ }
147
+
148
+ var lastSlash= url.lastIndexOf('/');
149
+ if (-1===lastSlash)
150
+ throw new Error("Couldn't determine path from script src: " + url);
151
+
152
+ return {
153
+ type: type,
154
+ url: url,
155
+ callback: callback,
156
+ scope: scope,
157
+ userData: userData,
158
+ loadQueue: [],
159
+ fetched: false,
160
+ injected: false,
161
+ callbacksExecuted: false,
162
+ path: url.substring(0, lastSlash+1),
163
+ parent: null
164
+ };
165
+ };
166
+
167
+ var rootResource= ResourceInfo(SCRIPT_TYPE, getRunningScriptSource());
168
+ rootResource.fetched= true;
169
+ rootResource.injected= true;
170
+
171
+ /** currentResource is the resource that is currently executing.
172
+ */
173
+ var currentResource= rootResource;
174
+
175
+ var injectResource= function(resource)
176
+ {
177
+ resource.injected= true;
178
+ switch (resource.type)
179
+ {
180
+ case SCRIPT_TYPE:
181
+ case JSNIB_TYPE:
182
+ injectScript(resource.url, injectionComplete, null, resource);
183
+ break;
184
+ case CSS_TYPE:
185
+ injectStylesheet(resource.url, injectionComplete, null, resource);
186
+ break;
187
+ default:
188
+ throw new Error('Unknown resource type: ' + resource.type);
189
+ }
190
+ };
191
+
192
+ /** The execution complete callback for the script.
193
+ */
194
+ var injectionComplete= function(resource)
195
+ {
196
+ while (resource)
197
+ {
198
+ if (resource.loadQueue.length)
199
+ {
200
+ currentResource= resource= resource.loadQueue.shift();
201
+ resource.complete= true;
202
+ if (!resource.fetched)
203
+ return;
204
+ if (MODULE_TYPE===resource.type)
205
+ continue;
206
+ injectResource(resource);
207
+ return;
208
+ }
209
+
210
+ resource.callbacksExecuted= true;
211
+ if (resource.callback)
212
+ resource.callback.call(resource.scope, resource.userData);
213
+
214
+ resource= resource.parent;
215
+ }
216
+
217
+ currentResource= resource ? resource : rootResource;
218
+ };
219
+
220
+ var fetchComplete= function(resource)
221
+ {
222
+ resource.fetched= true;
223
+ var parent= resource.parent;
224
+
225
+ if (resource===currentResource)
226
+ injectResource(resource);
227
+ };
228
+
229
+ var loadResource= function(url, callback, scope, userData, parent)
230
+ {
231
+ if (distil.debug)
232
+ url+= '?'+(new Date()).valueOf();
233
+
234
+ var resource= ResourceInfo(null, url, callback, scope, userData);
235
+ parent= parent||currentResource;
236
+ resource.parent= parent;
237
+ parent.loadQueue.push(resource);
238
+ fetchAsset(url, fetchComplete, null, resource);
239
+ };
240
+
241
+ var loadFiles= function(module)
242
+ {
243
+ var files= (module.loadQueue||[]).concat(module.required);
244
+ var resource= module.resource;
245
+ var path= module.path;
246
+
247
+ for (var i=0, len=files.length; i<len; ++i)
248
+ loadResource(path + files[i], null, null, null, resource);
249
+ };
250
+
251
+ distil.module= function(name, def)
252
+ {
253
+ if (name in moduleIndex)
254
+ {
255
+ var module= moduleIndex[name];
256
+ for (var p in def)
257
+ module[p]= def[p];
258
+
259
+ distil.require(name);
260
+ return;
261
+ }
262
+
263
+ def.path= currentResource.path + def.folder;
264
+ if ('/'!==def.path.slice(-1))
265
+ def.path+='/';
266
+
267
+ def.callbacks= [];
268
+ def.loadQueue= [];
269
+
270
+ if (!distil.mainModule)
271
+ distil.mainModule= def;
272
+
273
+ moduleIndex[name]= def;
274
+ if (def.required && def.required.length)
275
+ distil.require(name);
276
+ };
277
+
278
+ distil.queue= function(name, fragment)
279
+ {
280
+ var module= moduleIndex[name];
281
+ if (module.resource)
282
+ loadResource(currentResource.path + fragment, null, null, null, module.resource);
283
+ else
284
+ module.loadQueue.push(fragment);
285
+ };
286
+
287
+ distil.onready= function(callback)
288
+ {
289
+ if (rootResource.callbacksExecuted)
290
+ window.setTimeout(callback, 0);
291
+ else
292
+ rootResource.callback= callback;
293
+ }
294
+
295
+ distil.complete= function(name)
296
+ {
297
+ var module= moduleIndex[name];
298
+ if (module.loadQueue.length)
299
+ distil.require(name);
300
+ }
301
+
302
+ distil.require= function(name, callback, scope, userData)
303
+ {
304
+ var module= moduleIndex[name];
305
+ if (!module)
306
+ throw new Error(NO_MODULE_ERROR + name);
307
+
308
+ var complete= function()
309
+ {
310
+ if (callback)
311
+ callback.call(scope, userData);
312
+ module.loaded= true;
313
+ module.resource= null;
314
+ };
315
+
316
+ if (module.loaded)
317
+ {
318
+ window.setTimeout(complete, 0);
319
+ return;
320
+ }
321
+
322
+ var resource= module.resource= ResourceInfo(MODULE_TYPE, module.path, complete);
323
+ resource.parent= currentResource;
324
+ resource.fetched= true;
325
+ currentResource.loadQueue.push(resource);
326
+
327
+ loadFiles(module);
328
+
329
+ if (rootResource===currentResource)
330
+ injectionComplete(currentResource);
331
+ }
332
+
333
+ distil.kick= function()
334
+ {
335
+ if (rootResource===currentResource)
336
+ injectionComplete(currentResource);
337
+ }
338
+
339
+ distil.urlForAssetWithNameInModule= function(asset, moduleName)
340
+ {
341
+ var module= name ? moduleIndex[moduleName] : distil.mainModule;
342
+ if (!module)
343
+ throw new Error(NO_MODULE_ERROR + moduleName);
344
+ if (!module.asset_map)
345
+ return module.path + asset;
346
+ return module.path + (module.asset_map[asset]||asset);
347
+ }
348
+
349
+ distil.dataForAssetWithNameInModule= function(asset, moduleName)
350
+ {
351
+ var module= name ? moduleIndex[moduleName] : distil.mainModule;
352
+ if (!module)
353
+ throw new Error(NO_MODULE_ERROR + moduleName);
354
+ if (!module.assets)
355
+ return null;
356
+ return module.assets[asset]||null;
357
+ }
358
+
359
+ })(window.distil={}, window, document);
data/bin/distil CHANGED
@@ -1,13 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $script_dir= File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
4
- $vendor_dir= File.expand_path(File.join(File.dirname(__FILE__), "..", "vendor"))
5
- $app_name= File.basename($0)
3
+ LIB_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
4
+ VENDOR_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "vendor"))
5
+ ASSETS_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "assets"))
6
+ APP_NAME= File.basename($0)
6
7
 
7
- require "#{$script_dir}/project"
8
+ $:.unshift(LIB_DIR)
9
+
10
+ require "distil"
8
11
 
9
12
  arg_settings= {}
10
- project_file= "distil.yml"
13
+ project_file= nil
11
14
  args= []
12
15
 
13
16
  ARGV.each { |v|
@@ -32,13 +35,33 @@ ARGV.each { |v|
32
35
  arg_settings[key]= value
33
36
  }
34
37
 
38
+ def find_project_file(dir=nil)
39
+ dir ||= Dir.pwd
40
+
41
+ while dir.length > 1
42
+ Dir.glob(File.join(dir, '*.jsproj')) { |file|
43
+ return file if File.basename(dir)===File.basename(file, '.jsproj')
44
+ }
45
+ dir = File.dirname(dir)
46
+ end
47
+
48
+ end
49
+
50
+
35
51
  # Change working directory to the folder containing the build YML file.
36
- project_file= File.expand_path(project_file)
52
+ project_file||= find_project_file
37
53
 
38
- if (!File.exists?(project_file))
39
- puts "#{$app_name}: can't find project file: #{project_file}"
54
+ if !project_file
55
+ puts "#{APP_NAME}: can't find project file"
40
56
  exit
41
57
  end
42
58
 
43
- project= Project.new(project_file, arg_settings)
44
- project.build
59
+ project= Distil::DistilProject.new(project_file, arg_settings)
60
+
61
+ if 0==args.length
62
+ args << "build"
63
+ end
64
+
65
+ args.each { |cmd|
66
+ project.send cmd
67
+ }
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.10.4"
8
+ s.version = "0.11.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Watkins"]
12
- s.date = %q{2010-05-05}
12
+ s.date = %q{2010-06-06}
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"]
@@ -17,32 +17,40 @@ Gem::Specification.new do |s|
17
17
  s.files = [
18
18
  "Rakefile",
19
19
  "VERSION",
20
+ "assets/distil.js",
20
21
  "bin/distil",
21
22
  "distil.gemspec",
22
- "lib/bootstrap-template.js",
23
- "lib/configurable.rb",
24
- "lib/file-set.rb",
25
- "lib/file-types/css-file.rb",
26
- "lib/file-types/html-file.rb",
27
- "lib/file-types/javascript-file.rb",
28
- "lib/file-types/json-file.rb",
29
- "lib/filter.rb",
30
- "lib/filters/css-filter.rb",
31
- "lib/filters/file-reference-filter.rb",
32
- "lib/filters/jsl-dependency-filter.rb",
23
+ "lib/distil.rb",
24
+ "lib/distil/configurable.rb",
25
+ "lib/distil/configurable/file-set.rb",
26
+ "lib/distil/configurable/interpolated.rb",
27
+ "lib/distil/configurable/output-path.rb",
28
+ "lib/distil/configurable/project-path.rb",
29
+ "lib/distil/error-reporter.rb",
30
+ "lib/distil/product.rb",
31
+ "lib/distil/product/concatenated.rb",
32
+ "lib/distil/product/css-product.rb",
33
+ "lib/distil/product/debug.rb",
34
+ "lib/distil/product/javascript-base-product.rb",
35
+ "lib/distil/product/javascript-doc-product.rb",
36
+ "lib/distil/product/javascript-product.rb",
37
+ "lib/distil/product/minified.rb",
38
+ "lib/distil/project.rb",
39
+ "lib/distil/project/distil-project.rb",
40
+ "lib/distil/project/external-project.rb",
41
+ "lib/distil/source-file.rb",
42
+ "lib/distil/source-file/css-file.rb",
43
+ "lib/distil/source-file/html-file.rb",
44
+ "lib/distil/source-file/javascript-file.rb",
45
+ "lib/distil/source-file/json-file.rb",
46
+ "lib/distil/target.rb",
47
+ "lib/distil/task.rb",
48
+ "lib/distil/task/css-dependency-task.rb",
49
+ "lib/distil/task/jsl-dependency-task.rb",
50
+ "lib/distil/task/nib-task.rb",
51
+ "lib/distil/task/validate-js-task.rb",
33
52
  "lib/jsdoc.conf",
34
53
  "lib/jsl.conf",
35
- "lib/project.rb",
36
- "lib/source-file.rb",
37
- "lib/target.rb",
38
- "lib/task.rb",
39
- "lib/tasks/copy-task.rb",
40
- "lib/tasks/css-task.rb",
41
- "lib/tasks/javascript-task.rb",
42
- "lib/tasks/multiple-output-task.rb",
43
- "lib/tasks/output-task.rb",
44
- "lib/tasks/single-output-task.rb",
45
- "lib/tasks/test-task.rb",
46
54
  "lib/test/HtmlTestReporter.js",
47
55
  "lib/test/Test.js",
48
56
  "lib/test/TestReporter.js",
@@ -588,9 +596,12 @@ Gem::Specification.new do |s|
588
596
  s.specification_version = 3
589
597
 
590
598
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
599
+ s.add_runtime_dependency(%q<json>, [">= 1.4.3"])
591
600
  else
601
+ s.add_dependency(%q<json>, [">= 1.4.3"])
592
602
  end
593
603
  else
604
+ s.add_dependency(%q<json>, [">= 1.4.3"])
594
605
  end
595
606
  end
596
607
 
@@ -0,0 +1,86 @@
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
+ puts "full_path=#{full_path}\nsource_folder=#{@owner.source_folder}"
73
+ error("Unable to locate file: #{file}")
74
+ return
75
+ end
76
+ return if (@files.include?(source_file))
77
+ @files << source_file
78
+ end
79
+
80
+ def each
81
+ files.each { |f| yield f }
82
+ end
83
+
84
+ end
85
+
86
+ end
@@ -0,0 +1,36 @@
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
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,25 @@
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