Module: GemSearch::Utils::SystemUtil
- Included in:
- Commands::Browse
- Defined in:
- lib/gem_search/utils/system_util.rb
Instance Method Summary collapse
Instance Method Details
#browser_open(url) ⇒ Object
4 5 6 7 |
# File 'lib/gem_search/utils/system_util.rb', line 4 def browser_open(url) cmd = osx? ? "open" : %w(xdg-open cygstart x-www-browser firefox opera mozilla netscape).find { |com| which com } system(cmd, url) end |
#osx? ⇒ Boolean
10 11 12 13 |
# File 'lib/gem_search/utils/system_util.rb', line 10 def osx? require "rbconfig" RbConfig::CONFIG["host_os"].to_s.include?("darwin") end |
#which(cmd) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gem_search/utils/system_util.rb', line 15 def which(cmd) exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""] ENV["PATH"].split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = "#{path}/#{cmd}#{ext}" return exe if File.executable? exe end end nil end |