Class: Litbuild::ServiceDir
- Inherits:
-
Object
- Object
- Litbuild::ServiceDir
- Defined in:
- lib/litbuild/service_dir.rb
Overview
Service definition directories are a bit complicated. This is just a helper class that knows how to deal with them.
Instance Method Summary collapse
- #bundle ⇒ Object
- #dependencies ⇒ Object
- #env ⇒ Object
-
#initialize(svcdef) ⇒ ServiceDir
constructor
A new instance of ServiceDir.
- #multiline_files ⇒ Object
- #name ⇒ Object
- #oneline_files ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(svcdef) ⇒ ServiceDir
Returns a new instance of ServiceDir.
7 8 9 |
# File 'lib/litbuild/service_dir.rb', line 7 def initialize(svcdef) @svcdef = svcdef end |
Instance Method Details
#bundle ⇒ Object
15 16 17 |
# File 'lib/litbuild/service_dir.rb', line 15 def bundle @svcdef['bundle']&.first end |
#dependencies ⇒ Object
35 36 37 |
# File 'lib/litbuild/service_dir.rb', line 35 def dependencies @svcdef['dependencies'] || [] end |
#env ⇒ Object
49 50 51 52 53 54 55 56 57 |
# 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 ⇒ Object
39 40 41 42 43 44 45 46 47 |
# 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 ⇒ Object
11 12 13 |
# File 'lib/litbuild/service_dir.rb', line 11 def name @svcdef['name'].first end |
#oneline_files ⇒ Object
27 28 29 30 31 32 33 |
# 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 ⇒ Object
19 20 21 22 23 24 25 |
# 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 |