Class: VimPK::Commands::Install

Inherits:
Object
  • Object
show all
Includes:
VimPK::Colorizer
Defined in:
lib/vimpk/commands/install.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package, options) ⇒ Install

Returns a new instance of Install.



8
9
10
11
12
13
14
15
16
# File 'lib/vimpk/commands/install.rb', line 8

def initialize(package, options)
  @package = package || raise(ArgumentError, "Package name is required")
  @path = options.path
  @pack = options.pack || options.default_pack
  @type = options.type || options.default_type
  @dest = File.join(@path, @pack, @type, File.basename(@package))
  @source = "https://github.com/#{package}.git"
  @git = Git
end

Instance Attribute Details

#destObject (readonly)

Returns the value of attribute dest.



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

def dest
  @dest
end

Instance Method Details

#callObject

Raises:



18
19
20
21
22
# File 'lib/vimpk/commands/install.rb', line 18

def call
  raise PackageExistsError, "Package #{@package} already exists at #{@dest}" if File.exist?(@dest)

  Git.clone(@source, @dest, dir: @path)
end