ServiceDefinition#name based on filename and not specs.

master
Luka Vandervelden 2019-10-25 12:24:25 +02:00
parent bdeb23c275
commit a3c32905ee
1 changed files with 5 additions and 3 deletions

View File

@ -47,10 +47,9 @@ class ServiceDefinition
getter checks : Array(Checks)
getter provides : Array(Provides)
def initialize(specs : SpecParser)
def initialize(@name, specs : SpecParser)
sections = specs.sections
specs = specs.assignments
@name = specs["name"].as_s
@command = specs["command"].as_s
@stop_command = specs["stop-command"]?.try &.as_s
@directory = specs["directory"]?.try &.as_s
@ -64,7 +63,10 @@ class ServiceDefinition
def self.load(path)
Dir.each_child path do |child|
if child.match /\.spec$/
@@all << ServiceDefinition.new SpecParser.parse(File.read "#{path}/#{child}").not_nil!
name = File.basename(child, ".spec")
specs = SpecParser.parse File.read "#{path}/#{child}"
@@all << ServiceDefinition.new name, specs
else
next
end