distil 0.8.2 → 0.8.4

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.2
1
+ 0.8.4
data/bin/distil CHANGED
@@ -41,5 +41,4 @@ if (!File.exists?(project_file))
41
41
  end
42
42
 
43
43
  project= Project.new(project_file, arg_settings)
44
- project.build_external_projects
45
- project.build_targets
44
+ project.build
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.8.2"
8
+ s.version = "0.8.4"
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-01-11}
12
+ s.date = %q{2010-01-17}
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"]
@@ -26,9 +26,7 @@ Gem::Specification.new do |s|
26
26
  "lib/file-types/html-file.rb",
27
27
  "lib/file-types/javascript-file.rb",
28
28
  "lib/file-types/json-file.rb",
29
- "lib/file-types/nib-file.rb",
30
29
  "lib/filter.rb",
31
- "lib/filters/coherent-asset-filter.rb",
32
30
  "lib/filters/css-filter.rb",
33
31
  "lib/filters/file-reference-filter.rb",
34
32
  "lib/filters/jsl-dependency-filter.rb",
@@ -42,7 +40,6 @@ Gem::Specification.new do |s|
42
40
  "lib/tasks/css-task.rb",
43
41
  "lib/tasks/javascript-task.rb",
44
42
  "lib/tasks/multiple-output-task.rb",
45
- "lib/tasks/nib-task.rb",
46
43
  "lib/tasks/output-task.rb",
47
44
  "lib/tasks/single-output-task.rb",
48
45
  "lib/tasks/test-task.rb",
@@ -14,7 +14,7 @@ class JavascriptFile < SourceFile
14
14
  def escape_embeded_content(content)
15
15
  content.gsub("\\", "\\\\").gsub("\n", "\\n").gsub("\"", "\\\"").gsub("'", "\\\\'")
16
16
  end
17
-
17
+
18
18
  def debug_content(options)
19
19
  destination= File.expand_path(options.remove_prefix||"")
20
20
  path= @file_path ? @file_path : self.relative_to_folder(destination)
@@ -6,6 +6,10 @@ class JsonFile < JavascriptFile
6
6
  ".json"
7
7
  end
8
8
 
9
+ def content_type
10
+ "js"
11
+ end
12
+
9
13
  def minify_content(source)
10
14
  super("(#{source})")[1..-3]
11
15
  end
data/lib/project.rb CHANGED
@@ -3,7 +3,8 @@ require "#{$script_dir}/target"
3
3
  require 'yaml'
4
4
 
5
5
  class Project < Configurable
6
-
6
+ attr_reader :project_file
7
+
7
8
  option :tasks, Array
8
9
  option_alias :tasks, :task
9
10
 
@@ -19,6 +20,12 @@ class Project < Configurable
19
20
 
20
21
  option :external_projects
21
22
 
23
+ option :distileries, Array
24
+ option_alias :distileries, :distilleries
25
+ option_alias :distileries, :distilery
26
+ option_alias :distileries, :distillery
27
+
28
+
22
29
  def initialize(project_file, settings)
23
30
  @@current= self
24
31
  @project_file= File.expand_path(project_file)
@@ -48,6 +55,29 @@ class Project < Configurable
48
55
  nil
49
56
  end
50
57
 
58
+ def build
59
+ load_distileries
60
+ build_external_projects
61
+ build_targets
62
+ end
63
+
64
+ def load_distileries
65
+ return if distileries.nil?
66
+
67
+ distileries.each { |d|
68
+ if (File.exists?(d))
69
+ require d
70
+ next
71
+ end
72
+ path= Gem.required_location(d, 'distilery.rb')
73
+ if (path.nil?)
74
+ puts "Missing distilery: #{d}"
75
+ end
76
+ next if path.nil?
77
+ require path
78
+ }
79
+ end
80
+
51
81
  def build_external_projects
52
82
  projects= external_projects
53
83
  if (projects.nil?)
data/lib/source-file.rb CHANGED
@@ -114,16 +114,9 @@ class SourceFile
114
114
  next if !f.handles_file(self)
