home_run 0.9.0-x86-mingw32 → 0.9.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,49 @@
1
+ === 0.9.1 (2010-09-01)
2
+
3
+ * Fix strptime for %Y%m%d and similar formats (jeremyevans) (#9)
4
+
5
+ * Require rake-compiler when building from source (may need to clean out your ext/date_ext directory manually) (jeremyevans)
6
+
7
+ * Include the ragel-generated file in the repository, so you don't need ragel to build from source (jeremyevans)
8
+
9
+ * Respect Encoding.default_internal for returned strings on 1.9 (brianmario, jeremyevans)
10
+
11
+ * Handle problems with zones in the -HH,DDD or -HH.DDD formats (jeremyevans)
12
+
13
+ * Compile C files separately, instead of including C files in other C files (jeremyevans)
14
+
15
+ * On ruby 1.9, return strings in US-ASCII encoding instead of ASCII-8BIT (jeremyevans) (#8)
16
+
17
+ * Reorganize directory structure to use the standard ruby extension structure (luislavena, jeremyevans)
18
+
19
+ * Support Date/DateTime#step without a block returning an Enumerator on 1.9 (jeremyevans) (#6)
20
+
21
+ * Support ruby build with CALC_EXACT_MALLOC_SIZE (nocode) (#5)
22
+
23
+ * Add Ragel parser for Apache Common Log Format date format (jeremyevans)
24
+
25
+ * Add Ragel parser for RFC 822 date format (jeremyevans)
26
+
27
+ * Fix loading date/format.rb directly where the date extension hasn't been included but the Date class has been opened (jeremyevans) (#3)
28
+
29
+ * Don't override ruby's default extension optimization flags (jeremyevans)
30
+
31
+ * Fix compilation on Solaris with the Sun Studio Compiler (ankopainting)
32
+
33
+ * Handle YYYY/MM/DD date format in the ISO 8601 Ragel parser (jeremyevans)
34
+
35
+ * Add a home_run.rb file to allow you to require 'home_run' to load the extension, useful on Heroku with ruby 1.8 (jeremyevans) (#2)
36
+
37
+ * Don't think that Mac OS X/Darwin users are on Windows (jeremyevans) (#1)
38
+
39
+ * Tighten up offset limits to exactly 14 hours from UTC (jeremyevans)
40
+
41
+ * Make dates outside of the allowed range raise RangeErrors (jeremyevans)
42
+
43
+ * Add range check for DateTime#+ and related methods (jeremyevans)
44
+
45
+ * Add range check for DateTime#new! (jeremyevans)
46
+
1
47
  === 0.9.0 (2010-08-20)
2
48
 
3
49
  * Initial Public Release
data/README.rdoc CHANGED
@@ -36,8 +36,8 @@ some comparative results for common methods:
36
36
  The standard library Date class is slow enough to be the
37
37
  bottleneck in much (if not most) of code that uses it.
38
38
  Here's a real world benchmark showing the retrieval of
39
- data from a database, first without home_run, and then
40
- with home_run.
39
+ data from a database (using Sequel), first without home_run,
40
+ and then with home_run.
41
41
 
42
42
  $ script/console production
43
43
  Loading production environment (Rails 2.3.5)
@@ -109,10 +109,21 @@ using home_run:
109
109
  This manipulates the RUBYLIB and RUBYOPT environment variables so
110
110
  that home_run's Date/DateTime classes will be used.
111
111
 
112
+ You can also just require the library:
113
+
114
+ require 'home_run'
115
+
116
+ This should only be used as a last resort. Because rubygems requires
117
+ date, you can end up with situations where the Date instances created
118
+ before the require use the standard library version of Date, while the
119
+ Date instances created after the require use this library's version.
120
+ However, in some cases (such as on Heroku), this is the only way to
121
+ easily use this library.
122
+
112
123
  == Running the specs
113
124
 
114
- You can run the specs after installing the gem, if you have MSpec
115
- installed (gem install mspec):
125
+ You can run the rubyspec based specs after installing the gem, if
126
+ you have MSpec installed (gem install mspec):
116
127
 
117
128
  home_run --spec
118
129
 
@@ -202,6 +213,15 @@ you use the standard library.
202
213
  Any other differences will either be documented here or considered
203
214
  bugs, so please report any other differences you find.
204
215
 
216
+ == Known incompatibilities
217
+
218
+ Some other libraries are known to be incompatible with this
219
+ extension due to the above differences:
220
+
221
+ * Date::Performance - Date#<=> assumes @ajd instance variable
222
+ (unnecessary anyway, as home_run is faster)
223
+ * ruby-ole - Depends on DateTime.allocate/#initialize
224
+
205
225
  == Reporting issues/bugs
206
226
 
207
227
  home_run uses GitHub Issues for tracking issues/bugs:
@@ -220,25 +240,19 @@ To get a copy:
220
240
 
221
241
  There are a few requirements:
222
242
 
223
- * Rake
224
- * Ragel 6.5+ for building the ragel parser. The compiled C file is
225
- included in the gem, so people installing the gem don't need
226
- Ragel. The compiled C file is not checked into git, so you need
227
- Ragel if you are working with a git checkout.
243
+ * rake
244
+ * rake-compiler
228
245
  * MSpec (not RSpec) for running the specs. The specs are based on
229
246
  the rubyspec specs, which is why they use MSpec.
230
247
  * RDoc 2.5.10+ if you want to build the documentation.
248
+ * Ragel 6.5+ if you want to modify the ragel parser.
231
249
 
232
- The directory layout is slightly unusual in that there is no
233
- lib directory and there are .rb files in the ext directory. This may
234
- change in a future version.
235
-
236
- == Building
250
+ == Compiling
237
251
 
238
- To build the library from a git checkout, after installing the
252
+ To compile the library from a git checkout, after installing the
239
253
  requirements:
240
254
 
241
- rake parser build
255
+ rake compile
242
256
 
243
257
  == Testing
244
258
 
@@ -246,7 +260,8 @@ The default rake task runs the specs, so just run:
246
260
 
247
261
  rake
248
262
 
249
- You need to build the library before running the specs.
263
+ You need to compile the library and install MSpec before running the
264
+ specs.
250
265
 
251
266
  == Benchmarking
252
267
 
@@ -275,18 +290,23 @@ home_run has been tested on the following:
275
290
  === Operating Systems/Platforms
276
291
 
277
292
  * Linux (x86_64, i386)
278
- * Mac OS X 10.6 (x86_64, i386)
293
+ * Mac OS X 10.6 (x86_64, i386), 10.5 (i386)
279
294
  * OpenBSD (amd64, i386)
295
+ * Solaris 10 (sparc)
280
296
  * Windows XP (i386)
297
+ * Windows 7 (x64)
281
298
 
282
299
  === Compiler Versions
283
300
 
284
- * gcc (3.3.5, 4.2.1, 4.4.3, 4.5.0)
301
+ * gcc (3.3.5, 4.0.1, 4.2.1, 4.4.3, 4.5.0)
302
+ * Sun Studio Compiler (5.9)
285
303
 
286
304
  === Ruby Versions
287
305
 
306
+ * jruby cext branch (as of commit 1969c504229bfd6f2de1, 2010-08-23,
307
+ compiles and runs specs correctly, segfaults on benchmarks)
288
308
  * rbx head (as of commit 0e265b92727cf3536053, 2010-08-16)
289
- * ruby 1.8.6 (p0, p398, p399)
309
+ * ruby 1.8.6 (p0, p110, p398, p399)
290
310
  * ruby 1.8.7 (p174, p248, p299, p302)
291
311
  * ruby 1.9.1 (p243, p378, p429, p430)
292
312
  * ruby 1.9.2 (p0)
@@ -295,19 +315,11 @@ home_run has been tested on the following:
295
315
  If your platform, compiler version, or ruby version is not listed
296
316
  above, please test and send me a report including:
297
317
 
298
- * Your operating system and platform (e.g. i386, x86_64/amd64)
299
- * Your compiler
300
- * Your ruby version
301
- * The output of home_run --spec
302
- * The output of home_run --bench
303
-
304
- == Todo
305
-
306
- * Get it working on jruby with the cext branch
307
- * Add more specs for greater code coverage and to test
308
- boundry conditions
309
- * Expand main ragel parser to handle more formats
310
- * Add ragel versions of the 1.9 date parsing functions
318
+ * Your operating system and platform (e.g. i386, x86_64/amd64)
319
+ * Your compiler
320
+ * Your ruby version
321
+ * The output of home_run --spec
322
+ * The output of home_run --bench
311
323
 
312
324
  == Author
313
325
 
data/Rakefile CHANGED
@@ -2,20 +2,16 @@ require "rake"
2
2
  require "rake/clean"
3
3
  require 'rbconfig'
4
4
 
5
- CLEAN.include %w'ext/Makefile ext/date_ext.*o **/*.rbc *.core rdoc'
5
+ CLEAN.include %w'**/*.rbc *.core rdoc coverage'
6
6
  RUBY=ENV['RUBY'] || File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
7
7
 
8
- begin
9
- gem 'rdoc'
10
- require 'rdoc/rdoc'
11
- require "rake/rdoctask"
12
- Rake::RDocTask.new do |rdoc|
13
- rdoc.rdoc_dir = "rdoc"
14
- rdoc.options += ["--quiet", "--line-numbers", "--inline-source", '--title',
15
- 'home_run: Fast Date/DateTime classes for ruby', '--main', 'README.rdoc']
16
- rdoc.rdoc_files.add %w"README.rdoc CHANGELOG LICENSE ext/**/*.rb ext/*.c"
17
- end
18
- rescue LoadError
8
+ desc "Build the RDoc documentation"
9
+ task :rdoc do
10
+ require 'fileutils'
11
+ FileUtils.rm_rf('rdoc')
12
+ sh 'rdoc --quiet --line-numbers --inline-source --output rdoc --title ' \
13
+ '"home_run: Fast Date/DateTime classes for ruby" --main README.rdoc ' \
14
+ 'README.rdoc CHANGELOG LICENSE lib/date.rb lib/date/format.rb ext/date_ext/*.c'
19
15
  end
20
16
 
21
17
  desc "Run the specs with mspec"
@@ -26,73 +22,31 @@ task :spec do
26
22
  end
27
23
 
28
24
  desc "Build the gem"
29
- task :gem => [:clean, :parser] do
25
+ task :gem => [:distclean] do
30
26
  sh %{gem build home_run.gemspec}
31
27
  end
32
28
 
33
29
  desc "Try to clean up everything"
34
30
  task :distclean do
35
- CLEAN.concat(%w'pkg home_run-*.gem ext/1.* tmp rdoc ext/date_parser.c')
31
+ CLEAN.concat(%w'pkg home_run-*.gem lib/1.* tmp')
36
32
  Rake::Task[:clean].invoke
37
33
  end
38
34
 
39
- if RUBY_PLATFORM !~ /win|w32/ and File.directory?(File.join(File.expand_path(ENV['HOME']), '.rake-compiler'))
40
35
  begin
41
- require "rake/extensiontask"
42
- ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
43
- load('home_run.gemspec')
44
- desc "Internal--cross compile the windows binary gem"
45
- cross_platform = ENV['CROSS_PLATFORM'] || 'i386-mingw32'
46
- Rake::ExtensionTask.new('date_ext', HOME_RUN_GEMSPEC) do |ext|
47
- ext.name = 'date_ext'
48
- ext.ext_dir = 'ext'
49
- ext.lib_dir = 'ext'
50
- ext.cross_compile = true
51
- ext.cross_platform = cross_platform
52
- ext.source_pattern = '*.c'
53
- end
54
-
55
- # FIXME: Incredibly hacky, should figure out how to get
56
- # rake compiler to do this correctly
57
- desc "Build the cross compiled windows binary gem"
58
- task :windows_gem => [:clean, :parser] do
59
- sh %{rm -rf tmp pkg home_run-*.gem ext/1.*}
60
- system %{rake cross native gem}
61
- unless File.directory?('pkg')
62
- sh "cp ext/*.c tmp/#{cross_platform}/date_ext/1.8.6"
63
- system %{rake cross native gem}
64
- sh %{cp ext/*.c tmp/#{cross_platform}/date_ext/1.9.1}
65
- system %{rake cross native gem}
66
- sh %{rake cross native gem}
67
- end
68
- sh %{rm -rf home_run-*.gem tmp ext/1.*}
69
- sh %{mv pkg/home_run-*.gem .}
70
- sh %{rmdir pkg}
71
- end
36
+ require 'rake/extensiontask'
37
+ Rake::ExtensionTask.new('date_ext')
72
38
  rescue LoadError
73
39
  end
74
- end
75
40
 
76
- desc "Build the ragel parser"
41
+ desc "Regenerate the ragel parser"
77
42
  task :parser do
78
- sh %{cd ext && ragel date_parser.rl}
79
- end
80
-
81
- desc "Build the extension"
82
- task :build=>[:clean] do
83
- sh %{cd ext && #{RUBY} extconf.rb && make}
84
- end
85
-
86
- desc "Build debug version of extension"
87
- task :build_debug=>[:clean] do
88
- ENV['DEBUG'] = '1'
89
- sh %{cd ext && #{RUBY} extconf.rb && make}
43
+ sh %{cd ext/date_ext && ragel date_parser.rl}
90
44
  end
91
45
 
92
46
  desc "Start an IRB shell using the extension"
93
47
  task :irb do
94
48
  irb = ENV['IRB'] || File.join(RbConfig::CONFIG['bindir'], File.basename(RUBY).sub('ruby', 'irb'))
95
- sh %{#{irb} -I ext -r date}
49
+ sh %{#{irb} -I lib -r date}
96
50
  end
97
51
 
98
52
  desc "Run comparative benchmarks"
@@ -103,34 +57,39 @@ end
103
57
  desc "Run all benchmarks"
104
58
  task :bench_all => [:bench, :mem_bench, :garbage_bench]
105
59
 
60
+ desc "Run comparative parser benchmarks"
61
+ task :parser_bench do
62
+ sh %{#{RUBY} bench/parser_bench.rb}
63
+ end
64
+
106
65
  desc "Run comparative memory benchmarks"
107
66
  task :mem_bench do
108
- if RUBY_PLATFORM =~ /win|w32/
67
+ if RUBY_PLATFORM =~ /mswin|mingw/
109
68
  puts "Memory benchmarks not supported on Windows"
110
69
  next
111
70
  end
112
71
 
113
72
  stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/mem_bench.rb`.to_i
114
- home_run = `#{RUBY} -I ext bench/mem_bench.rb`.to_i
73
+ home_run = `#{RUBY} -I lib bench/mem_bench.rb`.to_i
115
74
  puts "Date memory use,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
116
75
 
117
76
  stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/dt_mem_bench.rb`.to_i
118
- home_run = `#{RUBY} -I ext bench/dt_mem_bench.rb`.to_i
77
+ home_run = `#{RUBY} -I lib bench/dt_mem_bench.rb`.to_i
119
78
  puts "DateTime memory use,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
120
79
  end
121
80
 
122
81
  desc "Run comparative garbage creation benchmarks"
123
82
  task :garbage_bench do
124
- if RUBY_PLATFORM =~ /win|w32/
83
+ if RUBY_PLATFORM =~ /mswin|mingw/
125
84
  puts "Garbage creation benchmarks not supported on Windows"
126
85
  next
127
86
  end
128
87
 
129
88
  stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/garbage_bench.rb`.to_i
130
- home_run = `#{RUBY} -I ext bench/garbage_bench.rb`.to_i
89
+ home_run = `#{RUBY} -I lib bench/garbage_bench.rb`.to_i
131
90
  puts "Date garbage created,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
132
91
 
133
92
  stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/dt_garbage_bench.rb`.to_i
134
- home_run = `#{RUBY} -I ext bench/dt_garbage_bench.rb`.to_i
93
+ home_run = `#{RUBY} -I lib bench/dt_garbage_bench.rb`.to_i
135
94
  puts "DateTime garbage created,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
136
95
  end
data/bench/cpu_bench.rb CHANGED
@@ -1,58 +1,5 @@
1
- require 'rbconfig'
2
- $:.unshift RbConfig::CONFIG['rubylibdir']
3
- require 'date'
4
- require 'benchmark'
5
-
6
- SD = Date
7
- SDT = DateTime
8
- Object.send(:remove_const, :Date)
9
- Object.send(:remove_const, :DateTime)
10
- $:.unshift(File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'ext'))
11
- load 'ext/date.rb'
12
- load 'ext/date/format.rb'
13
- HRD = Date
14
- HRDT = DateTime
15
- NANOS_PER_SEC = 1000000000
16
- N = 10000
17
- FILTER = ARGV.empty? ? nil : Regexp.new(ARGV[0])
18
-
19
- def compare(label, datetime=false, &block)
20
- return if FILTER && label !~ FILTER
21
- Object.send(:remove_const, :Date)
22
- Object.send(:remove_const, :DateTime)
23
- Object.send(:const_set, :Date, SD)
24
- Object.send(:const_set, :DateTime, SDT)
25
- stdlib = 0.0
26
- stdlib_times = 0
27
- while stdlib < 2
28
- t = Time.now
29
- yield(datetime ? SDT : SD)
30
- stdlib += Time.now - t
31
- stdlib_times += 1
32
- end
33
-
34
- Object.send(:remove_const, :Date)
35
- Object.send(:remove_const, :DateTime)
36
- Object.send(:const_set, :Date, HRD)
37
- Object.send(:const_set, :DateTime, HRDT)
38
- home_run = 0.0
39
- home_run_times = 0
40
- while home_run < 2
41
- t = Time.now
42
- yield(datetime ? HRDT : HRD)
43
- home_run += Time.now - t
44
- home_run_times += 1
45
- end
46
-
47
- puts sprintf('%s%s,%i,%i,%0.2f', datetime ? 'DateTime' : 'Date', label, (stdlib * NANOS_PER_SEC)/(N * stdlib_times), (home_run * NANOS_PER_SEC)/(N * home_run_times), (stdlib/stdlib_times)/(home_run/home_run_times))
48
- end
49
-
50
- def dt_compare(label, &block)
51
- compare(label, true, &block)
52
- end
53
-
1
+ load(File.join(File.dirname(File.expand_path(__FILE__)), 'cpu_bench_util.rb'))
54
2
  n = N
55
- puts "label,stdlib,home_run,times faster"
56
3
  compare("._parse"){|dc| n.times{dc._parse('2010-12-13')}}
57
4
  compare("._strptime"){|dc| n.times{dc._strptime('fri jan 5 00:00:00 2007', '%c')}}
58
5
  compare(".civil"){|dc| n.times{dc.civil(2010, 1, 1)}}
@@ -0,0 +1,55 @@
1
+ require 'rbconfig'
2
+ $:.unshift RbConfig::CONFIG['rubylibdir']
3
+ require 'date'
4
+ require 'benchmark'
5
+
6
+ SD = Date
7
+ SDT = DateTime
8
+ Object.send(:remove_const, :Date)
9
+ Object.send(:remove_const, :DateTime)
10
+ $:.unshift(File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'lib'))
11
+ load 'lib/date.rb'
12
+ load 'lib/date/format.rb'
13
+ HRD = Date
14
+ HRDT = DateTime
15
+ NANOS_PER_SEC = 1000000000
16
+ N = ENV['N'] ? ENV['N'].to_i : 10000
17
+ S = ENV['S'] ? ENV['S'].to_f : 2
18
+ FILTER = ARGV.empty? ? nil : Regexp.new(ARGV[0])
19
+
20
+ def compare(label, datetime=false, &block)
21
+ return if FILTER && label !~ FILTER
22
+ Object.send(:remove_const, :Date)
23
+ Object.send(:remove_const, :DateTime)
24
+ Object.send(:const_set, :Date, SD)
25
+ Object.send(:const_set, :DateTime, SDT)
26
+ stdlib = 0.0
27
+ stdlib_times = 0
28
+ while stdlib < S
29
+ t = Time.now
30
+ yield(datetime ? SDT : SD)
31
+ stdlib += Time.now - t
32
+ stdlib_times += 1
33
+ end
34
+
35
+ Object.send(:remove_const, :Date)
36
+ Object.send(:remove_const, :DateTime)
37
+ Object.send(:const_set, :Date, HRD)
38
+ Object.send(:const_set, :DateTime, HRDT)
39
+ home_run = 0.0
40
+ home_run_times = 0
41
+ while home_run < S
42
+ t = Time.now
43
+ yield(datetime ? HRDT : HRD)
44
+ home_run += Time.now - t
45
+ home_run_times += 1
46
+ end
47
+
48
+ puts sprintf('%s%s,%i,%i,%0.2f', datetime ? 'DateTime' : 'Date', label, (stdlib * NANOS_PER_SEC)/(N * stdlib_times), (home_run * NANOS_PER_SEC)/(N * home_run_times), (stdlib/stdlib_times)/(home_run/home_run_times))
49
+ end
50
+
51
+ def dt_compare(label, &block)
52
+ compare(label, true, &block)
53
+ end
54
+
55
+ puts "label,stdlib,home_run,times faster"
@@ -0,0 +1,20 @@
1
+ load(File.join(File.dirname(File.expand_path(__FILE__)), 'cpu_bench_util.rb'))
2
+ n = N
3
+ formats = <<END
4
+ 2010-12-13
5
+ 2010-12-13 10:20:30
6
+ 2010-12-13 10:20:30-07:00
7
+ 2009/09/23
8
+ 2009/09/23 06:38:06
9
+ 23/Aug/2010
10
+ 23/Aug/2010:14:31:32
11
+ 23/Aug/2010:14:31:32 -0700
12
+ Mon, 23 Aug 2010
13
+ Mon, 23 Aug 2010 11:13:31
14
+ Mon, 23 Aug 2010 11:13:31 -0700
15
+ Mon, 23 Aug 2010 21:43:53 GMT
16
+ END
17
+ formats = formats.split("\n").map{|l| l.chomp}
18
+ formats.each do |f|
19
+ compare("._parse #{f.inspect}"){|dc| n.times{dc._parse(f)}}
20
+ end
data/bin/home_run CHANGED
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'optparse'
4
+ require 'rbconfig'
4
5
 
5
6
  command = :run
6
- lib = File.expand_path('../../ext', __FILE__)
7
+ lib = File.dirname(File.dirname(File.expand_path(__FILE__)))
7
8
 
8
9
  opts = OptionParser.new do |opts|
9
10
  opts.banner = "home_run: Fast Date/DateTime classes for ruby"
10
- opts.define_head "Usage: home_run (--install | --uninstall | --bench | --spec | command)"
11
+ opts.define_head "Usage: home_run (--option | command)"
11
12
  opts.separator ""
12
13
  opts.separator "Options:"
13
14
 
@@ -35,16 +36,14 @@ opts.order!
35
36
 
36
37
  case command
37
38
  when :bench
38
- Dir.chdir(File.join(lib, '..'))
39
- require 'rbconfig'
39
+ Dir.chdir(lib)
40
40
  ENV['RUBY'] = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
41
41
  require 'rubygems'
42
42
  require 'rake'
43
43
  load './Rakefile'
44
44
  Rake::Task[:bench_all].invoke
45
45
  when :spec
46
- Dir.chdir(File.join(lib, '..'))
47
- require 'rbconfig'
46
+ Dir.chdir(lib)
48
47
  ENV['PATH'] = [RbConfig::CONFIG['bindir'], ENV['PATH']].join(File::PATH_SEPARATOR)
49
48
  ENV['RUBY'] = File.join(RbConfig::CONFIG['ruby_install_name'])
50
49
  require 'rubygems'
@@ -53,27 +52,25 @@ when :spec
53
52
  Rake::Task[:default].invoke
54
53
  when :install
55
54
  Dir.chdir(lib)
56
- require 'rbconfig'
57
55
  require 'fileutils'
58
56
  FUV = FileUtils::Verbose
59
- FUV.cp("date.rb", RbConfig::CONFIG['sitelibdir'])
57
+ FUV.cp("lib/date.rb", RbConfig::CONFIG['sitelibdir'])
60
58
  FUV.mkdir_p(File.join(RbConfig::CONFIG['sitelibdir'], 'date'))
61
- FUV.cp("date/format.rb", File.join(RbConfig::CONFIG['sitelibdir'], 'date'))
62
- if File.exists?("date_ext.#{RbConfig::CONFIG['DLEXT']}")
63
- FUV.cp("date_ext.#{RbConfig::CONFIG['DLEXT']}", RbConfig::CONFIG['sitearchdir'])
59
+ FUV.cp("lib/date/format.rb", File.join(RbConfig::CONFIG['sitelibdir'], 'date'))
60
+ if File.exists?("lib/date_ext.#{RbConfig::CONFIG['DLEXT']}")
61
+ FUV.cp("lib/date_ext.#{RbConfig::CONFIG['DLEXT']}", RbConfig::CONFIG['sitearchdir'])
64
62
  else
65
63
  # Windows binary gem files
66
- if File.exists?('1.8/date_ext.so')
64
+ if File.exists?('lib/1.8/date_ext.so')
67
65
  FUV.mkdir_p(File.join(RbConfig::CONFIG['sitearchdir'], '1.8'))
68
- FUV.cp("1.8/date_ext.so", File.join(RbConfig::CONFIG['sitearchdir'], '1.8'))
66
+ FUV.cp("lib/1.8/date_ext.so", File.join(RbConfig::CONFIG['sitearchdir'], '1.8'))
69
67
  end
70
- if File.exists?('1.9/date_ext.so')
68
+ if File.exists?('lib/1.9/date_ext.so')
71
69
  FUV.mkdir_p(File.join(RbConfig::CONFIG['sitearchdir'], '1.9'))
72
- FUV.cp("1.9/date_ext.so", File.join(RbConfig::CONFIG['sitearchdir'], '1.9'))
70
+ FUV.cp("lib/1.9/date_ext.so", File.join(RbConfig::CONFIG['sitearchdir'], '1.9'))
73
71
  end
74
72
  end
75
73
  when :uninstall
76
- require 'rbconfig'
77
74
  require 'fileutils'
78
75
  FUV = FileUtils::Verbose
79
76
  FUV.rm_f(File.join(RbConfig::CONFIG['sitelibdir'], 'date.rb'))
@@ -86,6 +83,6 @@ when :uninstall
86
83
  FUV.rmdir(File.join(RbConfig::CONFIG['sitearchdir'], '1.9')) rescue nil
87
84
  else
88
85
  ENV['RUBYOPT'] = "-rdate #{ENV['RUBYOPT']}"
89
- ENV['RUBYLIB'] = [lib, ENV['RUBYLIB']].join(File::PATH_SEPARATOR)
86
+ ENV['RUBYLIB'] = [File.join(lib, 'lib'), File.join(lib, 'ext', 'date_ext'), ENV['RUBYLIB']].join(File::PATH_SEPARATOR)
90
87
  exec(*ARGV)
91
88
  end
data/default.mspec CHANGED
@@ -7,6 +7,6 @@ unless ENV['HOME']
7
7
  end
8
8
 
9
9
  class MSpecScript
10
- set :flags, %w'-I ext -r date'
10
+ set :flags, %w'-I ext/date_ext -I lib -r date'
11
11
  set :files, ['spec/date/*', 'spec/datetime/*']
12
12
  end