forked from adamsanderson/open_gem
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added "homepage" command.
* The homepage command opens a given gem's homepage in the browser. Conflicts: lib/rubygems_plugin.rb
- Loading branch information
1 parent
1be9808
commit a639b53
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'launchy' | ||
# HomepageCommand will open the homepage of a gem in your browser. | ||
class Gem::Commands::HomepageCommand < Gem::Command | ||
include OpenGem::CommonOptions | ||
include Gem::VersionOption | ||
|
||
def initialize | ||
super 'homepage', "Opens the gem's homepage.", | ||
:command => nil, | ||
:version=> Gem::Requirement.default, | ||
:latest=> false | ||
|
||
add_command_option "Application to view homepage with" | ||
add_latest_version_option | ||
add_version_option | ||
add_exact_match_option | ||
end | ||
|
||
def arguments # :nodoc: | ||
"GEMNAME gem whose homepage you want to open" | ||
end | ||
|
||
def execute | ||
name = get_one_gem_name | ||
spec = get_spec(name) | ||
Launchy::Browser.run(spec.homepage) | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters