Class: LaPack::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/providers/provider.rb

Overview

Base package provider. I.e. database wrapper.

Should know how to:

  • fetch packages index and manage

  • show package info

  • download, make & install packages

  • remove packages

  • keeps multiple versions

Direct Known Subclasses

CtanProvider, GithubProvider

Instance Method Summary collapse

Constructor Details

#initialize(env, name, params) ⇒ Provider

Initialization with LaENV instance



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/providers/provider.rb', line 17

def initialize(env, name, params)
  @name = name

  # Check if db dir exists
  @dbdir = File.join(env.dbs_store, name)
  if File.exists?(@dbdir)
    raise "Can't write to #{@dbdir}. Not a directory" unless File.directory?(@dbdir)
  else
    FileUtils.mkdir_p(@dbdir)
  end
  configure(params)
  init(@dbdir)
end

Instance Method Details

#configure(params = {}) ⇒ Object

Configuration

Accepts any parameters (params) for configuration as Hash



35
36
37
# File 'lib/providers/provider.rb', line 35

def configure(params = {})
  true
end

#init(dbdir) ⇒ Object

Initialization

Uses dbdir argument for filesystem initialization No index update required there.



45
46
47
# File 'lib/providers/provider.rb', line 45

def init(dbdir)

end

#install(*packages) ⇒ Object



61
62
63
# File 'lib/providers/provider.rb', line 61

def install(*packages)
  puts "Dummy implementation. Should install: #{packages.join(",")}"
end

#listObject

Shows available packages



57
58
59
# File 'lib/providers/provider.rb', line 57

def list
  return []
end

#remove(package) ⇒ Object



69
70
71
# File 'lib/providers/provider.rb', line 69

def remove(package)
  # do nothing
end

#show(package) ⇒ Object



65
66
67
# File 'lib/providers/provider.rb', line 65

def show(package)
  []
end

#updateObject

Updates package index



51
52
53
# File 'lib/providers/provider.rb', line 51

def update
  true
end