Class: Gem::Commands::SignoutCommand

Inherits:
Gem::Command show all
Defined in:
lib/rubygems/commands/signout_command.rb

Instance Attribute Summary

Attributes inherited from Gem::Command

#command, #defaults, #options, #program_name, #summary

Instance Method Summary collapse

Methods inherited from Gem::Command

add_common_option, #add_extra_args, #add_option, add_specific_extra_args, #arguments, #begins?, build_args, build_args=, #check_deprecated_options, common_options, #defaults_str, #deprecate_option, extra_args, extra_args=, #get_all_gem_names, #get_all_gem_names_and_versions, #get_one_gem_name, #get_one_optional_argument, #handle_options, #handles?, #invoke, #invoke_with_build_args, #merge_options, #remove_option, #show_help, #show_lookup_failure, specific_extra_args, specific_extra_args_hash, #when_invoked

Methods included from UserInteraction

#alert, #alert_error, #alert_warning, #ask, #ask_for_password, #ask_yes_no, #choose_from_list, #say, #terminate_interaction, #verbose

Methods included from DefaultUserInteraction

ui, #ui, ui=, #ui=, use_ui, #use_ui

Methods included from Text

#clean_text, #format_text, #levenshtein_distance, #min3, #truncate_text

Constructor Details

#initializeSignoutCommand

Returns a new instance of SignoutCommand.



6
7
8
# File 'lib/rubygems/commands/signout_command.rb', line 6

def initialize
  super 'signout', 'Sign out from all the current sessions.'
end

Instance Method Details

#descriptionObject

:nodoc:



10
11
12
13
# File 'lib/rubygems/commands/signout_command.rb', line 10

def description # :nodoc:
  'The `signout` command is used to sign out from all current sessions,'\
  ' allowing you to sign in using a different set of credentials.'
end

#executeObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rubygems/commands/signout_command.rb', line 19

def execute
  credentials_path = Gem.configuration.credentials_path

  if !File.exist?(credentials_path)
    alert_error 'You are not currently signed in.'
  elsif !File.writable?(credentials_path)
    alert_error "File '#{Gem.configuration.credentials_path}' is read-only."\
                ' Please make sure it is writable.'
  else
    Gem.configuration.unset_api_key!
    say 'You have successfully signed out from all sessions.'
  end
end

#usageObject

:nodoc:



15
16
17
# File 'lib/rubygems/commands/signout_command.rb', line 15

def usage # :nodoc:
  program_name
end