Class: Gem::Commands::CurrentPathCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/rubygems/commands/current_path_command.rb

Overview

#

A component of current_gem. #

#

Copyright © 2009-2012 University of Cologne, #

Albertus-Magnus-Platz,                              #
50923 Cologne, Germany                              #
                                                    #

Copyright © 2013-2014 Jens Wille #

#

Authors: #

Jens Wille <jens.wille@gmail.com>                                       #
                                                                        #

current_gem is free software; you can redistribute it and/or modify it # under the terms of the GNU Affero General Public License as published by # the Free Software Foundation; either version 3 of the License, or (at your # option) any later version. #

#

current_gem is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License # for more details. #

#

You should have received a copy of the GNU Affero General Public License # along with current_gem. If not, see <www.gnu.org/licenses/>. #

#

++

Instance Method Summary collapse

Constructor Details

#initializeCurrentPathCommand

Returns a new instance of CurrentPathCommand.



33
34
35
36
37
38
39
40
# File 'lib/rubygems/commands/current_path_command.rb', line 33

def initialize
  super 'current_path', "Display the location of a gem's current symlink",
    resolve: false

  add_option('-r', '--resolve', 'Display value of symbolic link') { |value, options|
    options[:resolve] = true
  }
end

Instance Method Details

#argumentsObject



42
43
44
# File 'lib/rubygems/commands/current_path_command.rb', line 42

def arguments
  'GEMNAME       name of gem to display'
end

#executeObject



50
51
52
53
54
55
56
# File 'lib/rubygems/commands/current_path_command.rb', line 50

def execute
  path = CurrentGem.path_for(get_one_gem_name)
  return unless path && File.exist?(path)

  path = File.readlink(path) if options[:resolve]
  say path
end

#usageObject



46
47
48
# File 'lib/rubygems/commands/current_path_command.rb', line 46

def usage
  "#{program_name} GEMNAME"
end