distil 0.14.0.d → 0.14.0.g

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ begin
11
11
  gemspec.description= gemspec.summary
12
12
  gemspec.files= Dir['assets/*', 'lib/**/*', 'bin/*', '[A-Za-z]*', 'vendor/**/*']
13
13
  gemspec.files.reject! { |f| File.directory?(f) }
14
- gemspec.executables= ['distil']
14
+ gemspec.executables= ['distil', 'jsl']
15
15
  gemspec.extensions= ['vendor/extconf.rb']
16
16
  gemspec.add_dependency('json', '>= 1.4.3')
17
17
  gemspec.add_dependency('rubyzip', '>=0.9.4')
data/VERSION CHANGED
@@ -1 +1,2 @@
1
- 0.14.0.d
1
+ 0.14.0.g
2
+
data/bin/distil CHANGED
@@ -60,15 +60,21 @@ module Distil
60
60
  if options[:output_path]
61
61
  project.output_path= options[:output_path]
62
62
  end
63
+
64
+ begin
65
+ commands= ARGV.empty? ? ['build'] : ARGV
66
+ commands.each { |cmd|
67
+ project.send cmd
68
+ }
63
69
 
64
- commands= ARGV.empty? ? ['build'] : ARGV
65
- commands.each { |cmd|
66
- project.send cmd
67
- }
68
- project.report
69
-
70
- if true==options['server']
71
- start_server(project, options)
70
+ project.report
71
+
72
+ if true==options['server']
73
+ start_server(project, options)
74
+ end
75
+ rescue BuildFailure
76
+ project.report
77
+ exit 1
72
78
  end
73
-
79
+
74
80
  end
data/bin/jsl ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
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
+ JSL_CONF= "#{LIB_DIR}/jsl.conf"
6
+ LINT_COMMAND= "#{VENDOR_DIR}/jsl-0.3.0/bin/jsl"
7
+
8
+ args= ARGV.map { |a| "\"#{a}\"" }
9
+ system("#{LINT_COMMAND} #{args.join(" ")}")
data/distil.gemspec CHANGED
@@ -5,14 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{distil}
8
- s.version = "0.14.0.d"
8
+ s.version = "0.14.0.g"
9
9
 
10
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-22}
13
- s.default_executable = %q{distil}
12
+ s.date = %q{2011-01-13}
14
13
  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
- s.executables = ["distil"]
14
+ s.executables = ["distil", "jsl"]
16
15
  s.extensions = ["vendor/extconf.rb"]
