Files: e66116dc37379b6bc8f21bd749a81b00a19ff6ee / Rakefile
2670 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.3" |
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 | t.rcov = true |
36 | t.rcov_dir = 'doc/coverage' |
37 | t.rcov_opts = ['--exclude', 'spec\/spec,spec\/.*_spec.rb'] |
38 | end |
39 | |
40 | namespace :spec do |
41 | desc "Run all specs and store html output in doc/specs.html" |
42 | Spec::Rake::SpecTask.new('html') do |t| |
43 | t.spec_files = FileList['spec/**/*_spec.rb'] |
44 | t.spec_opts = ['--diff','--format html','--backtrace','--out doc/specs.html'] |
45 | end |
46 | end |
47 | |
48 | desc 'Generate RDoc' |
49 | rd = Rake::RDocTask.new do |rdoc| |
50 | rdoc.rdoc_dir = 'doc/rdoc' |
51 | rdoc.options << '--title' << 'bcrypt-ruby' << '--line-numbers' << '--inline-source' << '--main' << 'README' |
52 | rdoc.template = ENV['TEMPLATE'] if ENV['TEMPLATE'] |
53 | rdoc.rdoc_files.include('README', 'COPYING', 'CHANGELOG', 'lib/**/*.rb') |
54 | end |
55 | |
56 | spec = Gem::Specification.new do |s| |
57 | s.name = PKG_NAME |
58 | s.version = PKG_VERSION |
59 | s.summary = "OpenBSD's bcrypt() password hashing algorithm." |
60 | s.description = <<-EOF |
61 | bcrypt() is a sophisticated and secure hash algorithm designed by The OpenBSD project |
62 | for hashing passwords. bcrypt-ruby provides a simple, humane wrapper for safely handling |
63 | passwords. |
64 | EOF |
65 | |
66 | s.files = PKG_FILES.to_a |
67 | s.require_path = 'lib' |
68 | |
69 | s.has_rdoc = true |
70 | s.rdoc_options = rd.options |
71 | s.extra_rdoc_files = rd.rdoc_files.to_a |
72 | |
73 | s.extensions = FileList["ext/extconf.rb"].to_a |
74 | |
75 | s.authors = ["Coda Hale"] |
76 | s.email = "coda.hale@gmail.com" |
77 | s.homepage = "http://bcrypt-ruby.rubyforge.org" |
78 | s.rubyforge_project = "bcrypt-ruby" |
79 | end |
80 | |
81 | Rake::GemPackageTask.new(spec) do |pkg| |
82 | pkg.need_zip = true |
83 | pkg.need_tar = true |
84 | end |
85 | |
86 | desc "Clean, then compile the extension." |
87 | task :compile => [:clean] do |
88 | Dir.chdir('./ext') |
89 | system "ruby extconf.rb" |
90 | system "make" |
91 | Dir.chdir('..') |
92 | end |
93 | |
94 | desc "Run a set of benchmarks on the compiled extension." |
95 | task :benchmark do |
96 | TESTS = 100 |
97 | TEST_PWD = "this is a test" |
98 | require "lib/bcrypt" |
99 | Benchmark.bmbm do |results| |
100 | 4.upto(10) do |n| |
101 | results.report("cost #{n}:") { TESTS.times { BCrypt::Password.create(TEST_PWD, :cost => n) } } |
102 | end |
103 | end |
104 | end |
105 |
Built with git-ssb-web