mini_mime 1.1.2 → 1.1.5

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: 69ca27284c4e5ea1ed0cb7168b4f607f9b990f51ab4359e84b2e885e728b076d
4
- data.tar.gz: fcea561edc2c9a3be7b6755cdb43b0b3cde7f6c34090f6271daf1760fd8ced2a
3
+ metadata.gz: 2ba74b6b26e15d4b3c4415cd261469a5ef423a56a12e836b94b92a488ea275ef
4
+ data.tar.gz: 8a85a122d5e0d8e43513eef375b899a2501c51988acca191a2f299aeef7b2065
5
5
  SHA512:
6
- metadata.gz: b65b3456107b00dcb2891f5b86cb4c134a7bdd187043670edbd2f8a7c6c8034b66efd40a5fd2a56711b53bb34249c792d88315d04b59327a775ce5483294769e
7
- data.tar.gz: 1d488dc9b02a5a871dc313ab72860813b2e7245f9e889896e8072afaa5e31592850baa21249424765d7047c043431f61836a76078fc7b1ecc195c4f68465f97d
6
+ metadata.gz: d591fdc7a13ef2e1d8b05195b73dab9352263cad29fe60487c7d418e8fe135b021ebee2b485f79b031eb53df92b2dda97bc0db208b57363a430089323c5cd61f
7
+ data.tar.gz: 1d9971f665cfdf6cfc73d80183ee7ccfdbb27261177de17b70ad839203b6f898d8ff322159e3c36525c6d1ebef2d24500aced4f42f75ebbd3e7f955e7fcb853a
@@ -4,31 +4,42 @@ on:
4
4
  pull_request:
5
5
  push:
6
6
  branches:
7
- - master
7
+ - main
8
8
 
9
9
  jobs:
10
10
  build:
11
- runs-on: ubuntu-latest
12
- name: "Ruby ${{ matrix.ruby }} / Failure allowed: ${{ matrix.experimental }}"
11
+ runs-on: ${{ matrix.os }}-latest
12
+ name: "Ruby ${{ matrix.ruby }} / ${{ matrix.os }} / Failure allowed: ${{ matrix.experimental }}"
13
13
  continue-on-error: ${{ matrix.experimental }}
14
+ timeout-minutes: 5
15
+
14
16
  strategy:
15
17
  fail-fast: false
16
18
  matrix:
17
- ruby: ["2.4", "2.5", "2.6", "2.7"]
19
+ os: ["ubuntu"]
20
+ ruby: ["2.6", "2.7", "3.0", "3.1", "3.2"]
18
21
  experimental: [false]
19
22
  include:
23
+ - ruby: "3.2"
24
+ os: "windows"
25
+ experimental: false
20
26
  - ruby: "ruby-head"
27
+ os: "ubuntu"
21
28
  experimental: true
22
29
  - ruby: "truffleruby-head"
30
+ os: "ubuntu"
23
31
  experimental: true
24
32
  - ruby: "jruby-head"
33
+ os: "ubuntu"
25
34
  experimental: true
26
- - ruby: "jruby-9.1.17.0"
35
+ - ruby: "jruby-9.3.9.0"
36
+ os: "ubuntu"
27
37
  experimental: true
28
- - ruby: "jruby-9.2.13.0"
38
+ - ruby: "jruby-9.4.0.0"
39
+ os: "ubuntu"
29
40
  experimental: true
30
41
  steps:
31
- - uses: actions/checkout@v2
42
+ - uses: actions/checkout@v3
32
43
  - uses: ruby/setup-ruby@v1
33
44
  with:
34
45
  ruby-version: ${{ matrix.ruby }}
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  name: "Update MIME type DB"
13
13
  steps:
14
- - uses: actions/checkout@v2
14
+ - uses: actions/checkout@v3
15
15
  - uses: ruby/setup-ruby@v1
16
16
  with:
17
17
  ruby-version: "2.7"
data/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
1
+ 08-08-2023
2
+ - Version 1.1.5
3
+ - Update mime types from upstream
4
+
5
+ 08-08-2023
6
+ - Version 1.1.4
7
+ - Version 1.1.3 had issues on Windows which does not support pread, added a polyfill
8
+
9
+ 04-08-2023
10
+ - Version 1.1.3
11
+ - Added fork safety by migrating from seek+read to pread
12
+
1
13
  11-10-2021
2
14
  - Version 1.1.2
