Class: Uberinstaller::Installer

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/uberinstaller/installer.rb

Instance Method Summary collapse

Methods included from Loggable

configure_logger_for, #logger, logger_for

Constructor Details

#initialize(pkg_name, pkg_body) ⇒ Installer

Initialize the class

Parameters:

  • pkg_name (String)

    the name of the package

  • pkg_body (Hash)

    an Hash containing the parsed information for the package



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

def initialize(pkg_name, pkg_body)
  @name = pkg_name
  @body = pkg_body
  
  # an Hash containing private processing info for the class
  @meta = Hash.new
  @meta[:installable] = true

  if @body.has_key? :skip and @body[:skip]
    logger.warn "#{@name} has :skip option active, skipping "
  end
end

Instance Method Details

#install(type) ⇒ Object

Perform package installation based upon installation type, only if installable? is true

Parameters:

  • type (String)

    the installation type



53
54
55
56
57
58
59
60
61
# File 'lib/uberinstaller/installer.rb', line 53

def install(type)
  return unless installable?

  case type
  when 'git' then install_git
  when 'local' then install_local
  when 'system' then install_system
  end
end

#installable?bool

Return if the package is installable

Returns:

  • (bool)

    true if the package can be installed, false otherwise



34
35
36
# File 'lib/uberinstaller/installer.rb', line 34

def installable?
  @body[:skip] ? false : true
end

#preprocess(type) ⇒ Object

Perform package preprocessing based upon installation type, only if installable? is true

Parameters:

  • type (String)

    the installation type



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/uberinstaller/installer.rb', line 66

def preprocess(type)
  return unless installable?

  case type
  when 'git' then preprocess_git
  when 'local' then preprocess_local
  when 'system' then preprocess_system
  when 'json' then preprocess_json
  else raise Exception::NoPreprocessorException, type
  end
end

#validate(type) ⇒ Object

Perform package validation based upon installation type

Parameters:

  • type (String)

    the installation type



41
42
43
44
45
46
47
48
# File 'lib/uberinstaller/installer.rb', line 41

def validate(type)
  case type
  when 'system' then validate_system
  when 'git' then validate_git
  when 'local' then validate_local
  when 'json' then validate_json
  end
end