Sha256: eeefb538ef65dce880459e644e457d064f317da2dfd20474203571c4b91231dd

Contents?: true

Size: 603 Bytes

Versions: 3

Compression:

Stored size: 603 Bytes

Contents

# frozen_string_literal: true

require 'English'
require 'shellwords'

module Geet
  module Helpers
    module OsHelper
      def open_file_with_default_application(file_or_url)
        if `uname`.strip == 'Darwin'
          exec "open #{file_or_url.shellescape}"
        else
          exec "xdg-open #{file_or_url.shellescape}"
        end
      end

      def execute_command(description, *command_tokens)
        system(*command_tokens.map(&:shellescape))

        raise "Error during #{description} (exit status: #{$CHILD_STATUS.exitstatus})" if !$CHILD_STATUS.success?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
geet-0.3.0 lib/geet/helpers/os_helper.rb
geet-0.2.1 lib/geet/helpers/os_helper.rb
geet-0.2.0 lib/geet/helpers/os_helper.rb