-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile
executable file
·46 lines (37 loc) · 1.09 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
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rake/extensiontask'
spec = Gem::Specification.load('blake2b.gemspec')
Rake::ExtensionTask.new('blake2b_ext', spec) do |ext|
ext.source_pattern = '*.{c,h}'
end
Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
t.warning = true
end
task default: :full
desc 'clean, compile, and run the full test suite'
task full: %w(clean compile test)
def gemspec
@gemspec ||= begin
file = File.expand_path('../blake2b.gemspec', __FILE__)
eval(File.read(file), binding, file)
end
end
desc "Validate the gemspec"
task :gemspec do
gemspec.validate
end
desc "Build the gem"
task :gem => [:gemspec, :build] do
mkdir_p "pkg"
sh "gem build blake2b.gemspec"
mv "#{gemspec.full_name}.gem", "pkg"
require 'digest/sha2'
built_gem_path = "pkg/#{gemspec.full_name}.gem"
checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
checksum_path = "checksums/#{gemspec.version}.sha512"
File.open(checksum_path, 'w' ) {|f| f.write(checksum) }
end