git ssb

0+

dangerousbeans / %aPBe2k3ugtjBr4rrsU1…



Tree: c53946e846ea7b39fec519a6d2a9d9c27422f3d8

Files: c53946e846ea7b39fec519a6d2a9d9c27422f3d8 / Rakefile

1799 bytesRaw
1require 'rspec/core/rake_task'
2require 'rubygems/package_task'
3require 'rake/extensiontask'
4require 'rake/javaextensiontask'
5require 'rake/clean'
6require 'rdoc/task'
7require 'benchmark'
8
9CLEAN.include(
10 "ext/mri/*.o",
11 "ext/mri/*.bundle",
12 "ext/mri/*.so",
13 "ext/jruby/bcrypt_jruby/*.class"
14)
15CLOBBER.include(
16 "ext/mri/Makefile",
17 "doc/coverage",
18 "pkg"
19)
20GEMSPEC = Gem::Specification.load("bcrypt.gemspec")
21
22task :default => [:compile, :spec]
23
24desc "Run all specs"
25RSpec::Core::RakeTask.new do |t|
26 t.pattern = 'spec/**/*_spec.rb'
27 t.ruby_opts = '-w'
28end
29
30desc "Run all specs, with coverage testing"
31RSpec::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']
36end
37
38desc 'Generate RDoc'
39RDoc::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)
44end
45
46Gem::PackageTask.new(GEMSPEC) do |pkg|
47 pkg.need_zip = true
48 pkg.need_tar = true
49end
50
51if RUBY_PLATFORM =~ /java/
52 Rake::JavaExtensionTask.new('bcrypt_ext', GEMSPEC) do |ext|
53 ext.ext_dir = 'ext/jruby'
54 end
55else
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
61end
62
63desc "Run a set of benchmarks on the compiled extension."
64task :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
73end
74

Built with git-ssb-web