Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 131 lines (113 sloc) 3.435 kb
a548e49 Initial checkin.
codahale authored
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'
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc directo...
codahale authored
7 require "benchmark"
a548e49 Initial checkin.
codahale authored
8
9 PKG_NAME = "bcrypt-ruby"
525b599 @codahale Prepare for the 2.1.1 release.
authored
10 PKG_VERSION = "2.1.1"
a548e49 Initial checkin.
codahale authored
11 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12 PKG_FILES = FileList[
13 '[A-Z]*',
14 'lib/**/*.rb',
15 'spec/**/*.rb',
7e4f6e0 @FooBarWidget Move MRI C extension into 'mri' subdirectory.
FooBarWidget authored
16 'ext/mri/*.c',
17 'ext/mri/*.h',
18 'ext/mri/*.rb',
8f7acf4 @FooBarWidget Finish JRuby support.
FooBarWidget authored
19 'ext/jruby/bcrypt_jruby/BCrypt.java',
20 'ext/jruby/bcrypt_jruby/BCrypt.class'
a548e49 Initial checkin.
codahale authored
21 ]
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc directo...
codahale authored
22 CLEAN.include(
7e4f6e0 @FooBarWidget Move MRI C extension into 'mri' subdirectory.
FooBarWidget authored
23 "ext/mri/*.o",
24 "ext/mri/*.bundle",
25 "ext/mri/*.so",
26 "ext/jruby/bcrypt_jruby/*.class"
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc directo...
codahale authored
27 )
28 CLOBBER.include(
7e4f6e0 @FooBarWidget Move MRI C extension into 'mri' subdirectory.
FooBarWidget authored
29 "ext/mri/Makefile",
17b18ea @codahale Do a better job of ensuring BCrypt.java gets compiled.
authored
30 "doc/coverage",
31 "pkg"
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc directo...
codahale authored
32 )
a548e49 Initial checkin.
codahale authored
33
2020114 @codahale Make rake compile behave better, make the default task a full recompile ...
authored
34 task :default => [:compile, :spec]
a548e49 Initial checkin.
codahale authored
35
36 desc "Run all specs"
37 Spec::Rake::SpecTask.new do |t|
38 t.spec_files = FileList['spec/**/*_spec.rb']
39 t.spec_opts = ['--color','--backtrace','--diff']
fb7906c @FooBarWidget Fix the unit tests.
FooBarWidget authored
40 end
41
42 desc "Run all specs, with coverage testing"
43 Spec::Rake::SpecTask.new(:rcov) do |t|
44 t.spec_files = FileList['spec/**/*_spec.rb']
45 t.spec_opts = ['--color','--backtrace','--diff']
a548e49 Initial checkin.
codahale authored
46 t.rcov = true
4600360 Updated changelog with full details of what's been changed.
codahale authored
47 t.rcov_dir = 'doc/coverage'
79bcfae @FooBarWidget When running the coverage test, correctly ignore non-bcrypt-ruby source ...
FooBarWidget authored
48 t.rcov_opts = ['--exclude', 'rspec,diff-lcs,rcov,_spec,_helper']
a548e49 Initial checkin.
codahale authored
49 end
50
51 desc 'Generate RDoc'
52 rd = Rake::RDocTask.new do |rdoc|
4600360 Updated changelog with full details of what's been changed.
codahale authored
53 rdoc.rdoc_dir = 'doc/rdoc'
a548e49 Initial checkin.
codahale authored
54 rdoc.options << '--title' << 'bcrypt-ruby' << '--line-numbers' << '--inline-source' << '--main' << 'README'
55 rdoc.template = ENV['TEMPLATE'] if ENV['TEMPLATE']
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc directo...
codahale authored
56 rdoc.rdoc_files.include('README', 'COPYING', 'CHANGELOG', 'lib/**/*.rb')
a548e49 Initial checkin.
codahale authored
57 end
58
59 spec = Gem::Specification.new do |s|
60 s.name = PKG_NAME
61 s.version = PKG_VERSION
b53ba3b Actually write a gem description and summary. "Blah" and "Woot" don't cu...
codahale authored
62 s.summary = "OpenBSD's bcrypt() password hashing algorithm."
a548e49 Initial checkin.
codahale authored
63 s.description = <<-EOF
b53ba3b Actually write a gem description and summary. "Blah" and "Woot" don't cu...
codahale authored
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.
a548e49 Initial checkin.
codahale authored
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
7e4f6e0 @FooBarWidget Move MRI C extension into 'mri' subdirectory.
FooBarWidget authored
76 s.extensions = FileList["ext/mri/extconf.rb"].to_a
a548e49 Initial checkin.
codahale authored
77
e66116d @codahale Prepare for the 2.0.3 release.
authored
78 s.authors = ["Coda Hale"]
a548e49 Initial checkin.
codahale authored
79 s.email = "coda.hale@gmail.com"
80 s.homepage = "http://bcrypt-ruby.rubyforge.org"
81 s.rubyforge_project = "bcrypt-ruby"
82 end
17b18ea @codahale Do a better job of ensuring BCrypt.java gets compiled.
authored
83
84 file 'ext/jruby/bcrypt_jruby/BCrypt.class' => ["ext/jruby/bcrypt_jruby/BCrypt.java"] do
85 Rake::Task['compile:jruby'].invoke
86 end
a548e49 Initial checkin.
codahale authored
87
88 Rake::GemPackageTask.new(spec) do |pkg|
89 pkg.need_zip = true
90 pkg.need_tar = true
91 end
92
8f7acf4 @FooBarWidget Finish JRuby support.
FooBarWidget authored
93 desc "Clean, then compile the extension that's native to the current Ruby compiler."
94 if RUBY_PLATFORM == "java"
95 task :compile => 'compile:jruby'
96 else
97 task :compile => 'compile:mri'
98 end
99
100 namespace :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
7e4f6e0 @FooBarWidget Move MRI C extension into 'mri' subdirectory.
FooBarWidget authored
106 Dir.chdir('ext/mri') do
8f7acf4 @FooBarWidget Finish JRuby support.
FooBarWidget authored
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
a0c0fe6 @FooBarWidget Ensure that BCrypt.class is compiled with the right compatibility flags.
FooBarWidget authored
115 sh "javac -source 1.4 -target 1.4 BCrypt.java"
8f7acf4 @FooBarWidget Finish JRuby support.
FooBarWidget authored
116 end
f01304a @FooBarWidget Improve 'compile' Rake task.
FooBarWidget authored
117 end
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc directo...
codahale authored
118 end
119
90cd206 Added descriptions to compile and benchmark so's I can find them again n...
codahale authored
120 desc "Run a set of benchmarks on the compiled extension."
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc directo...
codahale authored
121 task :benchmark do
122 TESTS = 100
123 TEST_PWD = "this is a test"
8caa1cc @FooBarWidget When on Ruby 1.9, unlock the global interpreter lock while calculating b...
FooBarWidget authored
124 require File.expand_path(File.join(File.dirname(__FILE__), "lib", "bcrypt"))
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc directo...
codahale authored
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
130 end
Something went wrong with that request. Please try again.