Class: Gem::Commands::BanCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::BanCommand
- Defined in:
- lib/rubygems/commands/ban_command.rb
Instance Method Summary collapse
- #add ⇒ Object
-
#arguments ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ BanCommand
constructor
A new instance of BanCommand.
- #list ⇒ Object
- #remove ⇒ Object
-
#usage ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ BanCommand
Returns a new instance of BanCommand.
4 5 6 |
# File 'lib/rubygems/commands/ban_command.rb', line 4 def initialize super 'ban', 'Specific gem installation prevention utility' end |
Instance Method Details
#add ⇒ Object
43 44 45 46 47 48 |
# File 'lib/rubygems/commands/ban_command.rb', line 43 def add until (gem = [:args].shift).nil? raise Gem::CommandLineError, "Please specify a gem name to ban on the command line" unless gem Gem::Ban::ban(gem) end end |
#arguments ⇒ Object
:nodoc:
8 9 10 11 |
# File 'lib/rubygems/commands/ban_command.rb', line 8 def arguments # :nodoc: ['SUBCOMMAND list, add or remove', 'GEMNAME(s) name of a gem to ban or unban'].join "\n" end |
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rubygems/commands/ban_command.rb', line 17 def execute cmd = [:args].shift if %w|list add remove|.include? cmd return eval("#{cmd}") end if %w|help h usage --usage --help -h -?|.include? cmd show_help abort end alert_error "Unknown ban subcommand: #{cmd}" show_help abort end |
#list ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/rubygems/commands/ban_command.rb', line 35 def list unless (_banned = Gem::Ban::banned.join(' ')).empty? puts "Banned gems: #{_banned}" else puts 'Banned gems: (none)' end end |
#remove ⇒ Object
50 51 52 53 54 55 |
# File 'lib/rubygems/commands/ban_command.rb', line 50 def remove until (gem = [:args].shift).nil? raise Gem::CommandLineError, "Please specify a gem name to unban on the command line" unless gem Gem::Ban::unban(gem) end end |
#usage ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/rubygems/commands/ban_command.rb', line 13 def usage # :nodoc: "#{program_name} SUBCOMMAND GEMNAME(S)" end |