benry-cmdopt 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +29 -3
- data/MIT-LICENSE +21 -0
- data/README.md +445 -119
- data/Rakefile.rb +6 -87
- data/benry-cmdopt.gemspec +23 -21
- data/doc/benry-cmdopt.html +650 -0
- data/doc/css/style.css +160 -0
- data/lib/benry/cmdopt.rb +568 -439
- data/task/common-task.rb +138 -0
- data/task/package-task.rb +72 -0
- data/task/readme-task.rb +125 -0
- data/task/test-task.rb +81 -0
- data/test/cmdopt_test.rb +1361 -722
- metadata +22 -28
data/Rakefile.rb
CHANGED
@@ -1,92 +1,11 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
PROJECT = "benry-cmdopt"
|
5
|
+
RELEASE = ENV['RELEASE'] || "0.0.0"
|
6
|
+
COPYRIGHT = "copyright(c) 2021 kwatch@gmail.com"
|
7
|
+
LICENSE = "MIT License"
|
8
8
|
|
9
|
-
|
10
|
-
README.md CHANGES.md MIT-LICENSE.txt Rakefile.rb
|
11
|
-
lib/**/*.rb
|
12
|
-
test/**/*_test.rb
|
13
|
-
#{project}.gemspec
|
14
|
-
]]
|
9
|
+
#RUBY_VERSIONS = ["3.2", "3.1", "3.0", "2.7", "2.6", "2.5", "2.4", "2.3"]
|
15
10
|
|
16
|
-
|
17
|
-
require 'rake/clean'
|
18
|
-
CLEAN << "build"
|
19
|
-
CLOBBER << Dir.glob("#{project}-*.gem")
|
20
|
-
|
21
|
-
|
22
|
-
task :default => :help
|
23
|
-
|
24
|
-
|
25
|
-
desc "show help"
|
26
|
-
task :help do
|
27
|
-
puts "rake help # help"
|
28
|
-
puts "rake test # run test"
|
29
|
-
puts "rake package RELEASE=X.X.X # create gem file"
|
30
|
-
puts "rake publish RELEASE=X.X.X # upload gem file"
|
31
|
-
puts "rake clean # remove files"
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
desc "do test"
|
36
|
-
task :test do
|
37
|
-
sh "ruby", *Dir.glob("test/*.rb")
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
desc "create package"
|
42
|
-
task :package do
|
43
|
-
release != "0.0.0" or
|
44
|
-
raise "specify $RELEASE"
|
45
|
-
## copy
|
46
|
-
dir = "build"
|
47
|
-
rm_rf dir if File.exist?(dir)
|
48
|
-
mkdir dir
|
49
|
-
target_files.each do |file|
|
50
|
-
dest = File.join(dir, File.dirname(file))
|
51
|
-
mkdir_p dest, :verbose=>false unless File.exist?(dest)
|
52
|
-
cp file, "#{dir}/#{file}"
|
53
|
-
end
|
54
|
-
## edit
|
55
|
-
Dir.glob("#{dir}/**/*").each do |file|
|
56
|
-
next unless File.file?(file)
|
57
|
-
File.open(file, 'rb+') do |f|
|
58
|
-
s1 = f.read()
|
59
|
-
s2 = s1
|
60
|
-
s2 = s2.gsub(/\$Release[:].*?\$/, "$"+"Release: #{release} $")
|
61
|
-
s2 = s2.gsub(/\$Copyright[:].*?\$/, "$"+"Copyright: #{copyright} $")
|
62
|
-
s2 = s2.gsub(/\$License[:].*?\$/, "$"+"License: #{license} $")
|
63
|
-
#
|
64
|
-
if s1 != s2
|
65
|
-
f.rewind()
|
66
|
-
f.truncate(0)
|
67
|
-
f.write(s2)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
## build
|
72
|
-
chdir dir do
|
73
|
-
sh "gem build #{project}.gemspec"
|
74
|
-
end
|
75
|
-
mv "#{dir}/#{project}-#{release}.gem", "."
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
desc "upload gem file to rubygems.org"
|
80
|
-
task :publish do
|
81
|
-
release != "0.0.0" or
|
82
|
-
raise "specify $RELEASE"
|
83
|
-
#
|
84
|
-
gemfile = "#{project}-#{release}.gem"
|
85
|
-
print "** Are you sure to publish #{gemfile}? [y/N]: "
|
86
|
-
answer = $stdin.gets().strip()
|
87
|
-
if answer.downcase == "y"
|
88
|
-
sh "gem push #{gemfile}"
|
89
|
-
sh "git tag ruby-#{project}-#{release}"
|
90
|
-
sh "git push --tags"
|
91
|
-
end
|
92
|
-
end
|
11
|
+
Dir.glob('./task/*-task.rb').each {|x| require x }
|
data/benry-cmdopt.gemspec
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name =
|
5
|
-
spec.version =
|
6
|
-
spec.author =
|
7
|
-
spec.email =
|
4
|
+
spec.name = "benry-cmdopt"
|
5
|
+
spec.version = "$Release: 2.0.0 $".split()[1]
|
6
|
+
spec.author = "kwatch"
|
7
|
+
spec.email = "kwatch@gmail.com"
|
8
8
|
spec.platform = Gem::Platform::RUBY
|
9
|
-
spec.homepage =
|
10
|
-
spec.summary = "Command option parser,
|
11
|
-
spec.description = <<-
|
12
|
-
Command option parser,
|
9
|
+
spec.homepage = "https://kwatch.github.io/benry-ruby/benry-cmdopt.html"
|
10
|
+
spec.summary = "Command option parser, much better than `optparse.rb`"
|
11
|
+
spec.description = <<-"END"
|
12
|
+
Command option parser, much simpler and better than `optparse.rb`.
|
13
|
+
|
14
|
+
Why not `optparse.rb`? See #{spec.homepage}#why-not-optparserb for details.
|
13
15
|
END
|
14
|
-
spec.license =
|
16
|
+
spec.license = "MIT"
|
15
17
|
spec.files = Dir[
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
"README.md", "MIT-LICENSE", "CHANGES.md",
|
19
|
+
"Rakefile.rb", "#{spec.name}.gemspec",
|
20
|
+
"lib/**/*.rb", "test/**/*.rb", "task/**/*.rb",
|
21
|
+
#"bin/*", "examples/**/*",
|
22
|
+
"doc/*.html", "doc/css/*",
|
21
23
|
]
|
22
|
-
#spec.executables = [
|
23
|
-
spec.bindir =
|
24
|
-
spec.require_path =
|
25
|
-
spec.test_files = Dir[
|
26
|
-
#spec.extra_rdoc_files = [
|
24
|
+
#spec.executables = []
|
25
|
+
spec.bindir = "bin"
|
26
|
+
spec.require_path = "lib"
|
27
|
+
spec.test_files = Dir["test/**/*_test.rb"] # or: ["test/run_all.rb"]
|
28
|
+
#spec.extra_rdoc_files = ["README.md", "CHANGES.md"]
|
27
29
|
|
28
|
-
spec.
|
29
|
-
spec.add_development_dependency
|
30
|
+
spec.required_ruby_version = ">= 2.3"
|
31
|
+
spec.add_development_dependency "oktest" , "~> 1"
|
30
32
|
end
|