comp_tree 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.rdoc CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
2
  = CompTree ChangeLog
3
3
 
4
+ == Version 0.7.4
5
+
6
+ * fix documentation
7
+
4
8
  == Version 0.7.3
5
9
 
6
10
  * replace standard Queue class
data/README.rdoc CHANGED
@@ -1,8 +1,6 @@
1
1
 
2
2
  = CompTree
3
3
 
4
- * http://comptree.rubyforge.org
5
-
6
4
  == Summary
7
5
 
8
6
  Automatic parallelism and lazy evaluation via pure functional
@@ -94,6 +92,7 @@ depends on that state</em>. This is the principle under which
94
92
 
95
93
  == Links
96
94
 
95
+ * Documentation: http://comptree.rubyforge.org
97
96
  * Download: http://rubyforge.org/frs/?group_id=6917
98
97
  * Rubyforge home: http://rubyforge.org/projects/comptree
99
98
  * Repository: http://github.com/quix/comp_tree
data/Rakefile CHANGED
@@ -2,7 +2,12 @@ $LOAD_PATH.unshift 'devel'
2
2
 
3
3
  require 'jumpstart'
4
4
 
5
- Jumpstart.new('comp_tree') do |s|
6
- s.developer('James M. Lawrence', 'quixoticsycophant@gmail.com')
5
+ Jumpstart.new "comp_tree" do |s|
6
+ s.developer "James M. Lawrence", "quixoticsycophant@gmail.com"
7
7
  s.rubyforge_user = "quix"
8
+ s.rdoc_files = %w[
9
+ lib/comp_tree.rb
10
+ lib/comp_tree/driver.rb
11
+ lib/comp_tree/error.rb
12
+ ]
8
13
  end
