Class: GemSearch::Commands::Browse

Inherits:
Base
  • Object
show all
Includes:
Utils::SystemUtil
Defined in:
lib/gem_search/commands/browse.rb

Constant Summary collapse

GEM_URL =
"#{RUBYGEMS_URL}/gems/%s"

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods included from Utils::SystemUtil

#browser_open, #osx?, #which

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from GemSearch::Commands::Base

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gem_search/commands/browse.rb', line 10

def call
  gem_name = options[:browse]
  result = Request.new.search_for_browse(gem_name)
  url = extract_uri(result["homepage_uri"], gem_name)
  puts "Opening #{url}"
  browser_open(url)
rescue OpenURI::HTTPError
  puts_abort("No such a gem.")
rescue => e
  unexpected_error(e)
end