Class: Niman::Library::CustomPackage

Inherits:
Object
  • Object
show all
Defined in:
lib/niman/library/custom_package.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.commandsObject (readonly)

Returns the value of attribute commands.



5
6
7
# File 'lib/niman/library/custom_package.rb', line 5

def commands
  @commands
end

.filesObject (readonly)

Returns the value of attribute files.



5
6
7
# File 'lib/niman/library/custom_package.rb', line 5

def files
  @files
end

.package_namesObject (readonly)

Returns the value of attribute package_names.



5
6
7
# File 'lib/niman/library/custom_package.rb', line 5

def package_names
  @package_names
end

Class Method Details

.descriptionObject



31
32
33
# File 'lib/niman/library/custom_package.rb', line 31

def description
  ''
end

.errorsObject



40
41
42
43
44
45
46
47
# File 'lib/niman/library/custom_package.rb', line 40

def errors
  return [] if self.valid?
  package_names.keys.map do |key|
    if package_names[key].empty?
      "No package name configured for OS #{key}"
    end
  end.flatten
end

.exec(sudo = :no_sudo, command) ⇒ Object



35
36
37
38
# File 'lib/niman/library/custom_package.rb', line 35

def exec(sudo=:no_sudo, command)
  @commands ||= []
  @commands << Niman::Library::Command.new(use_sudo: sudo, command: command)
end

.file(path) {|file| ... } ⇒ Object

Yields:



24
25
26
27
28
29
# File 'lib/niman/library/custom_package.rb', line 24

def file(path)
  @files ||= []
  file = Niman::Library::File.new(path: path)
  yield file if block_given?
  @files << file
end

.installable?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/niman/library/custom_package.rb', line 15

def installable?
  !package_names.nil? && !package_names.empty?
end

.package_name(os, name) ⇒ Object



19
20
21
22
# File 'lib/niman/library/custom_package.rb', line 19

def package_name(os, name)
  @package_names ||= {}
  @package_names[os.to_sym] = name
end

.valid?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
# File 'lib/niman/library/custom_package.rb', line 7

def valid?
  if installable?
    package_names.keys.all?{|k| !package_names[k].empty?}
  else
    true
  end
end