Class: Convert2Ascii::CheckImageMagick

Inherits:
CheckPackage show all
Defined in:
lib/convert2ascii/check_package.rb

Instance Method Summary collapse

Methods inherited from CheckPackage

#arch_installed?, #centos_installed?, #check, #debian_installed?, #detect_linux_distribution, #macos_installed?, #ms_check, #redhat_installed?, #unknow_check

Methods included from OS

#detect_os

Constructor Details

#initializeCheckImageMagick

Returns a new instance of CheckImageMagick.



135
136
137
138
139
140
141
# File 'lib/convert2ascii/check_package.rb', line 135

def initialize
  super
  @name = "imagemagick"
  @need_error = Rainbow("[Error] `imagemagick` is need!").red
  @tips = Rainbow("[Tips ] For more details and install guide: https://github.com/rmagick/rmagick").green

end

Instance Method Details

#linux_checkObject



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/convert2ascii/check_package.rb', line 149

def linux_check
  # just Debian/Ubuntu
  linux_pkg = {
    "debian" => "libmagickwand-dev",
    "redhat" => "ImageMagick-devel",
    "arch" => "imagemagick",
  }

  linux_platform_name = detect_linux_distribution
  pkg_name = linux_pkg.fetch(linux_platform_name, nil)

  if !pkg_name
    raise CheckPackageError, "\n#{@need_error}\n#{@tips}\n"
  end

  __send__ "#{linux_platform_name}_installed?", pkg_name
end

#macos_checkObject



143
144
145
146
147
# File 'lib/convert2ascii/check_package.rb', line 143

def macos_check
  if !macos_installed?(@name)
    raise CheckPackageError, "\n#{@need_error}\n#{@tips}\n"
  end
end