mimetype 1.2.0 → 1.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6ed312b9b4b95657d1ef3f823732bafd47024c04c22008c3dc4cec42f7fcb89
4
- data.tar.gz: d12c5167922ce3b1fef1268b82685ec1ffa293f8c2588ebde54d938d92a47a95
3
+ metadata.gz: 356ff498fef82f2ce2a23ee7078769405c112d3351c63141b9fb91567c563fd0
4
+ data.tar.gz: 2f02165c68bd41726fc976b16d767303402221cc5aa5cedfa2643fca6aaace72
5
5
  SHA512:
6
- metadata.gz: acb4eff9419898e17e28664c4d1c7eca07c85967087b16ee95a079937462176c47e8668e13fdbffab38dc556314711bed031f136340489dd63df40561d7c62ad
7
- data.tar.gz: f05f3051eebc97bffac87873e945c83858e018ff746b4e9bb46687f94aaa541df4758d479395fd1da1e6adbd4199b95389a887717cbcd43bcb309b0849de3860
6
+ metadata.gz: fb0f305d00c57e47dc2be0b3c75fe6d340b9b28321749a654ce02a3f58acd210471910d481e264ec30fbdc2863a7ec8d196fbbf8f0afd1e52da3941704d0df22
7
+ data.tar.gz: a3e2242a3068a29887d4d866e888cc49a40d82342e13643788d4adf64627e71be337dd584d9cfb989513ca580493a3786bc3d3c4143e52619fa18a2a732ecb7d
data/README.md CHANGED
@@ -22,27 +22,39 @@ MimeType.lookup_by_filename("hello.txt")
22
22
  ## Performance
23
23
 
24
24
  ```
25
- MimeType: 19983 obj @ 1495392 bytes w/ 5467 obj @ 372766 bytes retained
26
- MIME::Type: 96527 obj @ 7607027 bytes w/ 30706 obj @ 2717341 bytes retained
25
+ MimeType: 23397 obj @ 1670599 bytes w/ 9169 obj @ 573112 bytes retained
26
+ MIME::Type: 96527 obj @ 7606239 bytes w/ 30706 obj @ 2716382 bytes retained
27
27
  MiniMime: 399 obj @ 41769 bytes w/ 54 obj @ 7229 bytes retained
28
28
 
29
29
 
30
30
  Warming up --------------------------------------
31
- MIME::TYPE by ext 27.428k i/100ms
32
- MimeType by ext 139.974k i/100ms
33
- MiniMime by ext 50.359k i/100ms
31
+ MIME::TYPE by ext 27.369k i/100ms
32
+ MimeType by ext 134.058k i/100ms
33
+ MiniMime by ext 51.839k i/100ms
34
34
  Calculating -------------------------------------
35
- MIME::TYPE by ext 299.961k (± 2.8%) i/s - 3.620M in 12.079154s
36
- MimeType by ext 2.183M2.8%) i/s - 26.175M in 12.001221s
37
- MiniMime by ext 587.215k (± 3.4%) i/s - 7.050M in 12.021076s
35
+ MIME::TYPE by ext 301.471k (± 2.5%) i/s - 3.640M in 12.081653s
36
+ MimeType by ext 2.107M1.8%) i/s - 25.337M in 12.031807s
37
+ MiniMime by ext 607.654k (± 3.1%) i/s - 7.309M in 12.040407s
38
+
39
+ Comparison:
40
+ MimeType by ext: 2106589.0 i/s
41
+ MiniMime by ext: 607653.8 i/s - 3.47x slower
42
+ MIME::TYPE by ext: 301470.5 i/s - 6.99x slower
43
+
38
44
 
39
45
 
40
46
  Warming up --------------------------------------
41
- MIME::TYPE by type 23.384k i/100ms
42
- MimeType by type 233.563k i/100ms
43
- MiniMime by type 123.538k i/100ms
47
+ MIME::TYPE by type 23.544k i/100ms
48
+ MimeType by type 199.664k i/100ms
49
+ MiniMime by type 123.087k i/100ms
44
50
  Calculating -------------------------------------
45
- MIME::TYPE by type 250.691k (± 3.5%) i/s - 3.017M in 12.047206s
46
- MimeType by type 5.136M (± 1.2%) i/s - 61.661M in 12.007824s
47
- MiniMime by type 1.842M1.5%) i/s - 22.113M in 12.007235s
51
+ MIME::TYPE by type 243.347k (± 3.8%) i/s - 2.919M in 12.014030s
52
+ MimeType by type 3.960M (± 1.5%) i/s - 47.520M in 12.002210s
53
+ MiniMime by type 1.859M2.0%) i/s - 22.402M in 12.054182s
54
+
55
+ Comparison:
56
+ MimeType by type: 3960282.0 i/s
57
+ MiniMime by type: 1859217.4 i/s - 2.13x slower
58
+ MIME::TYPE by type: 243347.1 i/s - 16.27x slower
59
+
48
60
  ```
@@ -3510,7 +3510,7 @@
3510
3510
  ]
3511
3511
  },
3512
3512
  "text/html": {
3513
- "extension": ".htm",
3513
+ "extension": ".html",
3514
3514
  "content_type": "text/html",
3515
3515
  "content_types": [
3516
3516
  "text/html"
Binary file
@@ -102,9 +102,9 @@ module MimeType
102
102
  # @param path [String, Pathutil, Pathname, File] the path
103
103
  # Find by path
104
104
  # --
105
- def lookup_by_filename(path)
106
- ext = File.extname(path)
107
- to_h[:e][ext]
105
+ def lookup_by_filename(v)
106
+ v = File.extname(v)
107
+ to_h[:e][v]
108
108
  end
109
109
 
110
110
  # --
@@ -112,8 +112,9 @@ module MimeType
112
112
  # @param ext [String] the extension in "." format
113
113
  # @return [Struct]
114
114
  # --
115
- def lookup_by_extension(extension)
116
- to_h[:e][extension]
115
+ def lookup_by_extension(v)
116
+ v = v.extension if v.is_a?(T)
117
+ to_h[:e][v]
117
118
  end
118
119
 
119
120
  # --
@@ -121,8 +122,9 @@ module MimeType
121
122
  # @param content_type [String] the content type
122
123
  # @return [Struct]
123
124
  # --
124
- def lookup_by_content_type(content_type)
125
- to_h[:c][content_type]
125
+ def lookup_by_content_type(v)
126
+ v = v.content_type if v.is_a?(T)
127
+ to_h[:c][v]
126
128
  end
127
129
 
128
130
  # --
@@ -3,5 +3,5 @@
3
3
  # Encoding: utf-8
4
4
 
5
5
  module MimeType
6
- VERSION = "1.2.0"
6
+ VERSION = "1.3.0"
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mimetype
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordon Bedwell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-06 00:00:00.000000000 Z
11
+ date: 2018-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pathutil