SpecFileParser update.

master
Luka Vandervelden 2019-08-15 17:29:52 +02:00
parent 4eefe465f4
commit 75e500adcf
4 changed files with 11 additions and 11 deletions

View File

@ -14,7 +14,7 @@ targets:
main: src/status.cr
dependencies:
spec:
git: https://git.karchnu.fr/JunkOS/recipes-parser
specfileparser:
git: https://git.karchnu.fr/WeirdOS/recipes-parser
license: MIT

View File

@ -1,4 +1,4 @@
require "spec"
require "specfileparser"
class Environment
enum Type
@ -21,7 +21,7 @@ class Environment
directory: "/srv/${ENVIRONMENT}"
end
def initialize(specs : Specs)
def initialize(specs : SpecFileParser)
assignments = specs.assignments
@name = assignments["name"].as_s
@ -46,7 +46,7 @@ class Environment
file_path = "#{path}/#{child}"
begin
environment = Environment.new Specs.parse(file_path).not_nil!
environment = Environment.new SpecFileParser.parse(file_path).not_nil!
rescue e
STDERR << "error loading #{file_path}: " << e << "\n"
# FIXME: Print stacktrace? Debug mode?

View File

@ -43,7 +43,7 @@ class Service
end
end
def initialize(specs : Specs)
def initialize(specs : SpecFileParser)
assignments = specs.assignments
@reference = ServiceDefinition.get assignments["name"].as_s
@ -302,7 +302,7 @@ class Service
end
begin
specs = Specs.parse("#{path}/#{child}").not_nil!
specs = SpecFileParser.parse("#{path}/#{child}").not_nil!
rescue
next
end

View File

@ -1,5 +1,5 @@
require "yaml"
require "spec"
require "specfileparser"
class ServiceDefinition
struct Consumes
@ -26,7 +26,7 @@ class ServiceDefinition
def initialize(@name, @command, @file = nil, @directory = nil)
end
def initialize(section : Specs::Section)
def initialize(section : SpecFileParser::Section)
@name = section.content["name"].as_s
@file = section.content["file"]?.try &.as_s
@directory = section.content["directory"]?.try &.as_s
@ -47,7 +47,7 @@ class ServiceDefinition
getter checks : Array(Checks)
getter provides : Array(Provides)
def initialize(specs : Specs)
def initialize(specs : SpecFileParser)
sections = specs.sections
specs = specs.assignments
@name = specs["name"].as_s
@ -64,7 +64,7 @@ class ServiceDefinition
def self.load(path)
Dir.each_child path do |child|
if child.match /\.spec$/
@@all << ServiceDefinition.new Specs.parse("#{path}/#{child}").not_nil!
@@all << ServiceDefinition.new SpecFileParser.parse("#{path}/#{child}").not_nil!
else
next
end