class Litbuild::ServiceDir
Service definition directories are a bit complicated. This is just a helper class that knows how to deal with them.
Public Class Methods
new(svcdef)
click to toggle source
# File lib/litbuild/service_dir.rb, line 7 def initialize(svcdef) @svcdef = svcdef end
Public Instance Methods
bundle()
click to toggle source
# File lib/litbuild/service_dir.rb, line 15 def bundle @svcdef['bundle']&.first end
dependencies()
click to toggle source
# File lib/litbuild/service_dir.rb, line 35 def dependencies @svcdef['dependencies'] || [] end
env()
click to toggle source
# File lib/litbuild/service_dir.rb, line 49 def env return [] unless @svcdef.key?('env') flattened = {} @svcdef['env'].first.each do |variable, value| flattened[variable] = value.first end flattened end
multiline_files()
click to toggle source
# File lib/litbuild/service_dir.rb, line 39 def multiline_files file_contents = {} %w[up down run].each do |fn| next unless @svcdef.key?(fn) file_contents[fn] = @svcdef[fn] end file_contents end
name()
click to toggle source
# File lib/litbuild/service_dir.rb, line 11 def name @svcdef['name'].first end
oneline_files()
click to toggle source
# File lib/litbuild/service_dir.rb, line 27 def oneline_files file_contents = { 'type' => type } %w[down-signal notification-fd].each do |fn| file_contents[fn] = @svcdef[fn].first if @svcdef.key?(fn) end file_contents end
type()
click to toggle source
# File lib/litbuild/service_dir.rb, line 19 def type return @svcdef['type'].first if @svcdef.key?('type') return 'longrun' if @svcdef.key?('run') return 'oneshot' if @svcdef.key?('up') raise(InvalidDirective, "servicedir #{name} must specify type") end