Sha256: 53188f8d73e3a5578f7145ab0aee7a9353c9f36eea9f1d111340df7cf6b89fd6

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require 'English'
module HtmlTo
  module Chromium
    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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
html_to-1.1.3 lib/html_to/chromium.rb
html_to-1.1.2 lib/html_to/chromium.rb