New Upstream Snapshot - ruby-mini-mime

Ready changes

Summary

Merged new upstream version: 1.1.2+git20230109.1.662db35 (was: 1.1.1).

Resulting package

Built on 2023-01-12T01:21 (took 10m11s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots ruby-mini-mime

Diff

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index 3c538d9..0000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-name: Mini Mime Tests
-
-on:
-  pull_request:
-  push:
-    branches:
-      - master
-
-jobs:
-  build:
-    runs-on: ubuntu-latest
-    name: "Ruby ${{ matrix.ruby }} / Failure allowed: ${{ matrix.experimental }}"
-    continue-on-error: ${{ matrix.experimental }}
-    strategy:
-      fail-fast: false
-      matrix:
-        ruby: ["2.4", "2.5", "2.6", "2.7"]
-        experimental: [false]
-        include:
-          - ruby: "ruby-head"
-            experimental: true
-          - ruby: "truffleruby-head"
-            experimental: true
-          - ruby: "jruby-head"
-            experimental: true
-          - ruby: "jruby-9.1.17.0"
-            experimental: true
-          - ruby: "jruby-9.2.13.0"
-            experimental: true
-    steps:
-      - uses: actions/checkout@v2
-      - uses: ruby/setup-ruby@v1
-        with:
-          ruby-version: ${{ matrix.ruby }}
-          bundler-cache: true
-      - name: Rubocop
-        run: bundle exec rubocop
-        if: "!contains(matrix.ruby, 'jruby')"
-      - name: Tests
-        run: bundle exec rake test
diff --git a/.github/workflows/db.yml b/.github/workflows/db.yml
deleted file mode 100644
index 305d09c..0000000
--- a/.github/workflows/db.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-name: Update MIME type DB
-
-on:
-  schedule:
-    # 10am on the 1st every month https://crontab.guru/#0_10_1_*_*
-    - cron: "0 10 1 * *"
-  workflow_dispatch:
-
-jobs:
-  update_db:
-    runs-on: ubuntu-latest
-    name: "Update MIME type DB"
-    steps:
-      - uses: actions/checkout@v2
-      - uses: ruby/setup-ruby@v1
-        with:
-          ruby-version: "2.7"
-          bundler-cache: true
-      - name: Update mime-types-data
-        run: bundle update mime-types-data
-      - name: Update DB
-        run: bundle exec rake rebuild_db
-      - name: Create PR
-        run: bin/db_pull_request
-        env:
-          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 0cb6eeb..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-/.bundle/
-/.yardoc
-/Gemfile.lock
-/_yardoc/
-/coverage/
-/doc/
-/pkg/
-/spec/reports/
-/tmp/
diff --git a/CHANGELOG b/CHANGELOG
index d4647b2..6910ae9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+11-10-2021
+  - Version 1.1.2
+  - update mime types from upstream
+
 23-08-2021
   - Version 1.1.1
   - update mime types from upstream
diff --git a/debian/changelog b/debian/changelog
index 916e6d8..c5bdd7a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ruby-mini-mime (1.1.2+git20230109.1.662db35-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Thu, 12 Jan 2023 01:15:01 -0000
+
 ruby-mini-mime (1.1.1-2) unstable; urgency=medium
 
   * Team upload.
diff --git a/lib/db/content_type_mime.db b/lib/db/content_type_mime.db
index 85fce0c..95d6d86 100644
--- a/lib/db/content_type_mime.db
+++ b/lib/db/content_type_mime.db
@@ -692,6 +692,7 @@ ttf         font/ttf
 woff        font/woff                                                                 base64          
 woff2       font/woff2                                                                base64          
 avif        image/avif                                                                base64          
+bmp         image/bmp                                                                 base64          
 cgm         image/cgm                                                                 base64          
 g3          image/g3fax                                                               base64          
 gif         image/gif                                                                 base64          
@@ -731,7 +732,6 @@ xif         image/vnd.xiff
 webp        image/webp                                                                base64          
 3ds         image/x-3ds                                                               base64          
 dng         image/x-adobe-dng                                                         base64          
-bmp         image/x-bmp                                                               base64          
 cr2         image/x-canon-cr2                                                         base64          
 crw         image/x-canon-crw                                                         base64          
 ras         image/x-cmu-raster                                                        base64          
@@ -812,6 +812,7 @@ si          text/vnd.wap.si
 sl          text/vnd.wap.sl                                                           quoted-printable
 wml         text/vnd.wap.wml                                                          quoted-printable
 wmls        text/vnd.wap.wmlscript                                                    quoted-printable
+vtt         text/vtt                                                                  quoted-printable
 asm         text/x-asm                                                                quoted-printable
 c           text/x-c                                                                  quoted-printable
 coffee      text/x-coffescript                                                        8bit            
diff --git a/lib/db/ext_mime.db b/lib/db/ext_mime.db
index bd05a77..a07c697 100644
--- a/lib/db/ext_mime.db
+++ b/lib/db/ext_mime.db
@@ -70,7 +70,7 @@ blb         application/x-blorb
 bleep       application/x-bleeper                                                     base64          
 blorb       application/x-blorb                                                       base64          
 bmi         application/vnd.bmi                                                       base64          
-bmp         image/x-bmp                                                               base64          
+bmp         image/bmp                                                                 base64          
 book        application/vnd.framemaker                                                base64          
 box         application/vnd.previewsystems.box                                        base64          
 boz         application/x-bzip2                                                       base64          
@@ -1055,6 +1055,7 @@ vsf         application/vnd.vsf
 vss         application/vnd.visio                                                     base64          
 vst         application/vnd.visio                                                     base64          
 vsw         application/vnd.visio                                                     base64          
+vtt         text/vtt                                                                  quoted-printable
 vtu         model/vnd.vtu                                                             base64          
 vxml        application/voicexml+xml                                                  base64          
 w3d         application/x-director                                                    base64          
diff --git a/lib/mini_mime/version.rb b/lib/mini_mime/version.rb
index 1be3683..a0fa463 100644
--- a/lib/mini_mime/version.rb
+++ b/lib/mini_mime/version.rb
@@ -1,4 +1,4 @@
 # frozen_string_literal: true
 module MiniMime
-  VERSION = "1.1.1"
+  VERSION = "1.1.2"
 end
diff --git a/mini_mime.gemspec b/mini_mime.gemspec
index 9105f5c..2ab398f 100644
--- a/mini_mime.gemspec
+++ b/mini_mime.gemspec
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
   spec.authors       = ["Sam Saffron"]
   spec.email         = ["sam.saffron@gmail.com"]
 
-  spec.summary       = %q{A lightweight mime type lookup toy}
-  spec.description   = %q{A lightweight mime type lookup toy}
+  spec.summary       = %q{A minimal mime type library}
+  spec.description   = %q{A minimal mime type library}
   spec.homepage      = "https://github.com/discourse/mini_mime"
   spec.license       = "MIT"
 
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
   spec.bindir        = "exe"
   spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
   spec.require_paths = ["lib"]
+  spec.required_ruby_version = ">= 2.6.0"
 
   spec.add_development_dependency "bundler"
   spec.add_development_dependency "rake"
diff --git a/test/fixtures/custom_content_type_mime.db b/test/fixtures/custom_content_type_mime.db
new file mode 100644
index 0000000..0df3883
--- /dev/null
+++ b/test/fixtures/custom_content_type_mime.db
@@ -0,0 +1,2 @@
+liquid      application/x-liquid                                                      8bit
+mp4         video/vnd.objectvideo                                                     quoted-printable
diff --git a/test/fixtures/custom_ext_mime.db b/test/fixtures/custom_ext_mime.db
new file mode 100644
index 0000000..2147a75
--- /dev/null
+++ b/test/fixtures/custom_ext_mime.db
@@ -0,0 +1,2 @@
+lua         application/x-lua                                                         8bit
+m4v         video/vnd.objectvideo                                                     quoted-printable
diff --git a/test/mini_mime/configuration_test.rb b/test/mini_mime/configuration_test.rb
new file mode 100644
index 0000000..d2782c7
--- /dev/null
+++ b/test/mini_mime/configuration_test.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+require 'test_helper'
+
+class MiniMime::ConfigurationTest < Minitest::Test
+  CUSTOM_EXT_MIME_DB_PATH = File.expand_path("../../fixtures/custom_ext_mime.db", __FILE__)
+  CUSTOM_CONTENT_TYPE_MIME_DB_PATH = File.expand_path("../../fixtures/custom_content_type_mime.db", __FILE__)
+
+  def setup
+    MiniMime::Db.instance_variable_set(:@db, nil)
+    @old_ext_db_path = MiniMime::Configuration.ext_db_path
+    @old_content_type_db_path = MiniMime::Configuration.content_type_db_path
+  end
+
+  def teardown
+    MiniMime::Db.instance_variable_set(:@db, nil)
+    MiniMime::Configuration.ext_db_path = @old_ext_db_path
+    MiniMime::Configuration.content_type_db_path = @old_content_type_db_path
+  end
+
+  def test_using_custom_ext_mime_db
+    MiniMime::Configuration.ext_db_path = CUSTOM_EXT_MIME_DB_PATH
+
+    assert_equal "application/x-lua", MiniMime.lookup_by_extension("lua").content_type
+    assert_equal "quoted-printable", MiniMime.lookup_by_extension("m4v").encoding
+  end
+
+  def test_using_custom_content_type_mime_db
+    MiniMime::Configuration.content_type_db_path = CUSTOM_CONTENT_TYPE_MIME_DB_PATH
+
+    assert_equal "liquid", MiniMime.lookup_by_content_type("application/x-liquid").extension
+    assert_equal "quoted-printable", MiniMime.lookup_by_content_type("video/vnd.objectvideo").encoding
+  end
+end
diff --git a/test/mini_mime_test.rb b/test/mini_mime_test.rb
new file mode 100644
index 0000000..da8aac2
--- /dev/null
+++ b/test/mini_mime_test.rb
@@ -0,0 +1,80 @@
+# frozen_string_literal: true
+require 'test_helper'
+
+begin
+  require 'mime/types/columnar'
+rescue LoadError
+end
+
+class MiniMimeTest < Minitest::Test
+  def test_that_it_has_a_version_number
+    refute_nil ::MiniMime::VERSION
+  end
+
+  def test_extension
+    assert_equal "application/zip", MiniMime.lookup_by_extension("zip").content_type
+  end
+
+  def test_mixed_case
+
+    # irb(main):009:0> MIME::Types.type_for("TxT").first.to_s
+    # => "text/plain"
+
+    assert_equal "application/vnd.groove-tool-message", MiniMime.lookup_by_filename("a.GTM").content_type
+    assert_equal "application/zip", MiniMime.lookup_by_extension("ZiP").content_type
+  end
+
+  def test_content_type
+    assert_equal "application/vnd.lotus-1-2-3", MiniMime.lookup_by_filename("a.123").content_type
+    assert_equal "application/x-compressed", MiniMime.lookup_by_filename("a.Z").content_type
+    assert_equal "application/vnd.groove-tool-message", MiniMime.lookup_by_filename("a.gtm").content_type
+    assert_equal "application/vnd.HandHeld-Entertainment+xml", MiniMime.lookup_by_filename("a.zmm").content_type
+    assert_equal "text/csv", MiniMime.lookup_by_filename("x.csv").content_type
+    assert_equal "application/x-msaccess", MiniMime.lookup_by_filename("x.mda").content_type
+
+    assert_nil MiniMime.lookup_by_filename("a.frog")
+  end
+
+  def test_binary
+    # note this is not strictly correct but .Z is the only
+    # upper case extension, being correct here seems overkill
+    # many already rely on case insensitive lookups (which is implemented by mime types)
+    assert MiniMime.lookup_by_filename("a.z").binary?
+    assert MiniMime.lookup_by_filename("a.Z").binary?
+    refute MiniMime.lookup_by_filename("a.txt").binary?
+    assert_nil MiniMime.lookup_by_filename("a.frog")
+  end
+
+  def test_binary_content_type
+    assert MiniMime.lookup_by_content_type("application/x-compressed").binary?
+    assert_nil MiniMime.lookup_by_content_type("something-fake")
+    refute MiniMime.lookup_by_content_type("text/plain").binary?
+  end
+
+  def should_prioritize_extensions_correctly
+    assert_equal MiniMime.lookup_by_content_type("text/plain").extension, "txt"
+  end
+
+  if defined? MIME::Types
+    def test_full_parity_with_mime_types
+      exts = Set.new
+      MIME::Types.each do |type|
+        type.extensions.each { |ext| exts << ext }
+      end
+
+      exts.each do |ext|
+        types = MIME::Types.type_for("a.#{ext}")
+
+        type = types.detect { |t| !t.obsolete? }
+        type ||= types.detect(&:registered)
+        type ||= types.first
+
+        # if type.content_type != MiniMime.lookup_by_filename("a.#{ext}").content_type
+        #   puts "#{ext} Expected #{type.content_type} Got #{MiniMime.lookup_by_filename("a.#{ext}").content_type}"
+        # end
+
+        assert_equal type.content_type, MiniMime.lookup_by_filename("a.#{ext}").content_type
+      end
+    end
+  end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 0000000..6e34b5b
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
+require 'mini_mime'
+
+require 'minitest/autorun'

More details

Full run details