17
16
  s.files = [
18
17
  "Buildfile",
@@ -20,16 +19,18 @@ Gem::Specification.new do |s|
20
19
  "VERSION",
21
20
  "assets/distil.js",
22
21
  "bin/distil",
23
- "bin/distil-old",
22
+ "bin/jsl",
24
23
  "distil.gemspec",
25
24
  "distil.tmproj",
26
25
  "lib/distil.rb",
27
26
  "lib/distil/browser.rb",
27
+ "lib/distil/build-failure.rb",
28
28
  "lib/distil/configurable.rb",
29
29
  "lib/distil/error-reporter.rb",
30
30
  "lib/distil/file-vendor.rb",
31
31
  "lib/distil/hash-additions.rb",
32
32
  "lib/distil/javascript-code.rb",
33
+ "lib/distil/javascript-documentation-generator.rb",
33
34
  "lib/distil/javascript-file-validator.rb",
34
35
  "lib/distil/library.rb",
35
36
  "lib/distil/product.rb",
data/distil.tmproj CHANGED
@@ -3,7 +3,7 @@
3
3
  <plist version="1.0">
4
4
  <dict>
5
5
  <key>currentDocument</key>
6
- <string>lib/distil/product/javascript-product.rb</string>
6
+ <string>lib/jsl.conf</string>
7
7
  <key>documents</key>
8
8
  <array>
9
9
  <dict>
@@ -21,102 +21,165 @@
21
21
  <integer>270</integer>
22
22
  <key>metaData</key>
23
23
  <dict>
24
- <key>bin/distil</key>
24
+ <key>Rakefile</key>
25
25
  <dict>
26
26
  <key>caret</key>
27
27
  <dict>
28
28
  <key>column</key>
29
- <integer>0</integer>
29
+ <integer>39</integer>
30
30
  <key>line</key>
31
- <integer>38</integer>
31
+ <integer>13</integer>
32
32
  </dict>
33
33
  <key>firstVisibleColumn</key>
34
34
  <integer>0</integer>
35
35
  <key>firstVisibleLine</key>
36
36
  <integer>0</integer>
37
37
  </dict>
38
- <key>lib/distil/configurable.rb</key>
38
+ <key>VERSION</key>
39
39
  <dict>
40
40
  <key>caret</key>
41
41
  <dict>
42
42
  <key>column</key>
43
43
  <integer>0</integer>
44
44
  <key>line</key>
45
- <integer>0</integer>
45
+ <integer>1</integer>
46
46
  </dict>
47
47
  <key>firstVisibleColumn</key>
48
48
  <integer>0</integer>
49
49
  <key>firstVisibleLine</key>
50
- <integer>31</integer>
50
+ <integer>0</integer>
51
51
  </dict>
52
- <key>lib/distil/error-reporter.rb</key>
52
+ <key>bin/distil</key>
53
53
  <dict>
54
54
  <key>caret</key>
55
55
  <dict>
56
56
  <key>column</key>
57
57
  <integer>0</integer>
58
58
  <key>line</key>
59
+ <integer>6</integer>
60
+ </dict>
61
+ <key>columnSelection</key>
62
+ <false/>
63
+ <key>firstVisibleColumn</key>
64
+ <integer>0</integer>
65
+ <key>firstVisibleLine</key>
66
+ <integer>0</integer>
67
+ <key>selectFrom</key>
68
+ <dict>
69
+ <key>column</key>
70
+ <integer>0</integer>
71
+ <key>line</key>
72
+ <integer>4</integer>
73
+ </dict>
74
+ <key>selectTo</key>
75
+ <dict>
76
+ <key>column</key>
59
77
  <integer>0</integer>
78
+ <key>line</key>
79
+ <integer>6</integer>
80
+ </dict>
81
+ </dict>
82
+ <key>bin/jsl</key>
83
+ <dict>
84
+ <key>caret</key>
85
+ <dict>
86
+ <key>column</key>
87
+ <integer>30</integer>
88
+ <key>line</key>
89
+ <integer>8</integer>
60
90
  </dict>
61
91
  <key>firstVisibleColumn</key>
62
92
  <integer>0</integer>
63
93
  <key>firstVisibleLine</key>
64
- <integer>18</integer>
94
+ <integer>0</integer>
65
95
  </dict>
66
- <key>lib/distil/library.rb</key>
96
+ <key>lib/distil/error-reporter.rb</key>
67
97
  <dict>
68
98
  <key>caret</key>
69
99
  <dict>
70
100
  <key>column</key>
71
101
  <integer>0</integer>
72
102
  <key>line</key>
73
- <integer>205</integer>
103
+ <integer>0</integer>
74
104
  </dict>
75
105
  <key>firstVisibleColumn</key>
76
106
  <integer>0</integer>
77
107
  <key>firstVisibleLine</key>
78
- <integer>183</integer>
108
+ <integer>18</integer>
79
109
  </dict>
80
- <key>lib/distil/product/javascript-product.rb</key>
110
+ <key>lib/distil/javascript-file-validator.rb</key>
81
111
  <dict>
82
112
  <key>caret</key>
83
113
  <dict>
84
114
  <key>column</key>
85
- <integer>33</integer>
115
+ <integer>0</integer>
86
116
  <key>line</key>
87
- <integer>116</integer>
117
+ <integer>4</integer>
88
118
  </dict>
119
+ <key>columnSelection</key>
120
+ <false/>
89
121
  <key>firstVisibleColumn</key>
90
122
  <integer>0</integer>
91
123
  <key>firstVisibleLine</key>
92
- <integer>93</integer>
124
+ <integer>15</integer>
125
+ <key>selectFrom</key>
126
+ <dict>
127
+ <key>column</key>
128
+ <integer>0</integer>
129
+ <key>line</key>
130
+ <integer>2</integer>
131
+ </dict>
132
+ <key>selectTo</key>
133
+ <dict>
134
+ <key>column</key>
135
+ <integer>0</integer>
136
+ <key>line</key>
137
+ <integer>4</integer>
138
+ </dict>
93
139
  </dict>
94
- <key>lib/distil/server.rb</key>
140
+ <key>lib/jsl.conf</key>
95
141
  <dict>
96
142
  <key>caret</key>
97
143
  <dict>
98
144
  <key>column</key>
99
- <integer>84</integer>
145
+ <integer>0</integer>
100
146
  <key>line</key>
101
- <integer>13</integer>
147
+ <integer>65</integer>
102
148
  </dict>
149
+ <key>columnSelection</key>
150
+ <false/>
103
151
  <key>firstVisibleColumn</key>
104
152
  <integer>0</integer>
105
153
  <key>firstVisibleLine</key>
106
- <integer>0</integer>
154
+ <integer>55</integer>
155
+ <key>selectFrom</key>
156
+ <dict>
157
+ <key>column</key>
158
+ <integer>0</integer>
159
+ <key>line</key>
160
+ <integer>64</integer>
161
+ </dict>
162
+ <key>selectTo</key>
163
+ <dict>
164
+ <key>column</key>
165
+ <integer>0</integer>
166
+ <key>line</key>
167
+ <integer>65</integer>
168
+ </dict>
107
169
  </dict>
108
170
  </dict>
109
171
  <key>openDocuments</key>
110
172
  <array>
111
- <string>lib/distil/library.rb</string>
112
173
  <string>bin/distil</string>
113
- <string>lib/distil/product/javascript-product.rb</string>
114
- <string>lib/distil/server.rb</string>
115
- <string>lib/distil/configurable.rb</string>
174
+ <string>bin/jsl</string>
175
+ <string>VERSION</string>
176
+ <string>lib/jsl.conf</string>
177
+ <string>Rakefile</string>
178
+ <string>lib/distil/javascript-file-validator.rb</string>
116
179
  </array>
117
180
  <key>showFileHierarchyDrawer</key>
118
181
  <false/>
119
182
  <key>windowFrame</key>
120
- <string>{{833, 300}, {1087, 878}}</string>
183
+ <string>{{353, 0}, {1087, 878}}</string>
121
184
  </dict>
122
185
  </plist>
@@ -0,0 +1,4 @@
1
+ module Distil
2
+ class BuildFailure < StandardError
3
+ end
4
+ end
@@ -0,0 +1,49 @@
1
+ module Distil
2
+
3
+ DOC_COMMENT_REGEX= /(\/\*\*.*?)\*\//m
4
+ DOC_VALID_FLAGS= [:topic, :deprecated]
5
+
6
+ module JavascriptDocumentationGenerator
7
+
8
+ include ErrorReporter
9
+
10
+ def extract_doc_comments_from(file)
11
+ comments= []
12
+
13
+ file.content.scan(DOC_COMMENT_REGEX).each { |m|
14
+ lines= m[0].split
15
+ comment= {
16
+ :ebnf => lines[1],
17
+ :text => lines[2..-1].join("\n")
18
+ }
19
+
20
+ # Remove comment characters (otherwise, the string doesn't split
21
+ # correctly when the line after the comment is empty). Flags are a comma
22
+ # separated list of options for this comment.
23
+ flags= lines[0][3..-1]
24
+ flags.split(',').each { |flag|
25
+ key, value= flag.split(/\s*:\s*/)
26
+ if !DOC_VALID_FLAGS.include?(key.to_sym)
27
+ warning "Invalid documentation qualifier: #{key}", file
28
+ next
29
+ end
30
+ comment[key.to_sym]= case key.to_sym
31
+ when :topic
32
+ value
33
+ when :deprecated
34
+ true
35
+ end
36
+ }
37
+
38
+ # Add the comment to the collection
39
+ comments << comment
40
+ }
41
+
42
+ comments
43
+ end
44
+
45
+ def document_file(file)
46
+ comments= extract_doc_comments_from(file)
47
+ end
48
+
49
+ end
@@ -67,8 +67,10 @@ module Distil
67
67
  summary= output.pop
68
68
  match= summary.match(/(\d+)\s+error\(s\), (\d+)\s+warning\(s\)/)
69
69
  if (match)
70
- @@error_count+= match[1].to_i
71
- @@warning_count+= match[2].to_i
70
+ errors= match[1].to_i
71
+ warnings= match[2].to_i
72
+ @@error_count+= errors
73
+ @@warning_count+= warnings
72
74
  end
73
75
 
74
76
  output= output.join("\n")
@@ -78,7 +80,8 @@ module Distil
78
80
  puts
79
81
  end
80
82
 
81
- end
83
+ raise BuildFailure if errors>0 || warnings>0
84
+ end
82
85
  end
83
86
 
84
87
  end
@@ -2,8 +2,10 @@ module Distil
2
2
 
3
3
  BUILD_FILE= 'Buildfile'
4
4
  DEFAULT_OUTPUT_FOLDER= 'build'
5
+ DEFAULT_DOC_OUTPUT_FOLDER= 'doc'
5
6
  DEFAULT_LANGUAGE= 'en'
6
-
7
+ DEFAULT_DOC_FOLDER= 'doc'
8
+
7
9
  APPLICATION_TYPE= 'application'
8
10
  FRAMEWORK_TYPE= 'framework'
9
11
 
@@ -12,15 +14,18 @@ module Distil
12
14
  include FileVendor
13
15
  include JavascriptFileValidator
14
16
 
15
- attr_reader :name, :path, :folder, :source_folder, :output_path, :include_paths
17
+ attr_reader :name, :path, :folder, :source_path, :output_path, :include_paths
16
18
  attr_reader :assets, :asset_aliases
17
19
  attr_reader :libraries_by_name, :libraries
18
20
  attr_reader :languages, :project_type
19
21
  attr_reader :source_files
22
+ attr_reader :doc_output_path
20
23
  attr_reader :global_export
21
24
  attr_reader :additional_globals
22
25
  attr_reader :subprojects
23
26
  attr_reader :dependency_aliases
27
+ attr_reader :doc_src_path
28
+ attr_reader :doc_output_path
24
29
 
25
30
  alias_config_key :project_type, :type
26
31
 
@@ -60,8 +65,9 @@ module Distil
60
65
  @path= path
61
66
  @parent= parent
62
67
  @folder= File.dirname(@path)
63
- @source_folder= @folder
68
+ @source_path= File.expand_path(@folder)
64
69
  @output_path= File.join(@folder, DEFAULT_OUTPUT_FOLDER)
70
+ @doc_output_path= File.join(@folder, DEFAULT_DOC_OUTPUT_FOLDER)
65
71
  @include_paths= [@folder]
66
72
  @include_files= []
67
73
  @asset_aliases= {}
@@ -92,8 +98,12 @@ module Distil
92
98
  self.output_path= File.expand_path(output_folder)
93
99
  end
94
100
 
101
+ c.with :doc_folder do |doc_folder|
102
+ @doc_output_path= File.expand_path(doc_folder)
103
+ end
104
+
95
105
  c.with :source_folder do |source_folder|
96
- @source_folder= source_folder
106
+ @source_path= File.expand_path(source_folder)
97
107
  end
98
108
 
99
109
  c.with :export do |export|
@@ -109,10 +119,10 @@ module Distil
109
119
  @languages << language
110
120
  end
111
121
 
112
- c.with_each :require do |asset|
113
- asset= Library.new(asset, self)
114
- @libraries << asset
115
- @libraries_by_name[asset.name]= asset
122
+ c.with_each :require do |library|
123
+ library= Library.new(library, self)
124
+ @libraries << library
125
+ @libraries_by_name[library.name]= library
116
126
  end
117
127
 
118
128
  c.with :source do |source_files|
@@ -228,8 +238,15 @@ module Distil
228
238
 
229
239
  def relative_output_path_for(thing)
230
240
  return nil if !thing
231
- # puts "relative_output_path_for: #{thing} #{output_path}"
232
- Project.path_relative_to_folder(thing.is_a?(String) ? thing : thing.output_path, output_path)
241
+ thing_path= thing.is_a?(String) ? thing : thing.output_path
242
+ # puts "relative_output_path_for:"
243
+ # puts " output_path= #{thing_path}"
244
+ # unless thing.is_a?(String)
245
+ # puts " full_path= #{thing.full_path}"
246
+ # puts " relative_path= #{thing.relative_path}"
247
+ # puts " source_path= #{source_path}"
248
+ # end
249
+ Project.path_relative_to_folder(thing_path, output_path)
233
250
  end
234
251
 
235
252
  def notice_text
@@ -266,12 +283,14 @@ module Distil
266
283
  next if (a.full_path).starts_with?(output_path)
267
284
 
268
285
  path= relative_output_path_for(a)
269
-
286
+
270
287
  parts= File.dirname(path).split(File::SEPARATOR)
271
288
  if ('.'==parts[0])
289
+ source_path= a.path_relative_to(output_path)
272
290
  product_path= File.join(output_path, path)
291
+ file_path= a.path_relative_to(source_path)
273
292
  FileUtils.rm product_path if File.exists? product_path
274
- File.symlink path, product_path
293
+ File.symlink file_path, product_path
275
294
  next
276
295
  end
277
296
 
@@ -280,7 +299,7 @@ module Distil
280
299
 
281
300
  folders.each { |f|
282
301
  target= f
283
- source= relative_output_path_for(File.join(source_folder, f))
302
+ source= relative_output_path_for(File.join(source_path, f))
284
303
 
285
304
  FileUtils.rm target if File.symlink?(target)
286
305
  next if File.directory?(target)
@@ -291,12 +310,17 @@ module Distil
291
310
 
292
311
  def copy_assets
293
312
  assets.each { |a|
294
- a.copy_to(output_path, source_folder)
313
+ a.copy_to(output_path, source_path)
295
314
  }
296
315
  end
297
316
 
298
317
  def build_assets
299
318
  symlink_assets
319
+
320
+ if !@parent
321
+ FileUtils.cp(File.join(ASSETS_DIR, 'distil.js'), output_path)
322
+ end
323
+
300
324
  # if (RELEASE_MODE==mode)
301
325
  # copy_assets
302
326
  # else
@@ -326,7 +350,7 @@ module Distil
326
350
  end
327
351
 
328
352
  matches= glob(file)
329
- matches= glob(File.join(source_folder, file)) if matches.empty?
353
+ matches= glob(File.join(source_path, file)) if matches.empty?
330
354
 
331
355
  if (matches.empty?)
332
356
  error("No matching files found for: #{file}")
@@ -3,7 +3,7 @@ require 'fileutils'
3
3
  module Distil
4
4
 
5
5
  class SourceFile
6
- attr_reader :full_path, :project
6
+ attr_reader :full_path, :project, :dependencies
7
7
  attr_accessor :language, :is_asset
8
8
 
9
9
  class_attr :extension
@@ -14,6 +14,7 @@ module Distil
14
14
  def initialize(filepath, project)
15
15
  @full_path= File.expand_path(filepath)
16
16
  @project= project
17
+ @dependencies=[]
17
18
  project.cache_file(self)
18
19
  end
19
20
 
@@ -28,7 +29,7 @@ module Distil
28
29
  def output_path
29
30
  # SourceFiles get copied (or symlinked) into the output folder so that
30
31
  # their path is the same as that relative to the source folder
31
- @output_path||= File.join(project.output_path, relative_path)
32
+ @output_path ||= File.join(project.output_path, relative_path)
32
33
  end
33
34
 
34
35
  def relative_path
@@ -36,7 +37,7 @@ module Distil
36
37
  if full_path.starts_with?(project.output_path)
37
38
  @relative_path= Project.path_relative_to_folder(full_path, project.output_path)
38
39
  else
39
- @relative_path=Project.path_relative_to_folder(full_path, project.source_folder)
40
+ @relative_path=Project.path_relative_to_folder(full_path, project.source_path)
40
41
  end
41
42
  end
42
43
 
@@ -88,10 +89,6 @@ module Distil
88
89
  Project.path_relative_to_folder(@full_path, folder)
89
90
  end
90
91
 
91
- def dependencies
92
- @dependencies||=[]
93
- end
94
-
95
92
  def add_dependency(file)
96
93
  return if @dependencies.include?(file)
97
94
  @dependencies << file
@@ -107,11 +104,11 @@ module Distil
107
104
  end
108
105
 
109
106
  def copy_to(folder, prefix)
110
- file_path= self.file_path || relative_to_folder(prefix||"")
111
- final_target_folder= File.join(folder, File.dirname(file_path))
107
+ relative= path_relative_to_folder(prefix)
108
+ target_path= File.join(folder, relative)
112
109
  FileUtils.mkdir_p final_target_folder
113
- FileUtils.cp self.full_path, final_target_folder
114
- File.join(final_target_folder, File.basename(file_path))
110
+ FileUtils.cp self.full_path, File.dirname(target_path)
111
+ target_path
115
112
  end
116
113
 
117
114
  end
data/lib/distil.rb CHANGED
@@ -61,6 +61,7 @@ class String
61
61
  end
62
62
  end
63
63
 
64
+ require 'distil/build-failure'
64
65
  require 'distil/hash-additions'
65
66
  require 'distil/javascript-code'
66
67
  require 'distil/error-reporter'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: distil
3
3
  version: !ruby/object:Gem::Version
4
- hash: 89
4
+ hash: 84
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 14
9
9
  - 0
10
- - d
11
- version: 0.14.0.d
10
+ - g
11
+ version: 0.14.0.g
12
12
  platform: ruby
13
13
  authors:
14
14
  - Jeff Watkins
@@ -16,8 +16,8 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-12-22 00:00:00 -08:00
20
- default_executable: distil
19
+ date: 2011-01-13 00:00:00 -08:00
20
+ default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: json
@@ -87,6 +87,7 @@ description: A build tool for Javascript and CSS that takes advantage of best-of
87
87
  email:
88
88
  executables:
89
89
  - distil
90
+ - jsl
90
91
  extensions:
91
92
  - vendor/extconf.rb
92
93
  extra_rdoc_files: []
@@ -97,16 +98,18 @@ files:
97
98
  - VERSION
98
99
  - assets/distil.js
99
100
  - bin/distil
100
- - bin/distil-old
101
+ - bin/jsl
101
102
  - distil.gemspec
102
103
  - distil.tmproj
103
104
  - lib/distil.rb
104
105
  - lib/distil/browser.rb
106
+ - lib/distil/build-failure.rb
105
107
  - lib/distil/configurable.rb
106
108
  - lib/distil/error-reporter.rb
107
109
  - lib/distil/file-vendor.rb
108
110
  - lib/distil/hash-additions.rb
109
111
  - lib/distil/javascript-code.rb
112
+ - lib/distil/javascript-documentation-generator.rb
110
113
  - lib/distil/javascript-file-validator.rb
111
114
  - lib/distil/library.rb
112
115
  - lib/distil/product.rb
data/bin/distil-old DELETED
@@ -1,78 +0,0 @@
1
- #!/usr/bin/env ruby
2
- module Distil
3
-
4
- LIB_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
5
- VENDOR_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "vendor"))
6
- ASSETS_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "assets"))
7
- APP_NAME= File.basename($0)
8
-
9
- $:.unshift(LIB_DIR)
10
-
11
- end
12
-
13
- require "distil"
14
-
15
- arg_settings= {}
16
- project_file= nil
17
- args= []
18
-
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
36
-
37
- arg_settings[key]= value
38
- }
39
-
40
- def find_project_file(dir=nil)
41
- dir ||= Dir.pwd
42
-
43
- immediate_projects= Dir.glob(File.join(dir, "*.jsproj"))
44
- if (!immediate_projects.empty? && 1==immediate_projects.length)
45
- return immediate_projects[0]
46
- end
47
-
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)
53
- end
54
-
55
- 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
- }