mime-types 2.3 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +2 -0
- data/Contributing.rdoc +2 -0
- data/History-Types.rdoc +26 -0
- data/History.rdoc +24 -0
- data/Licence.rdoc +3 -2
- data/Manifest.txt +2 -1
- data/README.rdoc +24 -9
- data/Rakefile +41 -15
- data/data/mime-types.json +1 -1
- data/lib/mime/type.rb +75 -10
- data/lib/mime/types.rb +13 -5
- data/lib/mime/types/loader.rb +12 -21
- data/support/benchmarks/load.rb +55 -0
- data/support/convert.rb +14 -4
- data/test/bad-fixtures/malformed +9 -0
- data/test/test_mime_type.rb +86 -1
- data/test/test_mime_types.rb +2 -0
- data/test/test_mime_types_class.rb +2 -0
- data/test/test_mime_types_loader.rb +11 -2
- metadata +34 -62
- metadata.gz.sig +0 -0
- data/support/benchmarker.rb +0 -55
metadata.gz.sig
CHANGED
Binary file
|
data/support/benchmarker.rb
DELETED
@@ -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
|