comp_tree 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.rdoc +4 -0
- data/Rakefile +1 -1
- data/devel/levitate.rb +259 -345
- data/lib/comp_tree/version.rb +1 -1
- metadata +4 -7
- data/MANIFEST +0 -24
data/CHANGES.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'levitate'
|
|
5
5
|
Levitate.new "comp_tree" do |s|
|
6
6
|
s.developers << ["James M. Lawrence", "quixoticsycophant@gmail.com"]
|
7
7
|
s.rubyforge_info = ["quix", "comptree"]
|
8
|
-
s.
|
8
|
+
s.username = "quix"
|
9
9
|
s.rdoc_files = %w[
|
10
10
|
lib/comp_tree.rb
|
11
11
|
lib/comp_tree/driver.rb
|
data/devel/levitate.rb
CHANGED
@@ -1,276 +1,33 @@
|
|
1
1
|
|
2
2
|
class Levitate
|
3
|
-
|
4
|
-
|
5
|
-
require 'fileutils'
|
6
|
-
require 'rbconfig'
|
7
|
-
require 'find'
|
8
|
-
dest_root = RbConfig::CONFIG["sitelibdir"]
|
9
|
-
sources = []
|
10
|
-
Find.find("./lib") { |source|
|
11
|
-
if install_file?(source)
|
12
|
-
sources << source
|
13
|
-
end
|
14
|
-
}
|
15
|
-
@spec = sources.inject(Array.new) { |acc, source|
|
16
|
-
if source == "./lib"
|
17
|
-
acc
|
18
|
-
else
|
19
|
-
dest = File.join(dest_root, source.sub(%r!\A\./lib!, ""))
|
20
|
-
|
21
|
-
install = lambda {
|
22
|
-
if File.directory?(source)
|
23
|
-
unless File.directory?(dest)
|
24
|
-
puts "mkdir #{dest}"
|
25
|
-
FileUtils.mkdir(dest)
|
26
|
-
end
|
27
|
-
else
|
28
|
-
puts "install #{source} --> #{dest}"
|
29
|
-
FileUtils.install(source, dest)
|
30
|
-
end
|
31
|
-
}
|
32
|
-
|
33
|
-
uninstall = lambda {
|
34
|
-
if File.directory?(source)
|
35
|
-
if File.directory?(dest)
|
36
|
-
puts "rmdir #{dest}"
|
37
|
-
FileUtils.rmdir(dest)
|
38
|
-
end
|
39
|
-
else
|
40
|
-
if File.file?(dest)
|
41
|
-
puts "rm #{dest}"
|
42
|
-
FileUtils.rm(dest)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
}
|
46
|
-
|
47
|
-
acc << {
|
48
|
-
:source => source,
|
49
|
-
:dest => dest,
|
50
|
-
:install => install,
|
51
|
-
:uninstall => uninstall,
|
52
|
-
}
|
53
|
-
end
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
def install_file?(source)
|
58
|
-
File.directory?(source) or
|
59
|
-
(File.file?(source) and File.extname(source) == ".rb")
|
60
|
-
end
|
61
|
-
|
62
|
-
def install
|
63
|
-
@spec.each { |entry|
|
64
|
-
entry[:install].call
|
65
|
-
}
|
66
|
-
end
|
67
|
-
|
68
|
-
def uninstall
|
69
|
-
@spec.reverse.each { |entry|
|
70
|
-
entry[:uninstall].call
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
def run(args = ARGV)
|
75
|
-
if args.empty?
|
76
|
-
install
|
77
|
-
elsif args.size == 1 and args.first == "--uninstall"
|
78
|
-
uninstall
|
79
|
-
else
|
80
|
-
raise "unrecognized arguments: #{args.inspect}"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
module AttrLazy
|
86
|
-
def attr_lazy(name, &block)
|
87
|
-
AttrLazy.define_reader(class << self ; self ; end, name, &block)
|
88
|
-
end
|
89
|
-
|
90
|
-
def attr_lazy_accessor(name, &block)
|
91
|
-
attr_lazy(name, &block)
|
92
|
-
AttrLazy.define_writer(class << self ; self ; end, name, &block)
|
93
|
-
end
|
94
|
-
|
95
|
-
class << self
|
96
|
-
def included(mod)
|
97
|
-
(class << mod ; self ; end).class_eval do
|
98
|
-
def attr_lazy(name, &block)
|
99
|
-
AttrLazy.define_reader(self, name, &block)
|
100
|
-
end
|
101
|
-
|
102
|
-
def attr_lazy_accessor(name, &block)
|
103
|
-
attr_lazy(name, &block)
|
104
|
-
AttrLazy.define_writer(self, name, &block)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
3
|
+
def initialize(gem_name)
|
4
|
+
@gem_name = gem_name
|
108
5
|
|
109
|
-
|
110
|
-
(class << instance ; self ; end).class_eval do
|
111
|
-
remove_method name rescue nil
|
112
|
-
define_method name do
|
113
|
-
value
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
6
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
117
7
|
|
118
|
-
|
119
|
-
klass.class_eval do
|
120
|
-
remove_method name rescue nil
|
121
|
-
define_method name do
|
122
|
-
value = instance_eval(&block)
|
123
|
-
AttrLazy.define_evaluated_reader(self, name, value)
|
124
|
-
value
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
8
|
+
yield self
|
128
9
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
remove_method writer rescue nil
|
133
|
-
define_method writer do |value|
|
134
|
-
AttrLazy.define_evaluated_reader(self, name, value)
|
135
|
-
value
|
136
|
-
end
|
137
|
-
end
|
10
|
+
self.class.instance_methods(false).sort.each do |name|
|
11
|
+
if name.to_s =~ %r!\Adefine_!
|
12
|
+
send(name)
|
138
13
|
end
|
139
14
|
end
|
140
15
|
end
|
141
16
|
|
142
|
-
|
143
|
-
module_function
|
144
|
-
|
145
|
-
def executable
|
146
|
-
require 'rbconfig'
|
147
|
-
|
148
|
-
name = File.join(
|
149
|
-
RbConfig::CONFIG["bindir"],
|
150
|
-
RbConfig::CONFIG["RUBY_INSTALL_NAME"]
|
151
|
-
)
|
17
|
+
attr_reader :gem_name
|
152
18
|
|
153
|
-
|
154
|
-
|
155
|
-
|
19
|
+
def self.attribute(name, &block)
|
20
|
+
var = :"@#{name}"
|
21
|
+
define_method name do
|
22
|
+
if instance_variable_defined?(var)
|
23
|
+
instance_variable_get(var)
|
156
24
|
else
|
157
|
-
|
25
|
+
instance_variable_set(var, instance_eval(&block))
|
158
26
|
end
|
159
27
|
end
|
160
|
-
|
161
|
-
def run(*args)
|
162
|
-
cmd = [executable, *args]
|
163
|
-
unless system(*cmd)
|
164
|
-
cmd_str = cmd.map { |t| "'#{t}'" }.join(", ")
|
165
|
-
raise "system(#{cmd_str}) failed with status #{$?.exitstatus}"
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def run_code_and_capture(code)
|
170
|
-
IO.popen(%{"#{executable}"}, "r+") { |pipe|
|
171
|
-
pipe.print(code)
|
172
|
-
pipe.flush
|
173
|
-
pipe.close_write
|
174
|
-
pipe.read
|
175
|
-
}
|
176
|
-
end
|
177
|
-
|
178
|
-
def run_file_and_capture(file)
|
179
|
-
unless File.file? file
|
180
|
-
raise "file does not exist: `#{file}'"
|
181
|
-
end
|
182
|
-
IO.popen(%{"#{executable}" "#{file}"}, "r") { |pipe|
|
183
|
-
pipe.read
|
184
|
-
}
|
185
|
-
end
|
186
|
-
|
187
|
-
def with_warnings(value = true)
|
188
|
-
previous = $VERBOSE
|
189
|
-
$VERBOSE = value
|
190
|
-
begin
|
191
|
-
yield
|
192
|
-
ensure
|
193
|
-
$VERBOSE = previous
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
def no_warnings(&block)
|
198
|
-
with_warnings(nil, &block)
|
199
|
-
end
|
28
|
+
attr_writer name
|
200
29
|
end
|
201
30
|
|
202
|
-
module Util
|
203
|
-
module_function
|
204
|
-
|
205
|
-
def run_ruby_on_each(*files)
|
206
|
-
files.each { |file|
|
207
|
-
Ruby.run("-w", file)
|
208
|
-
}
|
209
|
-
end
|
210
|
-
|
211
|
-
def to_camel_case(str)
|
212
|
-
str.split('_').map { |t| t.capitalize }.join
|
213
|
-
end
|
214
|
-
|
215
|
-
def write_file(file)
|
216
|
-
contents = yield
|
217
|
-
File.open(file, "wb") { |out|
|
218
|
-
out.print(contents)
|
219
|
-
}
|
220
|
-
contents
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
module InstanceEvalWithArgs
|
225
|
-
module_function
|
226
|
-
|
227
|
-
def with_temp_method(instance, method_name, method_block)
|
228
|
-
(class << instance ; self ; end).class_eval do
|
229
|
-
define_method(method_name, &method_block)
|
230
|
-
begin
|
231
|
-
yield method_name
|
232
|
-
ensure
|
233
|
-
remove_method(method_name)
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
def call_temp_method(instance, method_name, *args, &method_block)
|
239
|
-
with_temp_method(instance, method_name, method_block) {
|
240
|
-
instance.send(method_name, *args)
|
241
|
-
}
|
242
|
-
end
|
243
|
-
|
244
|
-
def instance_eval_with_args(instance, *args, &block)
|
245
|
-
call_temp_method(instance, :__temp_method, *args, &block)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
include AttrLazy
|
250
|
-
include Util
|
251
|
-
|
252
|
-
def initialize(gem_name)
|
253
|
-
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
254
|
-
|
255
|
-
require 'rubygems/package_task'
|
256
|
-
|
257
|
-
@gem_name = gem_name
|
258
|
-
|
259
|
-
yield self
|
260
|
-
|
261
|
-
self.class.instance_methods(false).select { |t|
|
262
|
-
t.to_s =~ %r!\Adefine_!
|
263
|
-
}.sort.each { |method_name|
|
264
|
-
send(method_name)
|
265
|
-
}
|
266
|
-
end
|
267
|
-
|
268
|
-
class << self
|
269
|
-
alias_method :attribute, :attr_lazy_accessor
|
270
|
-
end
|
271
|
-
|
272
|
-
attr_reader :gem_name
|
273
|
-
|
274
31
|
attribute :version_constant_name do
|
275
32
|
"VERSION"
|
276
33
|
end
|
@@ -296,6 +53,10 @@ class Levitate
|
|
296
53
|
mod.const_get(version_constant_name)
|
297
54
|
end or "0.0.0"
|
298
55
|
end
|
56
|
+
|
57
|
+
attribute :required_ruby_version do
|
58
|
+
">= 0"
|
59
|
+
end
|
299
60
|
|
300
61
|
attribute :readme_file do
|
301
62
|
"README.rdoc"
|
@@ -329,16 +90,10 @@ class Levitate
|
|
329
90
|
"spec.html"
|
330
91
|
end
|
331
92
|
|
332
|
-
|
93
|
+
attribute :spec_output do
|
333
94
|
"#{spec_output_dir}/#{spec_output_file}"
|
334
95
|
end
|
335
96
|
|
336
|
-
[:gem, :tgz].each { |ext|
|
337
|
-
attribute ext do
|
338
|
-
"pkg/#{gem_name}-#{version}.#{ext}"
|
339
|
-
end
|
340
|
-
}
|
341
|
-
|
342
97
|
attribute :rcov_options do
|
343
98
|
# workaround for the default rspec task
|
344
99
|
Dir["*"].select { |f| File.directory? f }.inject(Array.new) { |acc, dir|
|
@@ -350,30 +105,18 @@ class Levitate
|
|
350
105
|
} + ["--text-report"]
|
351
106
|
end
|
352
107
|
|
353
|
-
attribute :readme_file do
|
354
|
-
"README.rdoc"
|
355
|
-
end
|
356
|
-
|
357
|
-
attribute :manifest_file do
|
358
|
-
"MANIFEST"
|
359
|
-
end
|
360
|
-
|
361
108
|
attribute :generated_files do
|
362
109
|
[]
|
363
110
|
end
|
364
111
|
|
365
|
-
attribute :
|
366
|
-
|
367
|
-
File.read(manifest_file).split("\n")
|
368
|
-
elsif source_control?
|
369
|
-
IO.popen("git ls-files") { |pipe| pipe.read.split "\n" }
|
370
|
-
end.to_a + [manifest_file] + generated_files
|
112
|
+
attribute :extra_gemspec do
|
113
|
+
lambda { |spec| }
|
371
114
|
end
|
372
115
|
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
116
|
+
attribute :files do
|
117
|
+
if source_control?
|
118
|
+
IO.popen("git ls-files") { |pipe| pipe.read.split "\n" }
|
119
|
+
end.to_a + generated_files
|
377
120
|
end
|
378
121
|
|
379
122
|
attribute :rdoc_files do
|
@@ -381,7 +124,7 @@ class Levitate
|
|
381
124
|
end
|
382
125
|
|
383
126
|
attribute :rdoc_title do
|
384
|
-
"#{gem_name}: #{summary}"
|
127
|
+
"#{gem_name}: #{summary}".sub(/\.\Z/, "")
|
385
128
|
end
|
386
129
|
|
387
130
|
attribute :require_paths do
|
@@ -417,8 +160,6 @@ class Levitate
|
|
417
160
|
attribute :gemspec do
|
418
161
|
Gem::Specification.new do |g|
|
419
162
|
%w[
|
420
|
-
authors
|
421
|
-
email
|
422
163
|
summary
|
423
164
|
version
|
424
165
|
description
|
@@ -426,11 +167,11 @@ class Levitate
|
|
426
167
|
rdoc_options
|
427
168
|
extra_rdoc_files
|
428
169
|
require_paths
|
170
|
+
required_ruby_version
|
429
171
|
].each do |param|
|
430
172
|
t = send(param) and g.send("#{param}=", t)
|
431
173
|
end
|
432
174
|
g.name = gem_name
|
433
|
-
g.has_rdoc = true
|
434
175
|
g.homepage = url if url
|
435
176
|
dependencies.each { |dep|
|
436
177
|
g.add_dependency(*dep)
|
@@ -438,6 +179,9 @@ class Levitate
|
|
438
179
|
development_dependencies.each { |dep|
|
439
180
|
g.add_development_dependency(*dep)
|
440
181
|
}
|
182
|
+
g.authors = developers.map { |d| d[0] }
|
183
|
+
g.email = developers.map { |d| d[1] }
|
184
|
+
extra_gemspec.call(g)
|
441
185
|
end
|
442
186
|
end
|
443
187
|
|
@@ -490,25 +234,17 @@ class Levitate
|
|
490
234
|
}
|
491
235
|
|
492
236
|
attribute :url do
|
493
|
-
"http://#{
|
237
|
+
"http://#{username}.github.com/#{gem_name}"
|
494
238
|
end
|
495
239
|
|
496
|
-
attribute :
|
497
|
-
raise "
|
240
|
+
attribute :username do
|
241
|
+
raise "username not set"
|
498
242
|
end
|
499
243
|
|
500
244
|
attribute :rubyforge_info do
|
501
245
|
nil
|
502
246
|
end
|
503
247
|
|
504
|
-
attribute :authors do
|
505
|
-
developers.map { |d| d[0] }
|
506
|
-
end
|
507
|
-
|
508
|
-
attribute :email do
|
509
|
-
developers.map { |d| d[1] }
|
510
|
-
end
|
511
|
-
|
512
248
|
attribute :dependencies do
|
513
249
|
[]
|
514
250
|
end
|
@@ -521,6 +257,18 @@ class Levitate
|
|
521
257
|
[]
|
522
258
|
end
|
523
259
|
|
260
|
+
attribute :remote_levitate do
|
261
|
+
url = ENV["LEVITATE"] ||
|
262
|
+
"https://github.com/quix/levitate/raw/master/levitate.rb"
|
263
|
+
IO.popen("curl -s #{url}") { |f| f.read }
|
264
|
+
end
|
265
|
+
|
266
|
+
attribute :local_levitate do
|
267
|
+
File.open(__FILE__, "rb") { |f| f.read }
|
268
|
+
end
|
269
|
+
|
270
|
+
#### tasks
|
271
|
+
|
524
272
|
def define_clean
|
525
273
|
require 'rake/clean'
|
526
274
|
task :clean do
|
@@ -530,10 +278,8 @@ class Levitate
|
|
530
278
|
|
531
279
|
def define_package
|
532
280
|
if source_control?
|
533
|
-
|
534
|
-
|
535
|
-
end
|
536
|
-
CLEAN.add manifest_file
|
281
|
+
require 'rubygems/package_task'
|
282
|
+
|
537
283
|
task :package => :clean
|
538
284
|
Gem::PackageTask.new(gemspec).define
|
539
285
|
end
|
@@ -541,7 +287,7 @@ class Levitate
|
|
541
287
|
|
542
288
|
def define_spec
|
543
289
|
unless spec_files.empty?
|
544
|
-
|
290
|
+
no_warnings {
|
545
291
|
require 'spec/rake/spectask'
|
546
292
|
}
|
547
293
|
|
@@ -573,7 +319,7 @@ class Levitate
|
|
573
319
|
|
574
320
|
desc "run specs individually"
|
575
321
|
task :spec_deps do
|
576
|
-
|
322
|
+
run_each_file(*spec_files)
|
577
323
|
end
|
578
324
|
|
579
325
|
task :prerelease => [:spec, :spec_deps]
|
@@ -629,7 +375,7 @@ class Levitate
|
|
629
375
|
|
630
376
|
desc "run tests individually"
|
631
377
|
task :test_deps do
|
632
|
-
|
378
|
+
run_each_file(*test_files)
|
633
379
|
end
|
634
380
|
|
635
381
|
task :prerelease => [:test, :test_deps]
|
@@ -642,7 +388,7 @@ class Levitate
|
|
642
388
|
def define_doc
|
643
389
|
desc "run rdoc"
|
644
390
|
task :doc => :clean_doc do
|
645
|
-
|
391
|
+
gem 'rdoc' rescue nil
|
646
392
|
require 'rdoc/rdoc'
|
647
393
|
args = (
|
648
394
|
gemspec.rdoc_options +
|
@@ -671,6 +417,7 @@ class Levitate
|
|
671
417
|
if source_control?
|
672
418
|
desc "publish docs"
|
673
419
|
task :publish => [:clean, :check_directory, :doc] do
|
420
|
+
current_branch = `git branch`[/^\* (\S+)$/, 1] or raise "??? branch"
|
674
421
|
if rubyforge_info
|
675
422
|
user, project = rubyforge_info
|
676
423
|
Dir.chdir(doc_dir) do
|
@@ -689,6 +436,7 @@ class Levitate
|
|
689
436
|
FileUtils.rmdir "doc"
|
690
437
|
git "add", "."
|
691
438
|
git "commit", "-m", "generated by rdoc"
|
439
|
+
git "checkout", current_branch
|
692
440
|
git "push", "-f", "origin", "gh-pages"
|
693
441
|
end
|
694
442
|
end
|
@@ -697,12 +445,12 @@ class Levitate
|
|
697
445
|
def define_install
|
698
446
|
desc "direct install (no gem)"
|
699
447
|
task :install do
|
700
|
-
Installer.new.
|
448
|
+
Installer.new.install
|
701
449
|
end
|
702
450
|
|
703
451
|
desc "direct uninstall (no gem)"
|
704
452
|
task :uninstall do
|
705
|
-
Installer.new.
|
453
|
+
Installer.new.uninstall
|
706
454
|
end
|
707
455
|
end
|
708
456
|
|
@@ -717,7 +465,10 @@ class Levitate
|
|
717
465
|
def define_ping
|
718
466
|
task :ping do
|
719
467
|
require 'rbconfig'
|
720
|
-
|
468
|
+
[
|
469
|
+
"github.com",
|
470
|
+
("rubyforge.org" if rubyforge_info),
|
471
|
+
].compact.each do |server|
|
721
472
|
cmd = "ping " + (
|
722
473
|
if RbConfig::CONFIG["host"] =~ %r!darwin!
|
723
474
|
"-c2 #{server}"
|
@@ -728,23 +479,26 @@ class Levitate
|
|
728
479
|
unless `#{cmd}` =~ %r!0% packet loss!
|
729
480
|
raise "No ping for #{server}"
|
730
481
|
end
|
731
|
-
|
482
|
+
end
|
483
|
+
end
|
484
|
+
end
|
485
|
+
|
486
|
+
def define_check_levitate
|
487
|
+
task :check_levitate do
|
488
|
+
unless local_levitate == remote_levitate
|
489
|
+
raise "levitate is out of date"
|
490
|
+
end
|
732
491
|
end
|
733
492
|
end
|
734
493
|
|
735
494
|
def define_update_levitate
|
736
|
-
url = ENV["LEVITATE"] ||
|
737
|
-
"https://github.com/quix/levitate/raw/master/levitate.rb"
|
738
495
|
task :update_levitate do
|
739
|
-
if
|
740
|
-
|
741
|
-
puts "Already up-to-date."
|
742
|
-
else
|
743
|
-
git "commit", __FILE__, "-m", "updated levitate"
|
744
|
-
puts "Updated levitate."
|
745
|
-
end
|
496
|
+
if local_levitate == remote_levitate
|
497
|
+
puts "Already up-to-date."
|
746
498
|
else
|
747
|
-
|
499
|
+
File.open(__FILE__, "w") { |f| f.print(remote_levitate) }
|
500
|
+
git "commit", __FILE__, "-m", "update levitate"
|
501
|
+
puts "Updated levitate."
|
748
502
|
end
|
749
503
|
end
|
750
504
|
end
|
@@ -769,30 +523,22 @@ class Levitate
|
|
769
523
|
end
|
770
524
|
end
|
771
525
|
|
772
|
-
def last_release
|
773
|
-
`git tag`.lines.select { |t| t.index(gem_name) == 0 }.last.chomp
|
774
|
-
end
|
775
|
-
|
776
|
-
def git(*args)
|
777
|
-
sh "git", *args
|
778
|
-
end
|
779
|
-
|
780
|
-
def create_manifest
|
781
|
-
write_file(manifest_file) {
|
782
|
-
files.sort.join("\n")
|
783
|
-
}
|
784
|
-
end
|
785
|
-
|
786
526
|
def define_release
|
787
|
-
task :prerelease => [
|
527
|
+
task :prerelease => [
|
528
|
+
:clean,
|
529
|
+
:check_directory,
|
530
|
+
:check_levitate,
|
531
|
+
:ping,
|
532
|
+
history_file
|
533
|
+
]
|
788
534
|
|
789
535
|
task :finish_release do
|
790
536
|
git "tag", "#{gem_name}-" + version.to_s
|
791
537
|
git "push", "--tags", "origin", "master"
|
792
|
-
sh "gem", "push", gem
|
538
|
+
sh "gem", "push", "pkg/#{gem_name}-#{version}.gem"
|
793
539
|
end
|
794
540
|
|
795
|
-
task :release => [:prerelease, :package, :finish_release]
|
541
|
+
task :release => [:prerelease, :package, :finish_release, :publish]
|
796
542
|
end
|
797
543
|
|
798
544
|
def define_debug_gem
|
@@ -800,7 +546,23 @@ class Levitate
|
|
800
546
|
puts gemspec.to_ruby
|
801
547
|
end
|
802
548
|
end
|
803
|
-
|
549
|
+
|
550
|
+
#### helpers
|
551
|
+
|
552
|
+
def files_in_require_paths
|
553
|
+
require_paths.inject([]) { |acc, dir|
|
554
|
+
acc + Dir.glob("#{dir}/**/*.rb")
|
555
|
+
}
|
556
|
+
end
|
557
|
+
|
558
|
+
def last_release
|
559
|
+
`git tag`.lines.select { |t| t.index(gem_name) == 0 }.last.chomp
|
560
|
+
end
|
561
|
+
|
562
|
+
def git(*args)
|
563
|
+
sh "git", *args
|
564
|
+
end
|
565
|
+
|
804
566
|
def open_browser(*files)
|
805
567
|
sh(*([browser].flatten + files))
|
806
568
|
end
|
@@ -809,7 +571,7 @@ class Levitate
|
|
809
571
|
task_names.each { |task_name|
|
810
572
|
Rake::Task[task_name].actions.map! { |action|
|
811
573
|
lambda { |*args|
|
812
|
-
|
574
|
+
no_warnings {
|
813
575
|
action.call(*args)
|
814
576
|
}
|
815
577
|
}
|
@@ -825,11 +587,110 @@ class Levitate
|
|
825
587
|
File.directory? ".git"
|
826
588
|
end
|
827
589
|
|
828
|
-
|
829
|
-
include Util
|
830
|
-
include InstanceEvalWithArgs
|
590
|
+
#### utility for instance and class
|
831
591
|
|
832
|
-
|
592
|
+
module Util
|
593
|
+
def ruby_bin
|
594
|
+
require 'rbconfig'
|
595
|
+
|
596
|
+
name = File.join(
|
597
|
+
RbConfig::CONFIG["bindir"],
|
598
|
+
RbConfig::CONFIG["RUBY_INSTALL_NAME"]
|
599
|
+
)
|
600
|
+
|
601
|
+
if RbConfig::CONFIG["host"] =~ %r!(mswin|cygwin|mingw)! and
|
602
|
+
File.basename(name) !~ %r!\.(exe|com|bat|cmd)\Z!i
|
603
|
+
name + RbConfig::CONFIG["EXEEXT"]
|
604
|
+
else
|
605
|
+
name
|
606
|
+
end
|
607
|
+
end
|
608
|
+
|
609
|
+
def ruby_command
|
610
|
+
[ruby_bin] + Levitate.ruby_opts.to_a
|
611
|
+
end
|
612
|
+
|
613
|
+
def ruby_command_string
|
614
|
+
ruby_command.join(" ")
|
615
|
+
end
|
616
|
+
|
617
|
+
def run(*args)
|
618
|
+
cmd = ruby_command + args
|
619
|
+
unless system(*cmd)
|
620
|
+
cmd_str = cmd.map { |t| "'#{t}'" }.join(", ")
|
621
|
+
raise "system(#{cmd_str}) failed with status #{$?.exitstatus}"
|
622
|
+
end
|
623
|
+
end
|
624
|
+
|
625
|
+
def run_each_file(*files)
|
626
|
+
files.each { |file|
|
627
|
+
run("-w", file)
|
628
|
+
}
|
629
|
+
end
|
630
|
+
|
631
|
+
def run_code_and_capture(code)
|
632
|
+
IO.popen(ruby_command_string, "r+") { |pipe|
|
633
|
+
pipe.print(code)
|
634
|
+
pipe.flush
|
635
|
+
pipe.close_write
|
636
|
+
pipe.read
|
637
|
+
}
|
638
|
+
end
|
639
|
+
|
640
|
+
def run_file_and_capture(file)
|
641
|
+
unless File.file? file
|
642
|
+
raise "file does not exist: `#{file}'"
|
643
|
+
end
|
644
|
+
IO.popen(ruby_command_string + " " + file, "r") { |pipe|
|
645
|
+
pipe.read
|
646
|
+
}
|
647
|
+
end
|
648
|
+
|
649
|
+
def with_warnings(value = true)
|
650
|
+
previous = $VERBOSE
|
651
|
+
$VERBOSE = value
|
652
|
+
begin
|
653
|
+
yield
|
654
|
+
ensure
|
655
|
+
$VERBOSE = previous
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
def no_warnings(&block)
|
660
|
+
with_warnings(nil, &block)
|
661
|
+
end
|
662
|
+
|
663
|
+
def to_camel_case(str)
|
664
|
+
str.split('_').map { |t| t.capitalize }.join
|
665
|
+
end
|
666
|
+
|
667
|
+
def write_file(file)
|
668
|
+
contents = yield
|
669
|
+
File.open(file, "wb") { |out|
|
670
|
+
out.print(contents)
|
671
|
+
}
|
672
|
+
contents
|
673
|
+
end
|
674
|
+
|
675
|
+
def instance_exec2(obj, *args, &block)
|
676
|
+
method_name = ["_", obj.object_id, "_", Thread.current.object_id].join
|
677
|
+
(class << obj ; self ; end).class_eval do
|
678
|
+
define_method method_name, &block
|
679
|
+
begin
|
680
|
+
obj.send(method_name, *args)
|
681
|
+
ensure
|
682
|
+
remove_method method_name
|
683
|
+
end
|
684
|
+
end
|
685
|
+
end
|
686
|
+
end
|
687
|
+
extend Util
|
688
|
+
include Util
|
689
|
+
|
690
|
+
#### public helpers for testing
|
691
|
+
|
692
|
+
class << self
|
693
|
+
# From 'minitest' by Ryan Davis.
|
833
694
|
def capture_io
|
834
695
|
require 'stringio'
|
835
696
|
|
@@ -864,10 +725,10 @@ class Levitate
|
|
864
725
|
Tempfile.open("run-rdoc-code") { |temp_file|
|
865
726
|
temp_file.print(final_code)
|
866
727
|
temp_file.close
|
867
|
-
actual =
|
728
|
+
actual = run_file_and_capture(temp_file.path).chomp
|
868
729
|
}
|
869
730
|
|
870
|
-
|
731
|
+
instance_exec2(instance, expected, actual, index, &block)
|
871
732
|
end
|
872
733
|
|
873
734
|
def run_doc_section(file, section, instance, &block)
|
@@ -887,6 +748,7 @@ class Levitate
|
|
887
748
|
raise "parse error"
|
888
749
|
end
|
889
750
|
)
|
751
|
+
code.gsub!(/^\s*%.*$/, "") # ignore shell command examples
|
890
752
|
run_doc_code(code, expected, index, instance, &block)
|
891
753
|
index += 1
|
892
754
|
}
|
@@ -933,5 +795,57 @@ class Levitate
|
|
933
795
|
end
|
934
796
|
Object.const_set("Test#{file}".gsub(".", ""), klass)
|
935
797
|
end
|
798
|
+
|
799
|
+
def ruby_opts
|
800
|
+
@ruby_opts ||= []
|
801
|
+
end
|
802
|
+
attr_writer :ruby_opts
|
803
|
+
end
|
804
|
+
|
805
|
+
#### raw install, bypass gems
|
806
|
+
|
807
|
+
class Installer
|
808
|
+
def initialize
|
809
|
+
require 'fileutils'
|
810
|
+
require 'rbconfig'
|
811
|
+
require 'find'
|
812
|
+
|
813
|
+
@fu = FileUtils::Verbose
|
814
|
+
@spec = []
|
815
|
+
|
816
|
+
rb_root = RbConfig::CONFIG["sitelibdir"]
|
817
|
+
|
818
|
+
Find.find "lib" do |source|
|
819
|
+
next if source == "lib"
|
820
|
+
next unless File.directory?(source) || File.extname(source) == ".rb"
|
821
|
+
dest = File.join(rb_root, source.sub(%r!\Alib/!, ""))
|
822
|
+
@spec << [source, dest]
|
823
|
+
end
|
824
|
+
end
|
825
|
+
|
826
|
+
def install
|
827
|
+
@spec.each do |source, dest|
|
828
|
+
if File.directory?(source)
|
829
|
+
@fu.mkdir(dest) unless File.directory?(dest)
|
830
|
+
else
|
831
|
+
@fu.install(source, dest)
|
832
|
+
end
|
833
|
+
end
|
834
|
+
end
|
835
|
+
|
836
|
+
def uninstall
|
837
|
+
@spec.reverse.each do |source, dest|
|
838
|
+
if File.directory?(source)
|
839
|
+
@fu.rmdir(dest) if File.directory?(dest)
|
840
|
+
else
|
841
|
+
@fu.rm(dest) if File.file?(dest)
|
842
|
+
end
|
843
|
+
end
|
844
|
+
end
|
936
845
|
end
|
937
846
|
end
|
847
|
+
|
848
|
+
lambda do
|
849
|
+
config = File.join(File.dirname(__FILE__), "levitate_config.rb")
|
850
|
+
require config if File.file? config
|
851
|
+
end.call
|
data/lib/comp_tree/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: comp_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.1.
|
5
|
+
version: 1.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James M. Lawrence
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-05-18 00:00:00 Z
|
15
14
|
dependencies: []
|
16
15
|
|
17
16
|
description: CompTree is a parallel computation tree structure based upon concepts from pure functional programming.
|
@@ -48,8 +47,6 @@ files:
|
|
48
47
|
- test/readme_test.rb
|
49
48
|
- test/sequential_test.rb
|
50
49
|
- test/throw_test.rb
|
51
|
-
- MANIFEST
|
52
|
-
has_rdoc: true
|
53
50
|
homepage: http://quix.github.com/comp_tree
|
54
51
|
licenses: []
|
55
52
|
|
@@ -58,7 +55,7 @@ rdoc_options:
|
|
58
55
|
- --main
|
59
56
|
- README.rdoc
|
60
57
|
- --title
|
61
|
-
- "comp_tree: A simple framework for automatic parallelism
|
58
|
+
- "comp_tree: A simple framework for automatic parallelism"
|
62
59
|
- --exclude
|
63
60
|
- lib/comp_tree/algorithm.rb
|
64
61
|
- --exclude
|
@@ -88,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
85
|
requirements: []
|
89
86
|
|
90
87
|
rubyforge_project:
|
91
|
-
rubygems_version: 1.
|
88
|
+
rubygems_version: 1.8.2
|
92
89
|
signing_key:
|
93
90
|
specification_version: 3
|
94
91
|
summary: A simple framework for automatic parallelism.
|
data/MANIFEST
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
CHANGES.rdoc
|
2
|
-
MANIFEST
|
3
|
-
README.rdoc
|
4
|
-
Rakefile
|
5
|
-
devel/levitate.rb
|
6
|
-
lib/comp_tree.rb
|
7
|
-
lib/comp_tree/algorithm.rb
|
8
|
-
lib/comp_tree/driver.rb
|
9
|
-
lib/comp_tree/error.rb
|
10
|
-
lib/comp_tree/node.rb
|
11
|
-
lib/comp_tree/queue/queue.rb
|
12
|
-
lib/comp_tree/queue/queue_18.rb
|
13
|
-
lib/comp_tree/queue/queue_19.rb
|
14
|
-
lib/comp_tree/version.rb
|
15
|
-
test/basic_test.rb
|
16
|
-
test/circular_test.rb
|
17
|
-
test/comp_tree_test_base.rb
|
18
|
-
test/drain_test.rb
|
19
|
-
test/exception_test.rb
|
20
|
-
test/flood_test.rb
|
21
|
-
test/grind_test.rb
|
22
|
-
test/readme_test.rb
|
23
|
-
test/sequential_test.rb
|
24
|
-
test/throw_test.rb
|