Module: HtmlTo::Chromium

Included in:
ImageGenerate
Defined in:
lib/html_to/chromium.rb

Class Method Summary collapse

Class Method Details

.execute_pathObject

Raises:

  • (StandardError)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/html_to/chromium.rb', line 4

def self.execute_path
  if Configuration.chromium_path.present?
    raise ArgumentError, "html_to error: not found chromium by path #{Configuration.chromium_path}" unless File.exist? Configuration.chromium_path

    return Configuration.chromium_path
  end

  path = if /darwin/.match?(RbConfig::CONFIG['host_os'])
           '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
         elsif /linux/.match?(RbConfig::CONFIG['host_os'])
           release = %x(lsb_release -i -s)
           %x(which chromium-browser)
           if release == "Debian\n"
             which_path = %x(which chromium)
             raise StandardError, "html_to error: You don't have chromium, please do apt install chromium" unless $CHILD_STATUS.success?

           else
             which_path = %x(which chromium-browser)
             raise StandardError, "html_to error: You don't have chromium, please do apt install chromium-browser" unless $CHILD_STATUS.success?
           end
           which_path
         else
           raise StandardError, "html_to error host os don't detected"
         end
  raise StandardError, 'html_to error: chromium executable path not found' if path.blank?

  path.delete("\n")
end

.versionObject



33
34
35
# File 'lib/html_to/chromium.rb', line 33

def self.version
  %x(#{execute_path} --version)
end