Skip to content
Newer
Older
100644 129 lines (113 sloc) 3.37 KB
a548e49 Initial checkin.
codahale authored
1 require "spec/rake/spectask"
2 require 'rake/gempackagetask'
1965feb @tmm1 Switch to rake-compiler for building binary win32/java gems.
tmm1 authored
3 require 'rake/extensiontask'
4 require 'rake/javaextensiontask'
a548e49 Initial checkin.
codahale authored
5 require 'rake/contrib/rubyforgepublisher'
6 require 'rake/clean'
7 require 'rake/rdoctask'
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc dire…
codahale authored
8 require "benchmark"
a548e49 Initial checkin.
codahale authored
9
10 PKG_NAME = "bcrypt-ruby"
c85bc64 @codahale Prepare for the 2.1.2 release.
authored
11 PKG_VERSION = "2.1.2"
a548e49 Initial checkin.
codahale authored
12 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
13 PKG_FILES = FileList[
14 '[A-Z]*',
15 'lib/**/*.rb',
16 'spec/**/*.rb',
7e4f6e0 @FooBarWidget Move MRI C extension into 'mri' subdirectory.
FooBarWidget authored
17 'ext/mri/*.c',
18 'ext/mri/*.h',
19 'ext/mri/*.rb',
1965feb @tmm1 Switch to rake-compiler for building binary win32/java gems.
tmm1 authored
20 'ext/jruby/bcrypt_jruby/BCrypt.java'
a548e49 Initial checkin.
codahale authored
21 ]
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc dire…
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 dire…
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 dire…
codahale authored
32 )
a548e49 Initial checkin.
codahale authored
33
2020114 @codahale Make rake compile behave better, make the default task a full recompi…
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 sour…
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 dire…
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…
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…
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'
1965feb @tmm1 Switch to rake-compiler for building binary win32/java gems.
tmm1 authored
71 s.add_development_dependency 'rake-compiler'
a548e49 Initial checkin.
codahale authored
72
73 s.has_rdoc = true
74 s.rdoc_options = rd.options
75 s.extra_rdoc_files = rd.rdoc_files.to_a
76
7e4f6e0 @FooBarWidget Move MRI C extension into 'mri' subdirectory.
FooBarWidget authored
77 s.extensions = FileList["ext/mri/extconf.rb"].to_a
a548e49 Initial checkin.
codahale authored
78
e66116d @codahale Prepare for the 2.0.3 release.
authored
79 s.authors = ["Coda Hale"]
a548e49 Initial checkin.
codahale authored
80 s.email = "coda.hale@gmail.com"
81 s.homepage = "http://bcrypt-ruby.rubyforge.org"
82 s.rubyforge_project = "bcrypt-ruby"
83 end
17b18ea @codahale Do a better job of ensuring BCrypt.java gets compiled.
authored
84
a548e49 Initial checkin.
codahale authored
85 Rake::GemPackageTask.new(spec) do |pkg|
86 pkg.need_zip = true
87 pkg.need_tar = true
88 end
89
1965feb @tmm1 Switch to rake-compiler for building binary win32/java gems.
tmm1 authored
90 if RUBY_PLATFORM =~ /java/
91 Rake::JavaExtensionTask.new('bcrypt_ext', spec) do |ext|
92 ext.ext_dir = 'ext/jruby'
93 end
8f7acf4 @FooBarWidget Finish JRuby support.
FooBarWidget authored
94 else
1965feb @tmm1 Switch to rake-compiler for building binary win32/java gems.
tmm1 authored
95 Rake::ExtensionTask.new("bcrypt_ext", spec) do |ext|
96 ext.ext_dir = 'ext/mri'
97 ext.cross_compile = true
98 ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
8f7acf4 @FooBarWidget Finish JRuby support.
FooBarWidget authored
99
1965feb @tmm1 Switch to rake-compiler for building binary win32/java gems.
tmm1 authored
100 # inject 1.8/1.9 pure-ruby entry point
101 ext.cross_compiling do |spec|
102 spec.files += ["lib/#{ext.name}.rb"]
8f7acf4 @FooBarWidget Finish JRuby support.
FooBarWidget authored
103 end
104 end
1965feb @tmm1 Switch to rake-compiler for building binary win32/java gems.
tmm1 authored
105 end
106
107 # Entry point for fat-binary gems on win32
108 file("lib/bcrypt_ext.rb") do |t|
109 File.open(t.name, 'wb') do |f|
110 f.write <<-eoruby
111 RUBY_VERSION =~ /(\\d+.\\d+)/
112 require "\#{$1}/#{File.basename(t.name, '.rb')}"
113 eoruby
f01304a @FooBarWidget Improve 'compile' Rake task.
FooBarWidget authored
114 end
1965feb @tmm1 Switch to rake-compiler for building binary win32/java gems.
tmm1 authored
115 at_exit{ FileUtils.rm t.name if File.exists?(t.name) }
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc dire…
codahale authored
116 end
117
90cd206 Added descriptions to compile and benchmark so's I can find them agai…
codahale authored
118 desc "Run a set of benchmarks on the compiled extension."
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc dire…
codahale authored
119 task :benchmark do
120 TESTS = 100
121 TEST_PWD = "this is a test"
8caa1cc @FooBarWidget When on Ruby 1.9, unlock the global interpreter lock while calculatin…
FooBarWidget authored
122 require File.expand_path(File.join(File.dirname(__FILE__), "lib", "bcrypt"))
51520c4 Fixed cleaning and clobbering, added benchmark task, removed doc dire…
codahale authored
123 Benchmark.bmbm do |results|
124 4.upto(10) do |n|
125 results.report("cost #{n}:") { TESTS.times { BCrypt::Password.create(TEST_PWD, :cost => n) } }
126 end
127 end
128 end
Something went wrong with that request. Please try again.