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