Class: VimPK::Commands::Remove

Inherits:
Object
  • Object
show all
Defined in:
lib/vimpk/commands/remove.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ Remove

Returns a new instance of Remove.



6
7
8
9
# File 'lib/vimpk/commands/remove.rb', line 6

def initialize(name, options)
  @name = name || raise(ArgumentError, "Package name is required")
  @path = options.path
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vimpk/commands/remove.rb', line 11

def call
  glob = Dir.glob(File.join(@path, "*", "{start,opt}", @name))

  if glob.empty?
    raise PackageNotFoundError, "Package #{@name} not found in #{@path}."
  else
    glob.each do |dir|
      FileUtils.rm_rf(dir)
    end
  end
end