115
115
  c= f.filter_content(self, c, options)
116
116
  }
117
- "#{c}\n"
117
+ c
118
118
  end
119
119
 
120
- def content_relative_to_destination(destination)
121
- content.gsub(/\{\{FILEREF\(([^)]*)\)\}\}/) { |match|
122
- file= SourceFile.from_path($1)
123
- file.relative_to_folder(destination)
124
- }
125
- end
126
-
127
120
  def debug_content(options)
128
121
  self.filtered_content(options)
129
122
  end
data/lib/target.rb CHANGED
@@ -18,6 +18,10 @@ class Target < Configurable
18
18
  @extras.each { |task_name, task_settings|
19
19
  next if (tasks && !tasks.include?(task_name))
20
20
  t= Task.by_name(task_name)
21
+ if (t.nil?)
22
+ error("Unknown task: #{task_name}")
23
+ next
24
+ end
21
25
  @tasks << t.new(self, task_settings)
22
26
  }
23
27
 
data/lib/task.rb CHANGED
@@ -117,6 +117,9 @@ class Task < Configurable
117
117
  }
118
118
  oldest_product_modification_time= product_modification_times.max
119
119
 
120
+ stat= File.stat(Project.current.project_file)
121
+ return (@need_to_build=true) if stat.mtime > oldest_product_modification_time
122
+
120
123
  @assets.each { |a|
121
124
  stat= File.stat(a)
122
125
  return (@need_to_build=true) if stat.mtime > oldest_product_modification_time
@@ -164,7 +167,6 @@ class Task < Configurable
164
167
 
165
168
  folders.sort!
166
169
  folders.each { |f|
167
- # puts "#{File.join(remove_prefix, f)} => #{File.join(output_folder, f)}"
168
170
  src_folder= remove_prefix ? File.join(remove_prefix, f) : f
169
171
  src_folder= SourceFile.path_relative_to_folder(File.expand_path(src_folder), output_folder)
170
172
 
@@ -172,8 +174,6 @@ class Task < Configurable
172
174
  next if File.exists?(target_folder)
173
175
  File.symlink src_folder, target_folder
174
176
  }
175
-
176
- # puts "#{task_name}: folder=#{folders.inspect}"
177
177
  end
178
178
 
179
179
  def copy_assets
@@ -189,51 +189,7 @@ class Task < Configurable
189
189
  symlink_assets
190
190
  end
191
191
  end
192
-
193
- def copy_assets_orig
194
- # puts "\nincluded:"
195
- # @included_files.each { |f| puts f.file_path }
196
- #
197
- # puts "\nordered:"
198
- # @ordered_files.each { |f| puts f.file_path }
199
- # puts "\nassets:"
200
- # assets.each { |a| puts a.file_path }
201
-
202
- folders= assets.map { |a|
203
- short_folder_name= File.dirname(a.file_path).split("/")[0]
204
- if ("."==short_folder_name)
205
- [a.file_path, a.relative_to_folder(output_folder)]
206
- else
207
- short_folder_regex= /.*\/#{Regexp.escape(short_folder_name)}\//
208
- # puts "#{a.file_path}: #{short_folder_regex.inspect}: #{a.relative_to_folder(@options.output_folder)}"
209
- relative_folder_name= (a.relative_to_folder(output_folder))[short_folder_regex]
210
- [short_folder_name, relative_folder_name]
211
- end
212
- }
213
- folders.compact!
214
- folders.uniq!
215
192
 
216
- # puts "\nfolders:"
217
- # folders.each { |f| puts f.inspect }
218
-
219
- folders.each { |f|
220
- target_folder= "#{output_folder}/#{f[0]}"
221
- FileUtils.rm target_folder if File.symlink?(target_folder)
222
- # FileUtils.rm_r target_folder if File.exists?(target_folder)
223
- }
224
-
225
- if ("release"==mode)
226
- assets.each { |a| a.copy_to(output_folder) }
227
- else
228
- folders.each { |f|
229
- # puts "#{f[0]}"
230
- target_folder= "#{output_folder}/#{f[0]}"
231
- source_folder= f[1]
232
- File.symlink source_folder, target_folder
233
- }
234
- end
235
- end
236
-
237
193
  def cleanup
238
194
  end
239
195
 
@@ -25,6 +25,7 @@ class JavascriptTask < SingleOutputTask
25
25
 
26
26
  def initialize(target, options)
27
27
  super(target, options)
28
+ @concatenation_join_string = "\n/*jsl:ignore*/;/*jsl:end*/\n"
28
29
 
29
30
  if (generate_docs)
30
31
  @products << File.join(doc_folder, "index.html")
@@ -96,7 +97,10 @@ class JavascriptTask < SingleOutputTask
96
97
  tmp= Tempfile.new("jsdoc.conf")
97
98
 
98
99
  template= File.read(@options.jsdoc_conf)
99
- doc_files= @included_files.map { |f| "\"#{f.file_path}\"" }
100
+ doc_files= @included_files.map { |f|
101
+ p= f.file_path || f.relative_to_folder(options.remove_prefix||"")
102
+ "\"#{p}\""
103
+ }
100
104
 
101
105
  conf= replace_tokens(template, {
102
106
  "DOC_FILES"=>doc_files.join(",\n"),
@@ -21,6 +21,8 @@ class MultipleOutputTask < OutputTask
21
21
 
22
22
  # @options.output_folder= prefix
23
23
  FileUtils.mkdir_p(output_folder)
24
+
25
+ @concatenation_join_string= ""
24
26
 
25
27
  @prefix= prefix
26
28
  @concat= Hash.new
@@ -53,9 +55,15 @@ class MultipleOutputTask < OutputTask
53
55
  next if @files_to_exclude.include?(depend)
54
56
 
55
57
  concat << depend.filtered_content(options)
58
+ if (!concat.empty?)
59
+ concat << @concatenation_join_string||""
60
+ end
56
61
  debug << depend.debug_content(options)
57
62
  }
58
63
 
64
+ if (!concat.empty?)
65
+ concat << @concatenation_join_string||""
66
+ end
59
67
  concat << file.filtered_content(options)
60
68
  debug << file.debug_content(options)
61
69
 
@@ -22,6 +22,7 @@ class SingleOutputTask < OutputTask
22
22
  @name_gz= "#{prefix}#{target_name}.#{type}.gz"
23
23
  @name_debug= "#{prefix}#{target_name}-debug.#{type}"
24
24
 
25
+ @concatenation_join_string= ""
25
26
  @products= [@name_concat, @name_min, @name_gz, @name_debug]
26
27
 
27
28
  @concat = ""
@@ -30,6 +31,9 @@ class SingleOutputTask < OutputTask
30
31
 
31
32
  def process_files
32
33
  @included_files.each { |f|
34
+ if (!@concat.empty?)
35
+ @concat << @concatenation_join_string||""
36
+ end
33
37
  @concat << f.filtered_content(options)
34
38
  @debug << f.debug_content(options)
35
39
  }
@@ -277,4 +277,8 @@ class TestTask < Task
277
277
  @server.shutdown
278
278
  end
279
279
 
280
+ def need_to_build
281
+ true
282
+ end
283
+
280
284
  end
data/lib/test/browser.rb CHANGED
@@ -33,7 +33,7 @@ class FirefoxBrowser < Browser
33
33
  end
34
34
 
35
35
  def visit(url)
36
- system("open -a \"Firefox 3.5.app\" '#{url}'") if macos?
36
+ system("open -a \"Firefox.app\" '#{url}'") if macos?
37
37
  system("#{@path} #{url}") if windows?
38
38
  system("firefox #{url}") if linux?
39
39
  end
@@ -98,6 +98,19 @@ JSDOC.PluginManager.registerPlugin("DistilPlugin", {
98
98
  onDocCommentSrc: function(comment)
99
99
  {
100
100
  var src = comment.src;
101
+ var _this= this;
102
+ // if (/@method\b/.test(src))
103
+ // print("Method: previous symbol=" + this.lastSymbol.name);
104
+
105
+ function addScope(match, methodName)
106
+ {
107
+ if (_this.lastSymbol)
108
+ methodName= _this.lastSymbol.alias + "#" + methodName;
109
+ var tag= "@name "+methodName + "\n@function\n@description";
110
+ print("Replacing: \""+match+"\" with \""+tag+"\"");
111
+ return tag;
112
+ }
113
+ src= src.replace(/@method\s+(\S+)/, addScope);
101
114
 
102
115
  var indent = "";
103
116
  var indentLen = 0;
@@ -7,7 +7,6 @@ JSDOC.PluginManager.registerPlugin("InterfacePlugin", {
7
7
  return;
8
8
  if (symbol.comment.getTag("interface").length)
9
9
  symbol.isInterface= true;
10
- symbol.implementedInterfaces= symbol.comment.getTag("implements");
11
10
  },
12
11
 
13
12
  onDocCommentTags: function(comment)
@@ -30,6 +29,9 @@ JSDOC.PluginManager.registerPlugin("InterfacePlugin", {
30
29
  case 'interface':
31
30
  tag.desc= tag.nibbleName(tag.desc);
32
31
  break;
32
+ case 'implements':
33
+ tag.desc= tag.nibbleName(tag.desc);
34
+ break;
33
35
  }
34
36
  }
35
37
 
@@ -70,16 +70,14 @@
70
70
  {+ancestors.join(" : ")+}.
71
71
  <p/>
72
72
  </if>
73
- <if test="data.implementedInterfaces.length">
74
- {!
75
- var implementedInterfaces= [];
76
-
77
- function linkToInterface(i)
78
- {
79
- return new Link.toSymbol(i);
80
- }
81
- implementedInterfaces= data.implementedInterfaces.map(linkToInterface);
82
- !}
73
+ {!
74
+ function linkToInterface(i)
75
+ {
76
+ return new Link().toSymbol(i.name);
77
+ }
78
+ var implementedInterfaces= data.comment.getTag("implements").map(linkToInterface);
79
+ !}
80
+ <if test="implementedInterfaces.length">
83
81
  <p>
84
82
  <span class="label">Conforms to</span>
85
83
  {+implementedInterfaces.join(", ")+}.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: distil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Watkins
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-11 00:00:00 -08:00
12
+ date: 2010-01-17 00:00:00 -08:00
13
13
  default_executable: distil
14
14
  dependencies: []
15
15
 
@@ -33,9 +33,7 @@ files:
33
33
  - lib/file-types/html-file.rb
34
34
  - lib/file-types/javascript-file.rb
35
35
  - lib/file-types/json-file.rb
36
- - lib/file-types/nib-file.rb
37
36
  - lib/filter.rb
38
- - lib/filters/coherent-asset-filter.rb
39
37
  - lib/filters/css-filter.rb
40
38
  - lib/filters/file-reference-filter.rb
41
39
  - lib/filters/jsl-dependency-filter.rb
@@ -49,7 +47,6 @@ files:
49
47
  - lib/tasks/css-task.rb
50
48
  - lib/tasks/javascript-task.rb
51
49
  - lib/tasks/multiple-output-task.rb
52
- - lib/tasks/nib-task.rb
53
50
  - lib/tasks/output-task.rb
54
51
  - lib/tasks/single-output-task.rb
55
52
  - lib/tasks/test-task.rb
@@ -1,13 +0,0 @@
1
- require "#{$script_dir}/file-types/javascript-file.rb"
2
-
3
- class NibFile < JavascriptFile
4
-
5
- def self.extension
6
- ".jsnib"
7
- end
8
-
9
- def content_type
10
- "js"
11
- end
12
-
13
- end
@@ -1,65 +0,0 @@
1
- require "#{$script_dir}/filters/file-reference-filter"
2
-
3
- $include_regex= /NIB\.asset\(['"]([^)]+)['"]\)/
4
- $include_regex_old= /INC\(['"]([^)]+)['"]\)/
5
-
6
- class CoherentAssetFilter < FileReferenceFilter
7
-
8
- def handles_file(file)
9
- return [".js"].include?(file.extension)
10
- end
11
-
12
- def preprocess_content(file, content)
13
- content= content.split("\n")
14
-
15
- line_num=0
16
-
17
- content.each { |line|
18
-
19
- line_num+=1
20
-
21
- line.gsub!($include_regex) { |match|
22
-
23
- import_file= File.expand_path(File.join(file.parent_folder, $1))
24
-
25
- if (!File.exists?(import_file))
26
- file.error "Missing import file: #{$1}", line_num
27
- "NIB.asset('#{$1}')"
28
- else
29
- asset= SourceFile.from_path(import_file)
30
- file.add_asset(asset);
31
- if (file.can_embed_as_content(asset))
32
- "NIB.asset('#{file_reference(asset)}','#{content_reference(asset)}')"
33
- else
34
- "NIB.asset('#{file_reference(asset)}')"
35
- end
36
- end
37
-
38
- }
39
-
40
- line.gsub!($include_regex_old) { |match|
41
-
42
- import_file= File.expand_path(File.join(file.parent_folder, $1))
43
-
44
- if (!File.exists?(import_file))
45
- file.error "Missing import file: #{$1}", line_num
46
- "INC('#{$1}')"
47
- else
48
- asset= SourceFile.from_path(import_file)
49
- file.add_asset(asset);
50
- if (file.can_embed_as_content(asset))
51
- "INC('#{file_reference(asset)}','#{content_reference(asset)}')"
52
- else
53
- "INC('#{file_reference(asset)}')"
54
- end
55
- end
56
-
57
- }
58
-
59
- }
60
-
61
- content.join("\n")
62
- end
63
-
64
- end
65
-
@@ -1,83 +0,0 @@
1
- require "#{$script_dir}/tasks/multiple-output-task.rb"
2
- require "#{$script_dir}/tasks/javascript-task.rb"
3
-
4
- class NibTask < MultipleOutputTask
5
-
6
- def self.task_name
7
- "jsnib"
8
- end
9
-
10
- def source_type
11
- "js"
12
- end
13
-
14
- def output_type
15
- "jsnib"
16
- end
17
-
18
- # NibTask handles files that end in .jsnib
19
- def handles_file?(file_name)
20
- "#{file_name}"[/\.jsnib$/]
21
- end
22
-
23
- def validate_file(file)
24
-
25
- return if (!File.exists?($lint_command))
26
-
27
- tmp= Tempfile.new("jsl.conf")
28
-
29
- conf_files= [ "jsl.conf",
30
- "#{ENV['HOME']}/.jsl.conf",
31
- @options.jsl_conf
32
- ]
33
-
34
- jsl_conf= conf_files.find { |f| File.exists?(f) }
35
-
36
- tmp << File.read(jsl_conf)
37
- tmp << "\n"
38
-
39
- external_projects.each { |project|
40
- tmp << "+include #{project["include"]}\n"
41
- }
42
-
43
- file.dependencies.each { |f|
44
- tmp << "+process #{f}\n"
45
- }
46
-
47
- tmp << "+process #{file}\n"
48
-
49
- tmp.close()
50
-
51
- command= "#{$lint_command} -nologo -nofilelisting -conf #{tmp.path}"
52
-
53
- stdin, stdout, stderr= Open3.popen3(command)
54
- stdin.close
55
- output= stdout.read
56
- errors= stderr.read
57
-
58
- tmp.delete
59
-
60
- output= output.split("\n")
61
- summary= output.pop
62
- match= summary.match(/(\d+)\s+error\(s\), (\d+)\s+warning\(s\)/)
63
- if (match)
64
- @target.error_count+= match[1].to_i
65
- @target.warning_count+= match[2].to_i
66
- end
67
-
68
- output= output.join("\n")
69
-
70
- if (!output.empty?)
71
- puts output
72
- puts
73
- end
74
-
75
- end
76
-
77
- def validate_files
78
- @included_files.each { |f|
79
- validate_file(f)
80
- }
81
- end
82
-
83
- end