Sha256: 3ab0b59a9693ee5474c2d47a242d15911e85ba2eac63828b7c0adc66b637bdcd
Contents?: true
Size: 924 Bytes
Versions: 6
Compression:
Stored size: 924 Bytes
Contents
# -*- coding: UTF-8 -*- module MJ; # # Utility functions to work with PATH # module Path; # # Open the given +path+ in a file browser with +xdg-open+. # # Will print an error if xdg-open is not found. # # @param [#to_s] Pathname to open. def Path.open( path ) if Path.which( 'xdg-open' ).nil? logger.error( 'xdg-open is not available.' ) end if system( 'xdg-open %s' % [ path ] ).nil? logger.error( 'xdg-open failed to start' ) end end # # Find +cmd+ in environment variable +$PATH+ # def Path.which( cmd ) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each { |ext| exe = "#{path}/#{cmd}#{ext}" return exe if File.executable? exe } end return nil end end; end # module MJ::Path
Version data entries
6 entries across 6 versions & 1 rubygems