Skip to content

Commit

Permalink
[Analyzer] Do not load image analyzer gem if already loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Mth0158 committed Dec 8, 2024
1 parent 96033ed commit 44a6c6f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Analyzer::ImageAnalyzer::ImageMagick < Analyzer::ImageAnalyzer

def read_image
begin
require "mini_magick"
require "mini_magick" unless Object.const_defined?(:MiniMagick)
rescue LoadError
logger.info "Skipping image analysis because the mini_magick gem isn't installed"
return {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Analyzer::ImageAnalyzer::Vips < Analyzer::ImageAnalyzer

def read_image
begin
require "ruby-vips"
require "ruby-vips" unless Object.const_defined?(:Vips)
rescue LoadError
logger.info "Skipping image analysis because the ruby-vips gem isn't installed"
return {}
Expand Down
2 changes: 2 additions & 0 deletions test/analyzers/image_analyzers/image_magick_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
require 'analyzers/support/analyzer_helpers'
require 'analyzers/image_analyzers/shared_examples/returns_the_right_metadata_for_any_attachable'

return unless Object.const_defined?(:MiniMagick)

describe ActiveStorageValidations::Analyzer::ImageAnalyzer::ImageMagick do
include AnalyzerHelpers

Expand Down
2 changes: 2 additions & 0 deletions test/analyzers/image_analyzers/vips_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
require 'analyzers/support/analyzer_helpers'
require 'analyzers/image_analyzers/shared_examples/returns_the_right_metadata_for_any_attachable'

return unless Object.const_defined?(:Vips)

describe ActiveStorageValidations::Analyzer::ImageAnalyzer::Vips do
include AnalyzerHelpers

Expand Down

0 comments on commit 44a6c6f

Please sign in to comment.