git ssb

0+

dangerousbeans / %aPBe2k3ugtjBr4rrsU1…



Tree: 974b0f6e889d995cc06959c3de9fb0bb3cff8eee

Files: 974b0f6e889d995cc06959c3de9fb0bb3cff8eee / Rakefile

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

Built with git-ssb-web