3
15
  - update mime types from upstream
@@ -224,6 +224,7 @@ xbd application/vnd.fujixerox.docuworks.binder
224
224
  fzs application/vnd.fuzzysheet base64
225
225
  txd application/vnd.genomatix.tuxedo base64
226
226
  ggb application/vnd.geogebra.file base64
227
+ ggs application/vnd.geogebra.slides base64
227
228
  ggt application/vnd.geogebra.tool base64
228
229
  gex application/vnd.geometry-explorer base64
229
230
  gxt application/vnd.geonext base64
@@ -692,6 +693,7 @@ ttf font/ttf
692
693
  woff font/woff base64
693
694
  woff2 font/woff2 base64
694
695
  avif image/avif base64
696
+ bmp image/bmp base64
695
697
  cgm image/cgm base64
696
698
  g3 image/g3fax base64
697
699
  gif image/gif base64
@@ -731,7 +733,6 @@ xif image/vnd.xiff
731
733
  webp image/webp base64
732
734
  3ds image/x-3ds base64
733
735
  dng image/x-adobe-dng base64
734
- bmp image/x-bmp base64
735
736
  cr2 image/x-canon-cr2 base64
736
737
  crw image/x-canon-crw base64
737
738
  ras image/x-cmu-raster base64
@@ -787,6 +788,7 @@ ics text/calendar
787
788
  css text/css 8bit
788
789
  csv text/csv 8bit
789
790
  html text/html 8bit
791
+ js text/javascript quoted-printable
790
792
  markdown text/markdown quoted-printable
791
793
  n3 text/n3 quoted-printable
792
794
  txt text/plain quoted-printable
data/lib/db/ext_mime.db CHANGED
@@ -70,7 +70,7 @@ blb application/x-blorb
70
70
  bleep application/x-bleeper base64
71
71
  blorb application/x-blorb base64
72
72
  bmi application/vnd.bmi base64
73
- bmp image/x-bmp base64
73
+ bmp image/bmp base64
74
74
  book application/vnd.framemaker base64
75
75
  box application/vnd.previewsystems.box base64
76
76
  boz application/x-bzip2 base64
@@ -121,6 +121,7 @@ chrt application/vnd.kde.kchart
121
121
  cif chemical/x-cif base64
122
122
  cii application/vnd.anser-web-certificate-issue-initiation base64
123
123
  cil application/vnd.ms-artgalry base64
124
+ cjs text/javascript quoted-printable
124
125
  cla application/vnd.claymore base64
125
126
  class application/octet-stream base64
126
127
  clkk application/vnd.crick.clicker.keyboard base64
@@ -312,6 +313,7 @@ gdl model/vnd.gdl
312
313
  geo application/vnd.dynageo base64
313
314
  gex application/vnd.geometry-explorer base64
314
315
  ggb application/vnd.geogebra.file base64
316
+ ggs application/vnd.geogebra.slides base64
315
317
  ggt application/vnd.geogebra.tool base64
316
318
  ghf application/vnd.groove-help base64
317
319
  gif image/gif base64
@@ -408,6 +410,7 @@ jad text/vnd.sun.j2me.app-descriptor
408
410
  jam application/vnd.jam base64
409
411
  jar application/java-archive base64
410
412
  java text/x-java-source quoted-printable
413
+ jfif image/jpeg base64
411
414
  jisp application/vnd.jisp base64
412
415
  jlt application/vnd.hp-jlyt base64
413
416
  jnlp application/x-java-jnlp-file base64
@@ -422,7 +425,7 @@ jpgm image/jpm
422
425
  jpgv video/JPEG base64
423
426
  jpm image/jpm base64
424
427
  jpx image/jpx base64
425
- js application/javascript 8bit
428
+ js text/javascript quoted-printable
426
429
  json application/json 8bit
427
430
  jsonml application/jsonml+json base64
428
431
  k25 image/x-kodak-k25 base64
@@ -521,7 +524,7 @@ mj2 video/MJ2
521
524
  mjp2 video/MJ2 base64
522
525
  mjpeg video/x-motion-jpeg base64
523
526
  mjpg video/x-motion-jpeg base64
524
- mjs application/javascript 8bit
527
+ mjs text/javascript quoted-printable
525
528
  mk3d video/x-matroska base64
526
529
  mka audio/x-matroska base64
