git ssb

0+

dangerousbeans / %aPBe2k3ugtjBr4rrsU1…



Tree: 5e8c83fc81f04397f8ce2953b8b8c6745f648ff2

Files: 5e8c83fc81f04397f8ce2953b8b8c6745f648ff2 / Rakefile

3303 bytesRaw
1gem "rspec"
2require "spec/rake/spectask"
3require 'rake/gempackagetask'
4require 'rake/contrib/rubyforgepublisher'
5require 'rake/clean'
6require 'rake/rdoctask'
7require "benchmark"
8
9PKG_NAME = "bcrypt-ruby"
10PKG_VERSION = "2.1.0"
11PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12PKG_FILES = FileList[
13 '[A-Z]*',
14 'lib/**/*.rb',
15 'spec/**/*.rb',
16 'ext/mri/*.c',
17 'ext/mri/*.h',
18 'ext/mri/*.rb',
19 'ext/jruby/bcrypt_jruby/BCrypt.java',
20 'ext/jruby/bcrypt_jruby/BCrypt.class'
21]
22CLEAN.include(
23 "ext/mri/*.o",
24 "ext/mri/*.bundle",
25 "ext/mri/*.so",
26 "ext/jruby/bcrypt_jruby/*.class"
27)
28CLOBBER.include(
29 "ext/mri/Makefile",
30 "doc/coverage"
31)
32
33task :default => [:compile, :spec]
34
35desc "Run all specs"
36Spec::Rake::SpecTask.new do |t|
37 t.spec_files = FileList['spec/**/*_spec.rb']
38 t.spec_opts = ['--color','--backtrace','--diff']
39end
40
41desc "Run all specs, with coverage testing"
42Spec::Rake::SpecTask.new(:rcov) do |t|
43 t.spec_files = FileList['spec/**/*_spec.rb']
44 t.spec_opts = ['--color','--backtrace','--diff']
45 t.rcov = true
46 t.rcov_dir = 'doc/coverage'
47 t.rcov_opts = ['--exclude', 'rspec,diff-lcs,rcov,_spec,_helper']
48end
49
50desc 'Generate RDoc'
51rd = Rake::RDocTask.new do |rdoc|
52 rdoc.rdoc_dir = 'doc/rdoc'
53 rdoc.options << '--title' << 'bcrypt-ruby' << '--line-numbers' << '--inline-source' << '--main' << 'README'
54 rdoc.template = ENV['TEMPLATE'] if ENV['TEMPLATE']
55 rdoc.rdoc_files.include('README', 'COPYING', 'CHANGELOG', 'lib/**/*.rb')
56end
57
58spec = Gem::Specification.new do |s|
59 s.name = PKG_NAME
60 s.version = PKG_VERSION
61 s.summary = "OpenBSD's bcrypt() password hashing algorithm."
62 s.description = <<-EOF
63 bcrypt() is a sophisticated and secure hash algorithm designed by The OpenBSD project
64 for hashing passwords. bcrypt-ruby provides a simple, humane wrapper for safely handling
65 passwords.
66 EOF
67
68 s.files = PKG_FILES.to_a
69 s.require_path = 'lib'
70
71 s.has_rdoc = true
72 s.rdoc_options = rd.options
73 s.extra_rdoc_files = rd.rdoc_files.to_a
74
75 s.extensions = FileList["ext/mri/extconf.rb"].to_a
76
77 s.authors = ["Coda Hale"]
78 s.email = "coda.hale@gmail.com"
79 s.homepage = "http://bcrypt-ruby.rubyforge.org"
80 s.rubyforge_project = "bcrypt-ruby"
81end
82task :gem => ["compile:jruby"]
83
84Rake::GemPackageTask.new(spec) do |pkg|
85 pkg.need_zip = true
86 pkg.need_tar = true
87end
88
89desc "Clean, then compile the extension that's native to the current Ruby compiler."
90if RUBY_PLATFORM == "java"
91 task :compile => 'compile:jruby'
92else
93 task :compile => 'compile:mri'
94end
95
96namespace :compile do
97 desc "CLean, then compile all extensions"
98 task :all => [:mri, :jruby]
99
100 desc "Clean, then compile the MRI extension"
101 task :mri => :clean do
102 Dir.chdir('ext/mri') do
103 ruby "extconf.rb"
104 sh "make"
105 end
106 end
107
108 desc "Clean, then compile the JRuby extension"
109 task :jruby => :clean do
110 Dir.chdir('ext/jruby/bcrypt_jruby') do
111 sh "javac BCrypt.java"
112 end
113 end
114end
115
116desc "Run a set of benchmarks on the compiled extension."
117task :benchmark do
118 TESTS = 100
119 TEST_PWD = "this is a test"
120 require File.expand_path(File.join(File.dirname(__FILE__), "lib", "bcrypt"))
121 Benchmark.bmbm do |results|
122 4.upto(10) do |n|
123 results.report("cost #{n}:") { TESTS.times { BCrypt::Password.create(TEST_PWD, :cost => n) } }
124 end
125 end
126end
127

Built with git-ssb-web