mime-types 2.3 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata.gz.sig CHANGED
Binary file
@@ -1,55 +0,0 @@
1
- # -*- ruby encoding: utf-8 -*-
2
-
3
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
- require 'benchmark'
5
-
6
- class Benchmarker
7
- def self.benchmark(repeats)
8
- new(repeats.to_i).benchmark
9
- end
10
-
11
- def initialize(repeats = nil)
12
- @cache_file = File.expand_path('../cache.mtc', __FILE__)
13
- @repeats = repeats.to_i
14
- @repeats = 50 if repeats.zero?
15
- end
16
-
17
- def reload_mime_types(repeats = 1, force_load = false)
18
- path = File.expand_path('../../lib', __FILE__)
19
-
20
- repeats.times {
21
- Object.send(:remove_const, :MIME) if defined? MIME
22
- $LOADED_FEATURES.delete_if { |n| n =~ /#{path}/ }
23
- require 'mime/types'
24
- MIME::Types.send(:__types__) if force_load
25
- }
26
- end
27
-
28
- def benchmark
29
- remove_cache
30
-
31
- Benchmark.bm(17) do |mark|
32
- mark.report("Normal:") { reload_mime_types(@repeats) }
33
-
34
- ENV['RUBY_MIME_TYPES_LAZY_LOAD'] = 'yes'
35
- mark.report("Lazy:") { reload_mime_types(@repeats) }
36
- mark.report("Lazy+Load:") { reload_mime_types(@repeats, true) }
37
-
38
- ENV.delete('RUBY_MIME_TYPES_LAZY_LOAD')
39
-
40
- ENV['RUBY_MIME_TYPES_CACHE'] = @cache_file
41
- reload_mime_types
42
-
43
- mark.report("Cached:") { reload_mime_types(@repeats) }
44
- ENV['RUBY_MIME_TYPES_LAZY_LOAD'] = 'yes'
45
- mark.report("Lazy Cached:") { reload_mime_types(@repeats) }
46
- mark.report("Lazy Cached Load:") { reload_mime_types(@repeats, true) }
47
- end
48
- ensure
49
- remove_cache
50
- end
51
-
52
- def remove_cache
53
- File.unlink(@cache_file) if File.exist?(@cache_file)
54
- end
55
- end