Module: Bootlace::Package

Includes:
Logger, OS
Included in:
Base
Defined in:
lib/bootlace/package.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

#logger

Methods included from OS

#os

Instance Attribute Details

#noopObject (readonly)

Returns the value of attribute noop.



9
10
11
# File 'lib/bootlace/package.rb', line 9

def noop
  @noop
end

Instance Method Details

#install_package_from_hash(hash) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bootlace/package.rb', line 37

def install_package_from_hash(hash)
  unless package_installed? hash[os]
    if noop
      logger.info("Would have installed package '#{hash[os]}' via #{package_manager}")
    else
      logger.info("Installing package '#{hash[os]}' via #{package_manager}")
      install_package hash[os]
    end
  else
    logger.info("Package '#{hash[os]}' already installed; skipping")
  end
end

#install_package_from_string(s) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bootlace/package.rb', line 24

def install_package_from_string(s)
  unless package_installed? s
    if noop
      logger.info("Would have installed package '#{s}' via #{package_manager}")
    else
      logger.info("Installing package '#{s}' via #{package_manager}")
      install_package s
    end
  else
    logger.info("Package '#{s}' already installed; skipping")
  end
end

#noop!Object



11
12
13
# File 'lib/bootlace/package.rb', line 11

def noop!
  @noop = true
end

#package(arg) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/bootlace/package.rb', line 15

def package(arg)
  case arg.class.name
  when "String"
    install_package_from_string arg
  when "Hash"
    install_package_from_hash arg
  end
end