benry-cmdopt 2.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +13 -0
- data/MIT-LICENSE +1 -1
- data/README.md +15 -17
- data/benry-cmdopt.gemspec +4 -5
- data/doc/benry-cmdopt.html +152 -154
- data/doc/css/style.css +8 -0
- data/lib/benry/cmdopt.rb +3 -3
- data/test/cmdopt_test.rb +17 -0
- metadata +2 -7
- data/Rakefile.rb +0 -11
- data/task/common-task.rb +0 -138
- data/task/package-task.rb +0 -72
- data/task/readme-task.rb +0 -125
- data/task/test-task.rb +0 -81
data/doc/css/style.css
CHANGED
@@ -40,6 +40,10 @@ h3 {
|
|
40
40
|
font-size: 180%;
|
41
41
|
font-weight: normal;
|
42
42
|
}
|
43
|
+
h2 > code, h3 > code {
|
44
|
+
color: #39c;
|
45
|
+
font-weight: bold;
|
46
|
+
}
|
43
47
|
|
44
48
|
|
45
49
|
section.section {
|
@@ -85,6 +89,10 @@ code {
|
|
85
89
|
padding: 1px 3px;
|
86
90
|
color: #444;
|
87
91
|
}
|
92
|
+
h2 > code, h3 > code {
|
93
|
+
border: none;
|
94
|
+
background-color: transparent;
|
95
|
+
}
|
88
96
|
|
89
97
|
|
90
98
|
dt.bold {
|
data/lib/benry/cmdopt.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
###
|
5
|
-
### $Release: 2.0.
|
5
|
+
### $Release: 2.0.2 $
|
6
6
|
### $Copyright: copyright(c) 2021 kwatch@gmail.com $
|
7
7
|
### $License: MIT License $
|
8
8
|
###
|
@@ -23,7 +23,7 @@ end
|
|
23
23
|
module Benry::CmdOpt
|
24
24
|
|
25
25
|
|
26
|
-
VERSION = '$Release: 2.0.
|
26
|
+
VERSION = '$Release: 2.0.2 $'.split()[1]
|
27
27
|
|
28
28
|
|
29
29
|
def self.new()
|
@@ -120,7 +120,7 @@ module Benry::CmdOpt
|
|
120
120
|
#; [!rhhji] raises SchemaError when key is not a Symbol.
|
121
121
|
key.nil? || key.is_a?(Symbol) or
|
122
122
|
raise _error("add(#{key.inspect}, #{optdef.inspect}): The first arg should be a Symbol as an option key.")
|
123
|
-
#; [!vq6eq] raises SchemaError when help message is missing.
|
123
|
+
#; [!vq6eq] raises SchemaError when help message is missing.
|
124
124
|
desc.nil? || desc.is_a?(String) or
|
125
125
|
raise _error("add(#{key.inspect}, #{optdef.inspect}): Help message required as 3rd argument.")
|
126
126
|
#; [!7hi2d] takes command option definition string.
|
data/test/cmdopt_test.rb
CHANGED
@@ -1471,6 +1471,12 @@ END
|
|
1471
1471
|
ok {item.value} == 4
|
1472
1472
|
end
|
1473
1473
|
|
1474
|
+
spec "[!tu4k3] returns self." do
|
1475
|
+
cmdopt = Benry::CmdOpt.new()
|
1476
|
+
x = cmdopt.add(:version, "-v, --version", "version")
|
1477
|
+
ok {x}.same?(cmdopt)
|
1478
|
+
end
|
1479
|
+
|
1474
1480
|
end
|
1475
1481
|
|
1476
1482
|
|
@@ -1569,6 +1575,17 @@ END
|
|
1569
1575
|
@cmdopt.add(:debug, "-d, --debug[=<LEVEL>]", "debug", type: Integer)
|
1570
1576
|
end
|
1571
1577
|
|
1578
|
+
spec "[!7gc2m] parses command options." do
|
1579
|
+
args = ["-d", "x", "y"]
|
1580
|
+
@cmdopt.parse(args)
|
1581
|
+
ok {args} == ["x", "y"]
|
1582
|
+
end
|
1583
|
+
|
1584
|
+
spec "[!no4xu] returns option values as dict." do
|
1585
|
+
args = ["-d", "x"]
|
1586
|
+
ok {@cmdopt.parse(args)} == {:debug=>true}
|
1587
|
+
end
|
1588
|
+
|
1572
1589
|
spec "[!areof] handles only OptionError when block given." do
|
1573
1590
|
errmsg = nil
|
1574
1591
|
errcls = nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: benry-cmdopt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kwatch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oktest
|
@@ -36,15 +36,10 @@ files:
|
|
36
36
|
- CHANGES.md
|
37
37
|
- MIT-LICENSE
|
38
38
|
- README.md
|
39
|
-
- Rakefile.rb
|
40
39
|
- benry-cmdopt.gemspec
|
41
40
|
- doc/benry-cmdopt.html
|
42
41
|
- doc/css/style.css
|
43
42
|
- lib/benry/cmdopt.rb
|
44
|
-
- task/common-task.rb
|
45
|
-
- task/package-task.rb
|
46
|
-
- task/readme-task.rb
|
47
|
-
- task/test-task.rb
|
48
43
|
- test/cmdopt_test.rb
|
49
44
|
homepage: https://kwatch.github.io/benry-ruby/benry-cmdopt.html
|
50
45
|
licenses:
|
data/Rakefile.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
PROJECT = "benry-cmdopt"
|
5
|
-
RELEASE = ENV['RELEASE'] || "0.0.0"
|
6
|
-
COPYRIGHT = "copyright(c) 2021 kwatch@gmail.com"
|
7
|
-
LICENSE = "MIT License"
|
8
|
-
|
9
|
-
#RUBY_VERSIONS = ["3.2", "3.1", "3.0", "2.7", "2.6", "2.5", "2.4", "2.3"]
|
10
|
-
|
11
|
-
Dir.glob('./task/*-task.rb').each {|x| require x }
|
data/task/common-task.rb
DELETED
@@ -1,138 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
defined? PROJECT or abort "PROJECT required."
|
5
|
-
defined? RELEASE or abort "RELEASE required."
|
6
|
-
defined? COPYRIGHT or abort "COPYRIGHT required."
|
7
|
-
defined? LICENSE or abort "LICENSE required."
|
8
|
-
|
9
|
-
RELEASE =~ /\A\d+\.\d+\.\d+/ or abort "RELEASE=#{RELEASE}: invalid release number."
|
10
|
-
|
11
|
-
|
12
|
-
require 'rake/clean'
|
13
|
-
CLEAN << "build"
|
14
|
-
CLEAN.concat Dir.glob("#{PROJECT}-*.gem").collect {|x| x.sub(/\.gem$/, '') }
|
15
|
-
CLOBBER.concat Dir.glob("#{PROJECT}-*.gem")
|
16
|
-
|
17
|
-
|
18
|
-
task :default do
|
19
|
-
sh "rake -T", verbose: false
|
20
|
-
end unless Rake::Task.task_defined?(:default)
|
21
|
-
|
22
|
-
|
23
|
-
desc "show release guide"
|
24
|
-
task :guide do
|
25
|
-
do_guide()
|
26
|
-
end
|
27
|
-
|
28
|
-
def do_guide()
|
29
|
-
RELEASE != '0.0.0' or abort "** ERROR: 'RELEASE=X.X.X' required."
|
30
|
-
puts guide_message(PROJECT, RELEASE)
|
31
|
-
end
|
32
|
-
|
33
|
-
def guide_message(project, release)
|
34
|
-
target = "#{project}-#{release}"
|
35
|
-
tag = "#{project}-#{release}"
|
36
|
-
puts <<END
|
37
|
-
How to release:
|
38
|
-
|
39
|
-
$ git diff .
|
40
|
-
$ git status .
|
41
|
-
$ which ruby
|
42
|
-
$ rake test
|
43
|
-
$ rake test:all
|
44
|
-
$ rake readme:execute # optional
|
45
|
-
$ rake readme:toc # optional
|
46
|
-
$ rake package RELEASE=#{release}
|
47
|
-
$ rake package:extract # confirm files in gem file
|
48
|
-
$ (cd #{target}/data; find . -type f)
|
49
|
-
$ gem install #{target}.gem # confirm gem package
|
50
|
-
$ gem uninstall #{project}
|
51
|
-
$ gem push #{target}.gem # publish gem to rubygems.org
|
52
|
-
$ git tag #{tag} # or: git tag ruby-#{tag}
|
53
|
-
$ git push
|
54
|
-
$ git push --tags
|
55
|
-
$ rake clean
|
56
|
-
END
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
desc "create 'README.md' and 'doc/*.html'"
|
61
|
-
task :doc do
|
62
|
-
x = PROJECT
|
63
|
-
cd "doc" do
|
64
|
-
sh "../../docs/md2 --md #{x}.mdx > ../README.md"
|
65
|
-
sh "../../docs/md2 #{x}.mdx > #{x}.html"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
desc "copy 'doc/*.html' to '../docs/'"
|
70
|
-
task 'doc:export' do
|
71
|
-
RELEASE != '0.0.0' or abort "** ERROR: 'RELEASE=X.X.X' required."
|
72
|
-
x = PROJECT
|
73
|
-
cp "doc/#{x}.html", "../docs/"
|
74
|
-
edit_file!("../docs/#{x}.html")
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
desc "edit metadata in files"
|
79
|
-
task :edit do
|
80
|
-
do_edit()
|
81
|
-
end
|
82
|
-
|
83
|
-
def do_edit()
|
84
|
-
target_files().each do |fname|
|
85
|
-
edit_file!(fname)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def target_files()
|
90
|
-
$_target_files ||= begin
|
91
|
-
spec_src = File.read("#{PROJECT}.gemspec", encoding: 'utf-8')
|
92
|
-
spec = eval spec_src
|
93
|
-
spec.name == PROJECT or
|
94
|
-
abort "** ERROR: '#{PROJECT}' != '#{spec.name}' (project name in gemspec file)"
|
95
|
-
spec.files + Dir.glob("doc/*.mdx")
|
96
|
-
end
|
97
|
-
return $_target_files
|
98
|
-
end
|
99
|
-
|
100
|
-
def edit_file!(filename, verbose: true)
|
101
|
-
changed = edit_file(filename) do |s|
|
102
|
-
s = s.gsub(/\$Release[:].*?\$/, "$"+"Release: #{RELEASE} $")
|
103
|
-
s = s.gsub(/\$Copyright[:].*?\$/, "$"+"Copyright: #{COPYRIGHT} $")
|
104
|
-
s = s.gsub(/\$License[:].*?\$/, "$"+"License: #{LICENSE} $")
|
105
|
-
s
|
106
|
-
end
|
107
|
-
if verbose
|
108
|
-
puts "[C] #{filename}" if changed
|
109
|
-
puts "[U] #{filename}" unless changed
|
110
|
-
end
|
111
|
-
return changed
|
112
|
-
end
|
113
|
-
|
114
|
-
def edit_file(filename)
|
115
|
-
File.open(filename, 'rb+') do |f|
|
116
|
-
s1 = f.read()
|
117
|
-
s2 = yield s1
|
118
|
-
if s1 != s2
|
119
|
-
f.rewind()
|
120
|
-
f.truncate(0)
|
121
|
-
f.write(s2)
|
122
|
-
true
|
123
|
-
else
|
124
|
-
false
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
|
130
|
-
desc nil
|
131
|
-
task :'relink' do
|
132
|
-
Dir.glob("task/*.rb").each do |x|
|
133
|
-
src = "../" + x
|
134
|
-
next if File.identical?(src, x)
|
135
|
-
rm x
|
136
|
-
ln src, x
|
137
|
-
end
|
138
|
-
end
|
data/task/package-task.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
desc "create package (*.gem)"
|
5
|
-
task :package do
|
6
|
-
do_package()
|
7
|
-
end
|
8
|
-
|
9
|
-
def do_package()
|
10
|
-
RELEASE != '0.0.0' or abort "** ERROR: 'RELEASE=X.X.X' required."
|
11
|
-
## copy
|
12
|
-
dir = "build"
|
13
|
-
rm_rf dir if File.exist?(dir)
|
14
|
-
mkdir dir
|
15
|
-
target_files().each do |file|
|
16
|
-
dest = File.join(dir, File.dirname(file))
|
17
|
-
mkdir_p dest, :verbose=>false unless File.exist?(dest)
|
18
|
-
cp file, "#{dir}/#{file}"
|
19
|
-
end
|
20
|
-
## edit
|
21
|
-
Dir.glob("#{dir}/**/*").each do |file|
|
22
|
-
next unless File.file?(file)
|
23
|
-
edit_file!(file, verbose: false)
|
24
|
-
end
|
25
|
-
## build
|
26
|
-
chdir dir do
|
27
|
-
sh "gem build #{PROJECT}.gemspec"
|
28
|
-
end
|
29
|
-
mv "#{dir}/#{PROJECT}-#{RELEASE}.gem", "."
|
30
|
-
rm_rf dir
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
desc "extract latest gem file"
|
35
|
-
task :'package:extract' do
|
36
|
-
do_package_extract()
|
37
|
-
end
|
38
|
-
|
39
|
-
def do_package_extract()
|
40
|
-
gemfile = Dir.glob("#{PROJECT}-*.gem").sort_by {|x| File.mtime(x) }.last
|
41
|
-
dir = gemfile.sub(/\.gem$/, '')
|
42
|
-
rm_rf dir if File.exist?(dir)
|
43
|
-
mkdir dir
|
44
|
-
mkdir "#{dir}/data"
|
45
|
-
cd dir do
|
46
|
-
sh "tar xvf ../#{gemfile}"
|
47
|
-
sh "gunzip *.gz"
|
48
|
-
cd "data" do
|
49
|
-
sh "tar xvf ../data.tar"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
desc "upload gem file to rubygems.org"
|
56
|
-
task :publish do
|
57
|
-
do_publish()
|
58
|
-
end
|
59
|
-
|
60
|
-
def do_publish()
|
61
|
-
RELEASE != '0.0.0' or abort "** ERROR: 'RELEASE=X.X.X' required."
|
62
|
-
gemfile = "#{PROJECT}-#{RELEASE}.gem"
|
63
|
-
print "** Are you sure to publish #{gemfile}? [y/N]: "
|
64
|
-
answer = $stdin.gets().strip()
|
65
|
-
if answer.downcase == "y"
|
66
|
-
sh "gem push #{gemfile}"
|
67
|
-
#sh "git tag ruby-#{PROJECT}-#{RELEASE}"
|
68
|
-
sh "git tag #{PROJECT}-#{RELEASE}"
|
69
|
-
sh "#git push"
|
70
|
-
sh "#git push --tags"
|
71
|
-
end
|
72
|
-
end
|
data/task/readme-task.rb
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
README_FILE = "README.md" unless defined? README_FILE
|
4
|
-
README_EXTRACT = /^[Ff]ile: +(\S+)/ unless defined? README_EXTRACT
|
5
|
-
README_CODESTART = /^```\w+$/ unless defined? README_CODESTART
|
6
|
-
README_CODEEND = /^```$/ unless defined? README_CODEEND
|
7
|
-
README_DESTDIR = "tmp/readme" unless defined? README_DESTDIR
|
8
|
-
|
9
|
-
require 'rake/clean'
|
10
|
-
CLEAN << "README.html"
|
11
|
-
|
12
|
-
|
13
|
-
def readme_extract_callback(filename, str)
|
14
|
-
return str
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
namespace :readme do
|
19
|
-
|
20
|
-
|
21
|
-
desc "retrieve scripts from #{README_FILE}"
|
22
|
-
task :retrieve do
|
23
|
-
do_readme_retrieve()
|
24
|
-
end
|
25
|
-
|
26
|
-
def do_readme_retrieve()
|
27
|
-
dir = README_DESTDIR
|
28
|
-
rm_rf dir if File.exist?(dir)
|
29
|
-
mkdir_p dir
|
30
|
-
s = File.read(README_FILE, encoding: 'utf-8')
|
31
|
-
filename = nil
|
32
|
-
buf = nil
|
33
|
-
s.each_line do |line|
|
34
|
-
case line
|
35
|
-
when README_EXTRACT
|
36
|
-
filename = $1
|
37
|
-
next
|
38
|
-
when README_CODESTART
|
39
|
-
if filename
|
40
|
-
buf = []
|
41
|
-
end
|
42
|
-
next
|
43
|
-
when README_CODEEND
|
44
|
-
if filename && buf
|
45
|
-
newfile = "#{dir}/#{filename}"
|
46
|
-
unless File.exist?(File.dirname(newfile))
|
47
|
-
mkdir_p File.dirname(newfile)
|
48
|
-
end
|
49
|
-
str = readme_extract_callback(filename, buf.join())
|
50
|
-
File.write(newfile, str, encoding: 'utf-8')
|
51
|
-
puts "[retrieve] #{newfile}"
|
52
|
-
end
|
53
|
-
filename = nil
|
54
|
-
buf = nil
|
55
|
-
next
|
56
|
-
end
|
57
|
-
#
|
58
|
-
if buf
|
59
|
-
buf << line
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
desc "execute code in readme file"
|
66
|
-
task :execute => :retrieve do
|
67
|
-
do_readme_execute()
|
68
|
-
end
|
69
|
-
|
70
|
-
def do_readme_execute()
|
71
|
-
Dir.glob(README_DESTDIR+'/**/*.rb').sort.each do |fpath|
|
72
|
-
puts "========================================"
|
73
|
-
sh "ruby -I lib #{fpath}" do end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
desc "builds table of contents"
|
79
|
-
task :toc do
|
80
|
-
do_readme_toc()
|
81
|
-
end
|
82
|
-
|
83
|
-
def do_readme_toc()
|
84
|
-
url = ENV['README_URL'] or abort "$README_URL required."
|
85
|
-
mkdir "tmp" unless Dir.exist?("tmp")
|
86
|
-
htmlfile = "tmp/README.html"
|
87
|
-
sh "curl -s -o #{htmlfile} #{url}"
|
88
|
-
#rexp = /<h(\d) dir="auto"><a id="(.*?)" class="anchor".*><\/a>(.*)<\/h\1>/
|
89
|
-
rexp = /<h(\d) id="user-content-.*?" dir="auto"><a class="heading-link" href="#(.*?)">(.*)<svg/
|
90
|
-
html_str = File.read(htmlfile, encoding: 'utf-8')
|
91
|
-
buf = []
|
92
|
-
html_str.scan(rexp) do
|
93
|
-
level = $1.to_i
|
94
|
-
id = $2
|
95
|
-
title = $3
|
96
|
-
next if title =~ /Table of Contents/
|
97
|
-
title = title.gsub(/<\/?code>/, '`')
|
98
|
-
anchor = id.sub(/^user-content-/, '')
|
99
|
-
indent = " " * (level - 1)
|
100
|
-
buf << "#{indent}* <a href=\"##{anchor}\">#{title}</a>\n"
|
101
|
-
end
|
102
|
-
buf.shift() if buf[0] && buf[0] =~ /^\* /
|
103
|
-
toc_str = buf.join()
|
104
|
-
#
|
105
|
-
mdfile = README_FILE
|
106
|
-
changed = File.open(mdfile, "r+", encoding: 'utf-8') do |f|
|
107
|
-
s1 = f.read()
|
108
|
-
s2 = s1.sub(/(<!-- TOC -->\n).*(<!-- \/TOC -->\n)/m) {
|
109
|
-
[$1, toc_str, $2].join("\n")
|
110
|
-
}
|
111
|
-
if s1 != s2
|
112
|
-
f.rewind()
|
113
|
-
f.truncate(0)
|
114
|
-
f.write(s2)
|
115
|
-
true
|
116
|
-
else
|
117
|
-
false
|
118
|
-
end
|
119
|
-
end
|
120
|
-
puts "[changed] #{mdfile}" if changed
|
121
|
-
puts "[not changed] #{mdfile}" unless changed
|
122
|
-
end
|
123
|
-
|
124
|
-
|
125
|
-
end
|
data/task/test-task.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
unless defined?(RUBY_VERSIONS)
|
5
|
-
RUBY_VERSIONS = (
|
6
|
-
if ENV['RUBY_VERSIONS']
|
7
|
-
ENV['RUBY_VERSIONS'].split()
|
8
|
-
else
|
9
|
-
["3.2", "3.1", "3.0", "2.7", "2.6", "2.5", "2.4", "2.3"]
|
10
|
-
end
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
desc "run test"
|
16
|
-
task :test do
|
17
|
-
do_test()
|
18
|
-
end
|
19
|
-
|
20
|
-
def do_test()
|
21
|
-
run_test()
|
22
|
-
end
|
23
|
-
|
24
|
-
def run_test(ruby=nil, &b)
|
25
|
-
run_oktest(ruby, &b)
|
26
|
-
end
|
27
|
-
|
28
|
-
def run_minitest(ruby=nil, &b)
|
29
|
-
files = File.exist?("test/run_all.rb") \
|
30
|
-
? ["test/run_all.rb"] \
|
31
|
-
: Dir.glob("test/**/*_test.rb")
|
32
|
-
if ruby
|
33
|
-
sh(ruby, *files, &b)
|
34
|
-
else
|
35
|
-
ruby(*files, &b)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def run_oktest(ruby=nil, &b)
|
40
|
-
argstr = "-r oktest -e Oktest.main -- test -sp"
|
41
|
-
if ruby
|
42
|
-
sh("#{ruby} #{argstr}", &b)
|
43
|
-
else
|
44
|
-
ruby(argstr, &b)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
desc "run test in different ruby versions"
|
50
|
-
task :'test:all' do
|
51
|
-
do_test_all()
|
52
|
-
end
|
53
|
-
|
54
|
-
def do_test_all()
|
55
|
-
ENV['VS_HOME'] or
|
56
|
-
abort "[ERROR] rake test:all: '$VS_HOME' environment var required."
|
57
|
-
vs_home = ENV['VS_HOME'].split(/[:;]/).first
|
58
|
-
ruby_versions = RUBY_VERSIONS
|
59
|
-
test_all(vs_home, ruby_versions)
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_all(vs_home, ruby_versions)
|
63
|
-
header = proc {|s| "\033[0;36m=============== #{s} ===============\033[0m" }
|
64
|
-
error = proc {|s| "\033[0;31m** #{s}\033[0m" }
|
65
|
-
comp = proc {|x, y| x.to_s.split('.').map(&:to_i) <=> y.to_s.split('.').map(&:to_i) }
|
66
|
-
ruby_versions.each do |ver|
|
67
|
-
dir = Dir.glob("#{vs_home}/ruby/#{ver}.*/").sort_by(&comp).last
|
68
|
-
puts ""
|
69
|
-
if dir
|
70
|
-
puts header.("#{ver} (#{dir})")
|
71
|
-
run_test("#{dir}/bin/ruby") do |ok, res|
|
72
|
-
$stderr.puts error.("test failed") unless ok
|
73
|
-
end
|
74
|
-
sleep 0.2
|
75
|
-
else
|
76
|
-
puts header.(ver)
|
77
|
-
$stderr.puts error.("ruby #{ver} not found")
|
78
|
-
sleep 1.0
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|