Class: Niman::Library::CustomPackage
- Inherits:
-
Object
- Object
- Niman::Library::CustomPackage
- Defined in:
- lib/niman/library/custom_package.rb
Class Attribute Summary collapse
-
.commands ⇒ Object
readonly
Returns the value of attribute commands.
-
.files ⇒ Object
readonly
Returns the value of attribute files.
-
.package_names ⇒ Object
readonly
Returns the value of attribute package_names.
Class Method Summary collapse
- .description ⇒ Object
- .errors ⇒ Object
- .exec(sudo = :no_sudo, command) ⇒ Object
- .file(path) {|file| ... } ⇒ Object
- .installable? ⇒ Boolean
- .package_name(os, name) ⇒ Object
- .valid? ⇒ Boolean
Class Attribute Details
.commands ⇒ Object (readonly)
Returns the value of attribute commands.
5 6 7 |
# File 'lib/niman/library/custom_package.rb', line 5 def commands @commands end |
.files ⇒ Object (readonly)
Returns the value of attribute files.
5 6 7 |
# File 'lib/niman/library/custom_package.rb', line 5 def files @files end |
.package_names ⇒ Object (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
.description ⇒ Object
31 32 33 |
# File 'lib/niman/library/custom_package.rb', line 31 def description '' end |
.errors ⇒ Object
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
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
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
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 |