Skip to content

Commit 230b916

Browse files
committed
Replace mimemagic with mime-types
This change is to avoid troubles due to the licensing issue of mimemagic. See mimemagicrb/mimemagic#97 for the detail.
1 parent ff36f17 commit 230b916

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

iruby.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
2020
s.add_dependency 'bond', '~> 0.5'
2121
s.add_dependency 'data_uri', '~> 0.1'
2222
s.add_dependency 'ffi-rzmq'
23-
s.add_dependency 'mimemagic', '~> 0.3'
23+
s.add_dependency 'mime-types', '>= 3.3.1'
2424
s.add_dependency 'multi_json', '~> 1.11'
2525

2626
s.add_development_dependency 'pycall', '>= 1.2.1'

lib/iruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'mimemagic'
1+
require 'mime/types'
22
require 'multi_json'
33
require 'securerandom'
44
require 'openssl'

lib/iruby/display.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def clear_output(wait = false)
4444
private
4545

4646
def protect(mime, data)
47-
MimeMagic.new(mime).text? ? data.to_s : [data.to_s].pack('m0')
47+
MIME::Type.new(mime).ascii? ? data.to_s : [data.to_s].pack('m0')
4848
end
4949

5050
def render(data, obj, exact_mime, fuzzy_mime)
@@ -304,7 +304,7 @@ def format(mime = nil, &block)
304304

305305
match { |obj| obj.respond_to?(:path) && obj.method(:path).arity == 0 && File.readable?(obj.path) }
306306
format do |obj|
307-
mime = MimeMagic.by_path(obj.path).to_s
307+
mime = MIME::Types.of(obj.path).first.to_s
308308
[mime, File.read(obj.path)] if SUPPORTED_MIMES.include?(mime)
309309
end
310310

0 commit comments

Comments
 (0)