-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathRakefile
55 lines (45 loc) · 1.34 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require "bundler/gem_tasks"
require "rake/testtask"
require "rdoc/task"
name = "io/console"
if RUBY_ENGINE == "ruby" || RUBY_ENGINE == "truffleruby"
require 'rake/extensiontask'
extask = Rake::ExtensionTask.new(name) do |x|
x.lib_dir.sub!(%r[(?=/|\z)], "/#{RUBY_VERSION}/#{x.platform}")
end
task :test => :compile
end
ffi_version_file = "lib/ffi/#{name}/version.rb"
task ffi_version_file => "#{name.tr('/', '-')}.gemspec" do |t|
version = <<~RUBY
class IO::ConsoleMode
VERSION = "#{Bundler::GemHelper.instance.gemspec.version}"
end
RUBY
unless (File.read(t.name) rescue nil) == version
File.binwrite(t.name, version)
end
end
task :build => ffi_version_file
Rake::TestTask.new(:test) do |t|
if extask
t.libs = ["lib/#{RUBY_VERSION}/#{extask.platform}"]
end
t.libs << "test/lib"
t.ruby_opts << "-rhelper"
t.options = "--ignore-name=TestIO_Console#test_bad_keyword" if RUBY_ENGINE == "jruby"
t.test_files = FileList["test/**/test_*.rb"]
end
RDoc::Task.new
task :default => :test
task "build" => "build:java"
task "build:java" => "date_epoch"
task "coverage" do
cov = []
e = IO.popen([FileUtils::RUBY, "-S", "rdoc", "-C"], &:read)
e.scan(/^ *# in file (?<loc>.*)\n *(?<code>.*)|^ *(?<code>.*\S) *# in file (?<loc>.*)/) do
cov << "%s: %s\n" % $~.values_at(:loc, :code)
end
cov.sort!
puts cov
end