Skip to content

Commit

Permalink
Update web command behavior
Browse files Browse the repository at this point in the history
Now this command uses the BROWSER env variable to open links. If it is unset, the command just outputs the URL
  • Loading branch information
MatheusRich committed Jul 20, 2019
1 parent 0c4266b commit c70106a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 323 deletions.
54 changes: 4 additions & 50 deletions lib/rubygems/executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,6 @@ module Gem
module Web
class Executor

def open_default_browser_cmd(local_os, version, uri)
case local_os
when 'aix'
"defaultbrowser #{uri}"
when 'cygwin'
"cygstart #{uri}"
when 'darwin'
"open #{uri}"
when 'macruby'
"open #{uri}"
when 'freebsd'
"xdg-open #{uri}"
when 'hpux'
""
when 'java'
"if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {" \
"Desktop.getDesktop().browse(new URI(#{uri}));" \
"}"
when 'dalvik'
""
when 'dotnet'
"System.Diagnostics.Process.Start(#{uri});"
when 'linux'
"xdg-open #{uri}"
when 'mingw32'
"start #{uri}"
when 'netbsdelf'
"xdg-open #{uri}"
when 'openbsd'
"xdg-open #{uri}"
when 'bitrig'
"xdg-open #{uri}"
when 'solaris'
if version < 11
"sdtwebclient #{uri}"
else
"xdg-open #{uri}"
end
else
""
end
end

def open_page(gem, options)
if options[:sourcecode]
find_page(gem, "source_code_uri")
Expand Down Expand Up @@ -108,14 +65,11 @@ def open_rubytoolbox(gem)
end

def open_default_browser(uri)
local_os = Gem::Platform.local.os
version = Gem::Platform.local.version
open_browser_cmd = open_default_browser_cmd(local_os, version, uri)

if !open_browser_cmd.empty?
system(open_browser_cmd)
open_browser_cmd = ENV['BROWSER']
if open_browser_cmd.nil?
puts uri
else
puts "The command 'web' is not supported on your platform."
system(open_browser_cmd, uri)
end
end

Expand Down
Loading

0 comments on commit c70106a

Please sign in to comment.