diff options
| author | Jorne Kandziora <[email protected]> | 2021-03-27 11:41:11 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-03-27 11:41:11 +0100 |
| commit | 6072a9f6052f2022f5281f4ce2a0df499c01d07a (patch) | |
| tree | 808e6a6e3075d8c58feca66a1cd673f8968d2840 | |
| parent | 46c2ff10319cf068c15052ab2a320b974699e6e9 (diff) | |
| download | caxlsx-6072a9f6052f2022f5281f4ce2a0df499c01d07a.tar.gz caxlsx-6072a9f6052f2022f5281f4ce2a0df499c01d07a.zip | |
Replace mimemagic with marcel (#95)
Mimemagic requires users to download or install additional files.
Rails used Marcel as an abstration layer on this library. Marcel
was updated to another file matching database. Following Rails in
this matter will remove the need for users to do additional work,
just to use caxlsx.
| -rw-r--r-- | axlsx.gemspec | 2 | ||||
| -rw-r--r-- | lib/axlsx.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/util/mime_type_utils.rb | 2 | ||||
| -rw-r--r-- | test/tc_helper.rb | 2 | ||||
| -rw-r--r-- | test/tc_package.rb | 2 |
5 files changed, 4 insertions, 6 deletions
diff --git a/axlsx.gemspec b/axlsx.gemspec index 3f8a5008..2b5c96ec 100644 --- a/axlsx.gemspec +++ b/axlsx.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'nokogiri', '~> 1.10', '>= 1.10.4' s.add_runtime_dependency 'rubyzip', '>= 1.3.0', '< 3' s.add_runtime_dependency "htmlentities", "~> 4.3", '>= 4.3.4' - s.add_runtime_dependency "mimemagic", '~> 0.3' + s.add_runtime_dependency "marcel", '~> 1.0' s.add_development_dependency 'yard', "~> 0.9.8" s.add_development_dependency 'kramdown', '~> 2.3' diff --git a/lib/axlsx.rb b/lib/axlsx.rb index be4a2cd5..5be3c526 100644 --- a/lib/axlsx.rb +++ b/lib/axlsx.rb @@ -1,7 +1,7 @@ # encoding: UTF-8 require 'htmlentities' require 'axlsx/version.rb' -require 'mimemagic' +require 'marcel' require 'axlsx/util/simple_typed_list.rb' require 'axlsx/util/constants.rb' diff --git a/lib/axlsx/util/mime_type_utils.rb b/lib/axlsx/util/mime_type_utils.rb index 3fe2dbbd..9ad56630 100644 --- a/lib/axlsx/util/mime_type_utils.rb +++ b/lib/axlsx/util/mime_type_utils.rb @@ -5,7 +5,7 @@ module Axlsx # @param [String] v File path # @return [String] File mime type def self.get_mime_type(v) - MimeMagic.by_magic(File.open(v)).to_s + Marcel::MimeType.for(Pathname.new(v)) end end end diff --git a/test/tc_helper.rb b/test/tc_helper.rb index 396f19b2..af40a1e4 100644 --- a/test/tc_helper.rb +++ b/test/tc_helper.rb @@ -8,5 +8,3 @@ end require 'test/unit' require "timecop" require "axlsx.rb" -# MIME detection for Microsoft Office 2007+ formats -require 'mimemagic/overlay' diff --git a/test/tc_package.rb b/test/tc_package.rb index d313c2bd..f1ce0421 100644 --- a/test/tc_package.rb +++ b/test/tc_package.rb @@ -228,7 +228,7 @@ class TestPackage < Test::Unit::TestCase end def test_serialization_creates_files_with_excel_mime_type - assert_equal(MimeMagic.by_magic(@package.to_stream).type, + assert_equal(Marcel::MimeType.for(@package.to_stream), 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') end |
