Files: 053804330b025bd804000e403bf3d41264426e73 / Rakefile
1822 bytesRaw
1 | require 'rspec/core/rake_task' |
2 | require 'rubygems/package_task' |
3 | require 'rake/extensiontask' |
4 | require 'rake/javaextensiontask' |
5 | require 'rake/clean' |
6 | require 'rdoc/task' |
7 | require 'benchmark' |
8 | |
9 | CLEAN.include( |
10 | "ext/mri/*.o", |
11 | "ext/mri/*.bundle", |
12 | "ext/mri/*.so", |
13 | "ext/jruby/bcrypt_jruby/*.class" |
14 | ) |
15 | CLOBBER.include( |
16 | "ext/mri/Makefile", |
17 | "doc/coverage", |
18 | "pkg" |
19 | ) |
20 | GEMSPEC = eval(File.read(File.expand_path("../bcrypt.gemspec", __FILE__))) |
21 | |
22 | task :default => [:compile, :spec] |
23 | |
24 | desc "Run all specs" |
25 | RSpec::Core::RakeTask.new do |t| |
26 | t.pattern = 'spec/**/*_spec.rb' |
27 | t.ruby_opts = '-w' |
28 | end |
29 | |
30 | desc "Run all specs, with coverage testing" |
31 | RSpec::Core::RakeTask.new(:rcov) do |t| |
32 | t.pattern = 'spec/**/*_spec.rb' |
33 | t.rcov = true |
34 | t.rcov_path = 'doc/coverage' |
35 | t.rcov_opts = ['--exclude', 'rspec,diff-lcs,rcov,_spec,_helper'] |
36 | end |
37 | |
38 | desc 'Generate RDoc' |
39 | RDoc::Task.new do |rdoc| |
40 | rdoc.rdoc_dir = 'doc/rdoc' |
41 | rdoc.options += GEMSPEC.rdoc_options |
42 | rdoc.template = ENV['TEMPLATE'] if ENV['TEMPLATE'] |
43 | rdoc.rdoc_files.include(*GEMSPEC.extra_rdoc_files) |
44 | end |
45 | |
46 | Gem::PackageTask.new(GEMSPEC) do |pkg| |
47 | pkg.need_zip = true |
48 | pkg.need_tar = true |
49 | end |
50 | |
51 | if RUBY_PLATFORM =~ /java/ |
52 | Rake::JavaExtensionTask.new('bcrypt_ext', GEMSPEC) do |ext| |
53 | ext.ext_dir = 'ext/jruby' |
54 | end |
55 | else |
56 | Rake::ExtensionTask.new("bcrypt_ext", GEMSPEC) do |ext| |
57 | ext.ext_dir = 'ext/mri' |
58 | ext.cross_compile = true |
59 | ext.cross_platform = ['x86-mingw32', 'x64-mingw32'] |
60 | end |
61 | end |
62 | |
63 | desc "Run a set of benchmarks on the compiled extension." |
64 | task :benchmark do |
65 | TESTS = 100 |
66 | TEST_PWD = "this is a test" |
67 | require File.expand_path(File.join(File.dirname(__FILE__), "lib", "bcrypt")) |
68 | Benchmark.bmbm do |results| |
69 | 4.upto(10) do |n| |
70 | results.report("cost #{n}:") { TESTS.times { BCrypt::Password.create(TEST_PWD, :cost => n) } } |
71 | end |
72 | end |
73 | end |
74 |
Built with git-ssb-web