Class: Shellfie::DependencyChecker
- Inherits:
-
Object
- Object
- Shellfie::DependencyChecker
- Defined in:
- lib/shellfie/dependency_checker.rb
Constant Summary collapse
- IMAGE_MAGICK_COMMANDS =
%w[magick convert].freeze
Class Method Summary collapse
- .configure_mini_magick!(timeout: 30) ⇒ Object
- .doctor(output_dir: Dir.pwd) ⇒ Object
- .ensure_imagemagick! ⇒ Object
- .imagemagick_available? ⇒ Boolean
- .imagemagick_path ⇒ Object
Class Method Details
.configure_mini_magick!(timeout: 30) ⇒ Object
28 29 30 31 32 |
# File 'lib/shellfie/dependency_checker.rb', line 28 def configure_mini_magick!(timeout: 30) return unless defined?(MiniMagick) && MiniMagick.respond_to?(:timeout=) MiniMagick.timeout = timeout end |
.doctor(output_dir: Dir.pwd) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/shellfie/dependency_checker.rb', line 34 def doctor(output_dir: Dir.pwd) [ check("Ruby", RUBY_VERSION, Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0")), check("ImageMagick", imagemagick_path || "not found", imagemagick_available?), check("Writable output", output_dir, File.writable?(output_dir)), check("Encoding", Encoding.default_external.name, true) ] end |
.ensure_imagemagick! ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/shellfie/dependency_checker.rb', line 18 def ensure_imagemagick! return if imagemagick_available? raise DependencyError, <<~MSG ImageMagick not found → Please install ImageMagick: brew install imagemagick → Or visit: https://imagemagick.org/script/download.php MSG end |
.imagemagick_available? ⇒ Boolean
14 15 16 |
# File 'lib/shellfie/dependency_checker.rb', line 14 def imagemagick_available? !imagemagick_path.to_s.empty? end |
.imagemagick_path ⇒ Object
10 11 12 |
# File 'lib/shellfie/dependency_checker.rb', line 10 def imagemagick_path @imagemagick_path ||= find_executable(IMAGE_MAGICK_COMMANDS) end |