527
530
  mkd text/markdown quoted-printable
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module MiniMime
3
- VERSION = "1.1.2"
3
+ VERSION = "1.1.5"
4
4
  end
data/lib/mini_mime.rb CHANGED
@@ -50,8 +50,6 @@ module MiniMime
50
50
  end
51
51
 
52
52
  class Db
53
- LOCK = Mutex.new
54
-
55
53
  def self.lookup_by_filename(filename)
56
54
  extension = File.extname(filename)
57
55
  return if extension.empty?
@@ -60,18 +58,14 @@ module MiniMime
60
58
  end
61
59
 
62
60
  def self.lookup_by_extension(extension)
63
- LOCK.synchronize do
64
- @db ||= new
65
- @db.lookup_by_extension(extension) ||
66
- @db.lookup_by_extension(extension.downcase)
67
- end
61
+ @db ||= new
62
+ @db.lookup_by_extension(extension) ||
63
+ @db.lookup_by_extension(extension.downcase)
68
64
  end
69
65
 
70
66
  def self.lookup_by_content_type(content_type)
71
- LOCK.synchronize do
72
- @db ||= new
73
- @db.lookup_by_content_type(content_type)
74
- end
67
+ @db ||= new
68
+ @db.lookup_by_content_type(content_type)
75
69
  end
76
70
 
77
71
  class Cache
@@ -91,14 +85,40 @@ module MiniMime
91
85
  end
92
86
  end
93
87
 
88
+ if ::File.method_defined?(:pread)
89
+ PReadFile = ::File
90
+ else
91
+ # For Windows support
92
+ class PReadFile
93
+ def initialize(filename)
94
+ @mutex = Mutex.new
95
+ # We must open the file in binary mode
96
+ # otherwise Ruby's automatic line terminator
97
+ # translation will skew the row size
98
+ @file = ::File.open(filename, 'rb')
99
+ end
100
+
101
+ def readline(*args)
102
+ @file.readline(*args)
103
+ end
104
+
105
+ def pread(size, offset)
106
+ @mutex.synchronize do
107
+ @file.seek(offset, IO::SEEK_SET)
108
+ @file.read(size)
109
+ end
110
+ end
111
+ end
112
+ end
113
+
94
114
  class RandomAccessDb
95
115
  MAX_CACHED = 100
96
116
 
97
117
  def initialize(path, sort_order)
98
118
  @path = path
99
- @file = File.open(@path)
119
+ @file = PReadFile.new(@path)
100
120
 
101
- @row_length = @file.readline.length
121
+ @row_length = @file.readline("\n").length
102
122
  @file_length = File.size(@path)
103
123
  @rows = @file_length / @row_length
104
124
 
@@ -146,8 +166,7 @@ module MiniMime
146
166
  end
147
167
 
148
168
  def resolve(row)
149
- @file.seek(row * @row_length)
150
- Info.new(@file.readline)
169
+ Info.new(@file.pread(@row_length, row * @row_length).force_encoding(Encoding::UTF_8))
151
170
  end
152
171
  end
153
172
 
data/mini_mime.gemspec CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ["Sam Saffron"]
11
11
  spec.email = ["sam.saffron@gmail.com"]
12
12
 
13
- spec.summary = %q{A lightweight mime type lookup toy}
14
- spec.description = %q{A lightweight mime type lookup toy}
13
+ spec.summary = %q{A minimal mime type library}
14
+ spec.description = %q{A minimal mime type library}
15
15
  spec.homepage = "https://github.com/discourse/mini_mime"
16
16
  spec.license = "MIT"
17
17
 
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.bindir = "exe"
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
+ spec.required_ruby_version = ">= 2.6.0"
24
25
 
25
26
  spec.add_development_dependency "bundler"
26
27
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_mime
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-11 00:00:00.000000000 Z
11
+ date: 2023-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: A lightweight mime type lookup toy
83
+ description: A minimal mime type library
84
84
  email:
85
85
  - sam.saffron@gmail.com
86
86
  executables: []
@@ -118,15 +118,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - ">="
120
120
  - !ruby/object:Gem::Version
121
- version: '0'
121
+ version: 2.6.0
122
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  requirements:
124
124
  - - ">="
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.1.6
128
+ rubygems_version: 3.4.6
129
129
  signing_key:
130
130
  specification_version: 4
131
- summary: A lightweight mime type lookup toy
131
+ summary: A minimal mime type library
132
132
  test_files: []