@@ -0,0 +1,606 @@
1
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
2
+
3
+ require 'rubygems'
4
+ require 'ostruct'
5
+ require 'rbconfig'
6
+
7
+ require 'rake/gempackagetask'
8
+ require 'rake/contrib/sshpublisher'
9
+ require 'rake/clean'
10
+
11
+ require 'rdoc/rdoc'
12
+
13
+ require 'jumpstart/ruby'
14
+ require 'jumpstart/lazy_attribute'
15
+ require 'jumpstart/simple_installer'
16
+
17
+ class Jumpstart
18
+ include LazyAttribute
19
+
20
+ def not_provided(param)
21
+ raise "#{self.class}##{param} not provided"
22
+ end
23
+
24
+ def must_define(*params)
25
+ params.each { |param|
26
+ attribute param do
27
+ not_provided(param)
28
+ end
29
+ }
30
+ end
31
+
32
+ def initialize(project_name)
33
+ must_define :authors, :email
34
+
35
+ attribute :name do
36
+ project_name
37
+ end
38
+
39
+ attribute :version do
40
+ str = "VERSION"
41
+ begin
42
+ require name
43
+ if mod = Object.const_get(to_camel_case(name))
44
+ if mod.constants.include? str
45
+ mod.const_get str
46
+ else
47
+ raise
48
+ end
49
+ else
50
+ raise
51
+ end
52
+ rescue Exception
53
+ "0.0.0"
54
+ end
55
+ end
56
+
57
+ attribute :rubyforge_name do
58
+ name.gsub('_', '')
59
+ end
60
+
61
+ attribute :rubyforge_user do
62
+ email.first[%r!^.*(?=@)!]
63
+ end
64
+
65
+ attribute :readme_file do
66
+ "README.rdoc"
67
+ end
68
+
69
+ attribute :history_file do
70
+ "CHANGES.rdoc"
71
+ end
72
+
73
+ attribute :doc_dir do
74
+ "documentation"
75
+ end
76
+
77
+ attribute :spec_files do
78
+ Dir["spec/*_{spec,example}.rb"]
79
+ end
80
+
81
+ attribute :test_files do
82
+ Dir["test/test_*.rb"]
83
+ end
84
+
85
+ attribute :rcov_dir do
86
+ "coverage"
87
+ end
88
+
89
+ attribute :spec_output do
90
+ "spec.html"
91
+ end
92
+
93
+ %w[gem tgz].map { |ext|
94
+ attribute ext.to_sym do
95
+ "pkg/#{name}-#{version}.#{ext}"
96
+ end
97
+ }
98
+
99
+ attribute :rcov_options do
100
+ # workaround for the default rspec task
101
+ Dir["*"].select { |f| File.directory? f }.inject(Array.new) { |acc, dir|
102
+ if dir == "lib"
103
+ acc
104
+ else
105
+ acc + ["--exclude", dir + "/"]
106
+ end
107
+ } + ["--text-report"]
108
+ end
109
+
110
+ attribute :readme_file do
111
+ "README.rdoc"
112
+ end
113
+
114
+ attribute :files do
115
+ if File.exist?(manifest = "Manifest.txt")
116
+ File.read(manifest).split("\n")
117
+ elsif File.directory? ".git"
118
+ `git ls-files`.split("\n")
119
+ elsif File.directory? ".svn"
120
+ `svn status --verbose`.split("\n").map { |t|
121
+ t.split[3]
122
+ }.select { |t|
123
+ t and File.file?(t)
124
+ }
125
+ else
126
+ []
127
+ end
128
+ end
129
+
130
+ attribute :rdoc_files do
131
+ Dir["lib/**/*.rb"]
132
+ end
133
+
134
+ attribute :extra_rdoc_files do
135
+ [readme_file]
136
+ end
137
+
138
+ attribute :rdoc_options do
139
+ [
140
+ "--main",
141
+ readme_file,
142
+ "--title",
143
+ "#{name}: #{summary}",
144
+ ] + (files - rdoc_files).inject(Array.new) { |acc, file|
145
+ acc + ["--exclude", file]
146
+ }
147
+ end
148
+
149
+ attribute :browser do
150
+ if Config::CONFIG["host"] =~ %r!darwin!
151
+ app = %w[Firefox Safari].map { |t|
152
+ "/Applications/#{t}.app"
153
+ }.select { |t|
154
+ File.exist? t
155
+ }.first
156
+ if app
157
+ ["open", app]
158
+ else
159
+ not_provided(:browser)
160
+ end
161
+ else
162
+ "firefox"
163
+ end
164
+ end
165
+
166
+ attribute :gemspec do
167
+ Gem::Specification.new { |g|
168
+ g.has_rdoc = true
169
+ %w[
170
+ name
171
+ authors
172
+ email
173
+ summary
174
+ version
175
+ description
176
+ files
177
+ extra_rdoc_files
178
+ rdoc_options
179
+ ].each { |param|
180
+ value = send(param) and (
181
+ g.send("#{param}=", value)
182
+ )
183
+ }
184
+
185
+ if rubyforge_name
186
+ g.rubyforge_project = rubyforge_name
187
+ end
188
+
189
+ if url
190
+ g.homepage = url
191
+ end
192
+ }
193
+ end
194
+
195
+ attribute :readme_contents do
196
+ File.read(readme_file)
197
+ end
198
+
199
+ attribute :sections do
200
+ begin
201
+ pairs = Hash[*readme_contents.split(%r!^== (\w+).*?$!)[1..-1]].map {
202
+ |section, contents|
203
+ [section.downcase, contents.strip]
204
+ }
205
+ Hash[*pairs.flatten]
206
+ rescue
207
+ nil
208
+ end
209
+ end
210
+
211
+ attribute :description_section do
212
+ "description"
213
+ end
214
+
215
+ attribute :summary_section do
216
+ "summary"
217
+ end
218
+
219
+ attribute :description_sentences do
220
+ 1
221
+ end
222
+
223
+ attribute :summary_sentences do
224
+ 1
225
+ end
226
+
227
+ [:summary, :description].each { |section|
228
+ attribute section do
229
+ begin
230
+ sections[send("#{section}_section")].
231
+ gsub("\n", " ").
232
+ split(%r!\.\s*!m).
233
+ first(send("#{section}_sentences")).
234
+ join(". ") << "."
235
+ rescue
236
+ if section == :description
237
+ summary
238
+ end
239
+ end
240
+ end
241
+ }
242
+
243
+ attribute :url do
244
+ begin
245
+ readme_contents.match(%r!^\*.*?(http://\S+)!)[1]
246
+ rescue
247
+ "http://#{rubyforge_name}.rubyforge.org"
248
+ end
249
+ end
250
+
251
+ yield self
252
+
253
+ self.class.instance_methods(false).select { |t|
254
+ t.to_s =~ %r!\Adefine_!
255
+ }.each { |method_name|
256
+ send(method_name)
257
+ }
258
+ end
259
+
260
+ def developer(name, email)
261
+ self.authors rescue self.authors = []
262
+ self.email rescue self.email = []
263
+ self.authors << name
264
+ self.email << email
265
+ end
266
+
267
+ def author=(name)
268
+ self.authors = [name]
269
+ end
270
+
271
+ def define_clean
272
+ task :clean do
273
+ Rake::Task[:clobber].invoke
274
+ end
275
+ end
276
+
277
+ def define_package
278
+ task :package => :clean
279
+ Rake::GemPackageTask.new(gemspec) { |t|
280
+ t.need_tar = true
281
+ }
282
+ end
283
+
284
+ def define_spec
285
+ unless spec_files.empty?
286
+ require 'spec/rake/spectask'
287
+
288
+ desc "run specs"
289
+ Spec::Rake::SpecTask.new('spec') do |t|
290
+ t.spec_files = spec_files
291
+ end
292
+
293
+ desc "run specs with text output"
294
+ Spec::Rake::SpecTask.new('text_spec') do |t|
295
+ t.spec_files = spec_files
296
+ t.spec_opts = ['-fs']
297
+ end
298
+
299
+ desc "run specs with html output"
300
+ Spec::Rake::SpecTask.new('full_spec') do |t|
301
+ t.spec_files = spec_files
302
+ t.rcov = true
303
+ t.rcov_opts = rcov_options
304
+ t.spec_opts = ["-fh:#{spec_output}"]
305
+ end
306
+
307
+ desc "run full_spec then open browser"
308
+ task :show_spec => :full_spec do
309
+ open_browser(spec_output, rcov_dir + "/index.html")
310
+ end
311
+
312
+ desc "run specs individually"
313
+ task :spec_deps do
314
+ run_ruby_on_each(*spec_files)
315
+ end
316
+
317
+ task :prerelease => [:spec, :spec_deps]
318
+ task :default => :spec
319
+
320
+ CLEAN.include spec_output
321
+ end
322
+ end
323
+
324
+ def define_test
325
+ unless test_files.empty?
326
+ desc "run tests"
327
+ task :test do
328
+ test_files.each { |file|
329
+ require file
330
+ }
331
+ end
332
+
333
+ desc "run tests with rcov"
334
+ task :full_test do
335
+ verbose(false) {
336
+ sh("rcov", "-o", rcov_dir, "--text-report",
337
+ *(test_files + rcov_options)
338
+ )
339
+ }
340
+ end
341
+
342
+ desc "run full_test then open browser"
343
+ task :show_test => :full_test do
344
+ open_browser(rcov_dir + "/index.html")
345
+ end
346
+
347
+ desc "run tests individually"
348
+ task :test_deps do
349
+ run_ruby_on_each(*test_files)
350
+ end
351
+
352
+ task :prerelease => [:test, :test_deps]
353
+ task :default => :test
354
+
355
+ CLEAN.include rcov_dir
356
+ end
357
+ end
358
+
359
+ def define_doc
360
+ desc "run rdoc"
361
+ task :doc => :clean_doc do
362
+ args = (
363
+ gemspec.rdoc_options +
364
+ gemspec.require_paths.clone +
365
+ gemspec.extra_rdoc_files +
366
+ ["-o", doc_dir]
367
+ ).flatten.map { |t| t.to_s }
368
+ RDoc::RDoc.new.document args
369
+ end
370
+
371
+ task :clean_doc do
372
+ # normally rm_rf, but mimic rake/clean output
373
+ rm_r(doc_dir) rescue nil
374
+ end
375
+
376
+ desc "run rdoc then open browser"
377
+ task :show_doc => :doc do
378
+ open_browser(doc_dir + "/index.html")
379
+ end
380
+
381
+ task :rdoc => :doc
382
+ task :clean => :clean_doc
383
+ end
384
+
385
+ def define_publish
386
+ desc "upload docs"
387
+ task :publish => [:clean_doc, :doc] do
388
+ Rake::SshDirPublisher.new(
389
+ "#{rubyforge_user}@rubyforge.org",
390
+ "/var/www/gforge-projects/#{rubyforge_name}",
391
+ doc_dir
392
+ ).upload
393
+ end
394
+ end
395
+
396
+ def define_install
397
+ desc "direct install (no gem)"
398
+ task :install do
399
+ SimpleInstaller.new.run([])
400
+ end
401
+
402
+ desc "direct uninstall (no gem)"
403
+ task :uninstall do
404
+ SimpleInstaller.new.run(["--uninstall"])
405
+ end
406
+ end
407
+
408
+ def define_debug
409
+ runner = Class.new do
410
+ def comment_src_dst(on)
411
+ on ? ["", "#"] : ["#", ""]
412
+ end
413
+
414
+ def comment_regions(on, contents, start)
415
+ src, dst = comment_src_dst(on)
416
+ contents.gsub(%r!^(\s+)#{src}#{start}.*?^\1#{src}(\}|end)!m) { |chunk|
417
+ indent = $1
418
+ chunk.gsub(%r!^#{indent}#{src}!, "#{indent}#{dst}")
419
+ }
420
+ end
421
+
422
+ def comment_lines(on, contents, start)
423
+ src, dst = comment_src_dst(on)
424
+ contents.gsub(%r!^(\s*)#{src}#{start}!) {
425
+ $1 + dst + start
426
+ }
427
+ end
428
+
429
+ def debug_info(enable)
430
+ Find.find("lib", "test") { |path|
431
+ if path =~ %r!\.rb\Z!
432
+ Jumpstart.replace_file(path) { |contents|
433
+ result = comment_regions(!enable, contents, "debug")
434
+ comment_lines(!enable, result, "trace")
435
+ }
436
+ end
437
+ }
438
+ end
439
+ end
440
+
441
+ desc "enable debug and trace calls"
442
+ task :debug_on do
443
+ runner.new.debug_info(true)
444
+ end
445
+
446
+ desc "disable debug and trace calls"
447
+ task :debug_off do
448
+ runner.new.debug_info(false)
449
+ end
450
+ end
451
+
452
+ def define_columns
453
+ desc "check for columns > 80"
454
+ task :check_columns do
455
+ Dir["**/*.rb"].each { |file|
456
+ File.read(file).scan(%r!^.{81}!) { |match|
457
+ unless match =~ %r!http://!
458
+ raise "#{file} greater than 80 columns: #{match}"
459
+ end
460
+ }
461
+ }
462
+ end
463
+ task :prerelease => :check_columns
464
+ end
465
+
466
+ def define_comments
467
+ task :comments do
468
+ file = "comments.txt"
469
+ write_file(file) {
470
+ Array.new.tap { |result|
471
+ (["Rakefile"] + Dir["**/*.{rb,rake}"]).each { |file|
472
+ File.read(file).scan(%r!\#[^\{].*$!) { |match|
473
+ result << match
474
+ }
475
+ }
476
+ }.join("\n")
477
+ }
478
+ CLEAN.include file
479
+ end
480
+ end
481
+
482
+ def define_check_directory
483
+ task :check_directory do
484
+ unless `git status` =~ %r!nothing to commit \(working directory clean\)!
485
+ raise "Directory not clean"
486
+ end
487
+ end
488
+ end
489
+
490
+ def define_ping
491
+ task :ping do
492
+ %w[github.com rubyforge.org].each { |server|
493
+ cmd = "ping " + (
494
+ if Config::CONFIG["host"] =~ %r!darwin!
495
+ "-c2 #{server}"
496
+ else
497
+ "#{server} 2 2"
498
+ end
499
+ )
500
+ unless `#{cmd}` =~ %r!0% packet loss!
501
+ raise "No ping for #{server}"
502
+ end
503
+ }
504
+ end
505
+ end
506
+
507
+ def define_update_jumpstart
508
+ url = ENV["RUBY_JUMPSTART"] || "git://github.com/quix/jumpstart.git"
509
+ task :update_jumpstart do
510
+ Dir.chdir("devel") {
511
+ rm_rf "jumpstart"
512
+ git "clone", url
513
+ rm_rf "jumpstart/.git"
514
+ git "commit", "jumpstart", "-m", "update jumpstart"
515
+ }
516
+ end
517
+ end
518
+
519
+ def git(*args)
520
+ sh("git", *args)
521
+ end
522
+
523
+ def rubyforge(command, file)
524
+ sh(
525
+ "rubyforge",
526
+ command,
527
+ rubyforge_name,
528
+ rubyforge_name,
529
+ version.to_s,
530
+ file
531
+ )
532
+ end
533
+
534
+ def define_release
535
+ task :prerelease => [:clean, :check_directory, :ping]
536
+
537
+ task :finish_release do
538
+ gem_md5, tgz_md5 = [gem, tgz].map { |file|
539
+ "#{file}.md5".tap { |md5|
540
+ sh("md5sum #{file} > #{md5}")
541
+ }
542
+ }
543
+
544
+ rubyforge("add_release", gem)
545
+ [gem_md5, tgz, tgz_md5].each { |file|
546
+ rubyforge("add_file", file)
547
+ }
548
+
549
+ git("tag", "#{name}-" + version.to_s)
550
+ git(*%w(push --tags origin master))
551
+ end
552
+
553
+ task :release => [:prerelease, :package, :publish, :finish_release]
554
+ end
555
+
556
+ def define_debug_gem
557
+ task :debug_gem do
558
+ puts gemspec.to_ruby
559
+ end
560
+ end
561
+
562
+ def open_browser(*files)
563
+ sh(*([browser].flatten + files))
564
+ end
565
+
566
+ def write_file(file)
567
+ yield.tap { |contents|
568
+ File.open(file, "wb") { |out|
569
+ out.print(contents)
570
+ }
571
+ }
572
+ end
573
+
574
+ def run_ruby_on_each(*files)
575
+ files.each { |file|
576
+ Ruby.run_or_raise("-w", file)
577
+ }
578
+ end
579
+
580
+ def to_camel_case(str)
581
+ str.split('_').map { |t| t.capitalize }.join
582
+ end
583
+
584
+ class << self
585
+ def replace_file(file)
586
+ old_contents = File.read(file)
587
+ yield(old_contents).tap { |new_contents|
588
+ if old_contents != new_contents
589
+ File.open(file, "wb") { |output|
590
+ output.print(new_contents)
591
+ }
592
+ end
593
+ }
594
+ end
595
+ end
596
+ end
597
+
598
+ unless respond_to? :tap
599
+ class Object
600
+ def tap
601
+ yield self
602
+ self
603
+ end
604
+ end
605
+ end
606
+
data/devel/jumpstart.rb CHANGED
@@ -1,594 +1 @@
1
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
2
-
3
- require 'rubygems'
4
- require 'ostruct'
5
- require 'rbconfig'
6
-
7
- require 'rake/gempackagetask'
8
- require 'rake/contrib/sshpublisher'
9
- require 'rake/clean'
10
-
11
- require 'rdoc/rdoc'
12
-
13
- require 'jumpstart/ruby'
14
- require 'jumpstart/lazy_attribute'
15
- require 'jumpstart/simple_installer'
16
-
17
- class Jumpstart
18
- include LazyAttribute
19
-
20
- def not_provided(param)
21
- raise "#{self.class}##{param} not provided"
22
- end
23
-
24
- def must_define(*params)
25
- params.each { |param|
26
- attribute param do
27
- not_provided(param)
28
- end
29
- }
30
- end
31
-
32
- def initialize(project_name)
33
- must_define :authors, :email
34
-
35
- attribute :name do
36
- project_name
37
- end
38
-
39
- attribute :version do
40
- str = "VERSION"
41
- begin
42
- require name
43
- if mod = Object.const_get(to_camel_case(name))
44
- if mod.constants.include? str
45
- mod.const_get str
46
- else
47
- raise
48
- end
49
- else
50
- raise
51
- end
52
- rescue Exception
53
- "0.0.0"
54
- end
55
- end
56
-
57
- attribute :rubyforge_name do
58
- name.gsub('_', '')
59
- end
60
-
61
- attribute :rubyforge_user do
62
- email.first[%r!^.*(?=@)!]
63
- end
64
-
65
- attribute :readme_file do
66
- "README.rdoc"
67
- end
68
-
69
- attribute :history_file do
70
- "CHANGES.rdoc"
71
- end
72
-
73
- attribute :doc_dir do
74
- "documentation"
75
- end
76
-
77
- attribute :spec_files do
78
- Dir["spec/*_{spec,example}.rb"]
79
- end
80
-
81
- attribute :test_files do
82
- Dir["test/test_*.rb"]
83
- end
84
-
85
- attribute :rcov_dir do
86
- "coverage"
87
- end
88
-
89
- attribute :spec_output do
90
- "spec.html"
91
- end
92
-
93
- %w[gem tgz].map { |ext|
94
- attribute ext.to_sym do
95
- "pkg/#{name}-#{version}.#{ext}"
96
- end
97
- }
98
-
99
- attribute :rcov_options do
100
- # workaround for the default rspec task
101
- Dir["*"].select { |f| File.directory? f }.inject(Array.new) { |acc, dir|
102
- if dir == "lib"
103
- acc
104
- else
105
- acc + ["--exclude", dir + "/"]
106
- end
107
- } + ["--text-report"]
108
- end
109
-
110
- attribute :readme_file do
111
- "README.rdoc"
112
- end
113
-
114
- attribute :files do
115
- if File.exist?(manifest = "Manifest.txt")
116
- File.read(manifest).split("\n")
117
- elsif File.directory? ".git"
118
- `git ls-files`.split("\n")
119
- elsif File.directory? ".svn"
120
- `svn status --verbose`.split("\n").map { |t|
121
- t.split[3]
122
- }.select { |t|
123
- t and File.file?(t)
124
- }
125
- else
126
- []
127
- end
128
- end
129
-
130
- attribute :rdoc_files do
131
- Dir["lib/**/*.rb"]
132
- end
133
-
134
- attribute :extra_rdoc_files do
135
- [readme_file]
136
- end
137
-
138
- attribute :rdoc_options do
139
- [
140
- "--main",
141
- readme_file,
142
- "--title",
143
- "#{name}: #{summary}",
144
- ] + (files - rdoc_files).inject(Array.new) { |acc, file|
145
- acc + ["--exclude", file]
146
- }
147
- end
148
-
149
- attribute :browser do
150
- if Config::CONFIG["host"] =~ %r!darwin!
151
- app = %w[Firefox Safari].map { |t|
152
- "/Applications/#{t}.app"
153
- }.select { |t|
154
- File.exist? t
155
- }.first
156
- if app
157
- ["open", app]
158
- else
159
- not_provided(:browser)
160
- end
161
- else
162
- "firefox"
163
- end
164
- end
165
-
166
- attribute :gemspec do
167
- Gem::Specification.new { |g|
168
- g.has_rdoc = true
169
- %w[
170
- name
171
- authors
172
- email
173
- summary
174
- version
175
- description
176
- files
177
- extra_rdoc_files
178
- rdoc_options
179
- ].each { |param|
180
- value = send(param) and (
181
- g.send("#{param}=", value)
182
- )
183
- }
184
-
185
- if rubyforge_name
186
- g.rubyforge_project = rubyforge_name
187
- end
188
-
189
- if url
190
- g.homepage = url
191
- end
192
- }
193
- end
194
-
195
- attribute :readme_contents do
196
- File.read(readme_file)
197
- end
198
-
199
- attribute :sections do
200
- begin
201
- pairs = Hash[*readme_contents.split(%r!^== (\w+).*?$!)[1..-1]].map {
202
- |section, contents|
203
- [section.downcase, contents.strip]
204
- }
205
- Hash[*pairs.flatten]
206
- rescue
207
- nil
208
- end
209
- end
210
-
211
- attribute :description_section do
212
- "description"
213
- end
214
-
215
- attribute :summary_section do
216
- "summary"
217
- end
218
-
219
- attribute :description_sentences do
220
- 1
221
- end
222
-
223
- attribute :summary_sentences do
224
- 1
225
- end
226
-
227
- [:summary, :description].each { |section|
228
- attribute section do
229
- begin
230
- sections[send("#{section}_section")].
231
- gsub("\n", " ").
232
- split(%r!\.\s*!m).
233
- first(send("#{section}_sentences")).
234
- join(". ") << "."
235
- rescue
236
- if section == :description
237
- summary
238
- end
239
- end
240
- end
241
- }
242
-
243
- attribute :url do
244
- begin
245
- readme_contents.match(%r!^\* (\S+)!)[1]
246
- rescue
247
- "http://#{rubyforge_name}.rubyforge.org"
248
- end
249
- end
250
-
251
- yield self
252
-
253
- self.class.instance_methods(false).select { |t|
254
- t.to_s =~ %r!\Adefine_!
255
- }.each { |method_name|
256
- send(method_name)
257
- }
258
- end
259
-
260
- def developer(name, email)
261
- self.authors rescue self.authors = []
262
- self.email rescue self.email = []
263
- self.authors << name
264
- self.email << email
265
- end
266
-
267
- def author=(name)
268
- self.authors = [name]
269
- end
270
-
271
- def define_clean
272
- task :clean do
273
- Rake::Task[:clobber].invoke
274
- end
275
- end
276
-
277
- def define_package
278
- task :package => :clean
279
- Rake::GemPackageTask.new(gemspec) { |t|
280
- t.need_tar = true
281
- }
282
- end
283
-
284
- def define_spec
285
- unless spec_files.empty?
286
- require 'spec/rake/spectask'
287
-
288
- desc "run specs"
289
- Spec::Rake::SpecTask.new('spec') do |t|
290
- t.spec_files = spec_files
291
- end
292
-
293
- desc "run specs with text output"
294
- Spec::Rake::SpecTask.new('text_spec') do |t|
295
- t.spec_files = spec_files
296
- t.spec_opts = ['-fs']
297
- end
298
-
299
- desc "run specs with html output"
300
- Spec::Rake::SpecTask.new('full_spec') do |t|
301
- t.spec_files = spec_files
302
- t.rcov = true
303
- t.rcov_opts = rcov_options
304
- t.spec_opts = ["-fh:#{spec_output}"]
305
- end
306
-
307
- desc "run full_spec then open browser"
308
- task :show_spec => :full_spec do
309
- open_browser(spec_output, rcov_dir + "/index.html")
310
- end
311
-
312
- desc "run specs individually"
313
- task :spec_deps do
314
- run_ruby_on_each(*spec_files)
315
- end
316
-
317
- task :prerelease => [:spec, :spec_deps]
318
- task :default => :spec
319
-
320
- CLEAN.include spec_output
321
- end
322
- end
323
-
324
- def define_test
325
- unless test_files.empty?
326
- desc "run tests"
327
- task :test do
328
- test_files.each { |file|
329
- require file
330
- }
331
- end
332
-
333
- desc "run tests with rcov"
334
- task :full_test do
335
- verbose(false) {
336
- sh("rcov", "-o", rcov_dir, "--text-report",
337
- *(test_files + rcov_options)
338
- )
339
- }
340
- end
341
-
342
- desc "run full_test then open browser"
343
- task :show_test => :full_test do
344
- open_browser(rcov_dir + "/index.html")
345
- end
346
-
347
- desc "run tests individually"
348
- task :test_deps do
349
- run_ruby_on_each(*test_files)
350
- end
351
-
352
- task :prerelease => [:test, :test_deps]
353
- task :default => :test
354
-
355
- CLEAN.include rcov_dir
356
- end
357
- end
358
-
359
- def define_doc
360
- desc "run rdoc"
361
- task :doc => :clean_doc do
362
- args = (
363
- gemspec.rdoc_options +
364
- gemspec.require_paths.clone +
365
- gemspec.extra_rdoc_files +
366
- ["-o", doc_dir]
367
- ).flatten.map { |t| t.to_s }
368
- RDoc::RDoc.new.document args
369
- end
370
-
371
- task :clean_doc do
372
- # normally rm_rf, but mimic rake/clean output
373
- rm_r(doc_dir) rescue nil
374
- end
375
-
376
- desc "run rdoc then open browser"
377
- task :show_doc => :doc do
378
- open_browser(doc_dir + "/index.html")
379
- end
380
-
381
- task :rdoc => :doc
382
- task :clean => :clean_doc
383
- end
384
-
385
- def define_publish
386
- desc "upload docs"
387
- task :publish => [:clean_doc, :doc] do
388
- Rake::SshDirPublisher.new(
389
- "#{rubyforge_user}@rubyforge.org",
390
- "/var/www/gforge-projects/#{rubyforge_name}",
391
- doc_dir
392
- ).upload
393
- end
394
- end
395
-
396
- def define_install
397
- desc "direct install (no gem)"
398
- task :install do
399
- SimpleInstaller.new.run([])
400
- end
401
-
402
- desc "direct uninstall (no gem)"
403
- task :uninstall do
404
- SimpleInstaller.new.run(["--uninstall"])
405
- end
406
- end
407
-
408
- def define_debug
409
- runner = Class.new do
410
- def comment_src_dst(on)
411
- on ? ["", "#"] : ["#", ""]
412
- end
413
-
414
- def comment_regions(on, contents, start)
415
- src, dst = comment_src_dst(on)
416
- contents.gsub(%r!^(\s+)#{src}#{start}.*?^\1#{src}(\}|end)!m) { |chunk|
417
- indent = $1
418
- chunk.gsub(%r!^#{indent}#{src}!, "#{indent}#{dst}")
419
- }
420
- end
421
-
422
- def comment_lines(on, contents, start)
423
- src, dst = comment_src_dst(on)
424
- contents.gsub(%r!^(\s*)#{src}#{start}!) {
425
- $1 + dst + start
426
- }
427
- end
428
-
429
- def debug_info(enable)
430
- Find.find("lib", "test") { |path|
431
- if path =~ %r!\.rb\Z!
432
- Jumpstart.replace_file(path) { |contents|
433
- result = comment_regions(!enable, contents, "debug")
434
- comment_lines(!enable, result, "trace")
435
- }
436
- end
437
- }
438
- end
439
- end
440
-
441
- desc "enable debug and trace calls"
442
- task :debug_on do
443
- runner.new.debug_info(true)
444
- end
445
-
446
- desc "disable debug and trace calls"
447
- task :debug_off do
448
- runner.new.debug_info(false)
449
- end
450
- end
451
-
452
- def define_columns
453
- desc "check for columns > 80"
454
- task :check_columns do
455
- Dir["**/*.rb"].each { |file|
456
- File.read(file).scan(%r!^.{81}!) { |match|
457
- unless match =~ %r!http://!
458
- raise "#{file} greater than 80 columns: #{match}"
459
- end
460
- }
461
- }
462
- end
463
- task :prerelease => :check_columns
464
- end
465
-
466
- def define_comments
467
- task :comments do
468
- file = "comments.txt"
469
- write_file(file) {
470
- Array.new.tap { |result|
471
- (["Rakefile"] + Dir["**/*.{rb,rake}"]).each { |file|
472
- File.read(file).scan(%r!\#[^\{].*$!) { |match|
473
- result << match
474
- }
475
- }
476
- }.join("\n")
477
- }
478
- CLEAN.include file
479
- end
480
- end
481
-
482
- def define_check_directory
483
- task :check_directory do
484
- unless `git status` =~ %r!nothing to commit \(working directory clean\)!
485
- raise "Directory not clean"
486
- end
487
- end
488
- end
489
-
490
- def define_ping
491
- task :ping do
492
- %w[github.com rubyforge.org].each { |server|
493
- cmd = "ping " + (
494
- if Config::CONFIG["host"] =~ %r!darwin!
495
- "-c2 #{server}"
496
- else
497
- "#{server} 2 2"
498
- end
499
- )
500
- unless `#{cmd}` =~ %r!0% packet loss!
501
- raise "No ping for #{server}"
502
- end
503
- }
504
- end
505
- end
506
-
507
- def git(*args)
508
- sh("git", *args)
509
- end
510
-
511
- def rubyforge(command, file)
512
- sh(
513
- "rubyforge",
514
- command,
515
- rubyforge_name,
516
- rubyforge_name,
517
- version.to_s,
518
- file
519
- )
520
- end
521
-
522
- def define_release
523
- task :prerelease => [:clean, :check_directory, :ping]
524
-
525
- task :finish_release do
526
- gem_md5, tgz_md5 = [gem, tgz].map { |file|
527
- "#{file}.md5".tap { |md5|
528
- sh("md5sum #{file} > #{md5}")
529
- }
530
- }
531
-
532
- rubyforge("add_release", gem)
533
- [gem_md5, tgz, tgz_md5].each { |file|
534
- rubyforge("add_file", file)
535
- }
536
-
537
- git("tag", "#{name}-" + version.to_s)
538
- git(*%w(push --tags origin master))
539
- end
540
-
541
- task :release => [:prerelease, :package, :publish, :finish_release]
542
- end
543
-
544
- def define_debug_gem
545
- task :debug_gem do
546
- puts gemspec.to_ruby
547
- end
548
- end
549
-
550
- def open_browser(*files)
551
- sh(*([browser].flatten + files))
552
- end
553
-
554
- def write_file(file)
555
- yield.tap { |contents|
556
- File.open(file, "wb") { |out|
557
- out.print(contents)
558
- }
559
- }
560
- end
561
-
562
- def run_ruby_on_each(*files)
563
- files.each { |file|
564
- Ruby.run_or_raise("-w", file)
565
- }
566
- end
567
-
568
- def to_camel_case(str)
569
- str.split('_').map { |t| t.capitalize }.join
570
- end
571
-
572
- class << self
573
- def replace_file(file)
574
- old_contents = File.read(file)
575
- yield(old_contents).tap { |new_contents|
576
- if old_contents != new_contents
577
- File.open(file, "wb") { |output|
578
- output.print(new_contents)
579
- }
580
- end
581
- }
582
- end
583
- end
584
- end
585
-
586
- unless respond_to? :tap
587
- class Object
588
- def tap
589
- yield self
590
- self
591
- end
592
- end
593
- end
594
-
1
+ require 'jumpstart/jumpstart'
data/lib/comp_tree.rb CHANGED
@@ -28,7 +28,7 @@ require 'comp_tree/driver'
28
28
  # See README.rdoc.
29
29
  #
30
30
  module CompTree
31
- VERSION = "0.7.3"
31
+ VERSION = "0.7.4"
32
32
 
33
33
  class << self
34
34
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comp_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James M. Lawrence
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-25 00:00:00 -04:00
12
+ date: 2009-04-28 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -27,6 +27,7 @@ files:
27
27
  - README.rdoc
28
28
  - Rakefile
29
29
  - devel/jumpstart.rb
30
+ - devel/jumpstart/jumpstart.rb
30
31
  - devel/jumpstart/lazy_attribute.rb
31
32
  - devel/jumpstart/ruby.rb
32
33
  - devel/jumpstart/simple_installer.rb
@@ -64,6 +65,8 @@ rdoc_options:
64
65
  - --exclude
65
66
  - devel/jumpstart.rb
66
67
  - --exclude
68
+ - devel/jumpstart/jumpstart.rb
69
+ - --exclude
67
70
  - devel/jumpstart/lazy_attribute.rb
68
71
  - --exclude
69
72
  - devel/jumpstart/ruby.rb
@@ -72,6 +75,16 @@ rdoc_options:
72
75
  - --exclude
73
76
  - install.rb
74
77
  - --exclude
78
+ - lib/comp_tree/algorithm.rb
79
+ - --exclude
80
+ - lib/comp_tree/node.rb
81
+ - --exclude
82
+ - lib/comp_tree/queue.rb
83
+ - --exclude
84
+ - lib/comp_tree/queue_new.rb
85
+ - --exclude
86
+ - lib/comp_tree/queue_old.rb
87
+ - --exclude
75
88
  - test/common.rb
76
89
  - --exclude
77
90
  - test/test_basic.rb