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