SpecFileParser update.
parent
4eefe465f4
commit
75e500adcf
|
@ -14,7 +14,7 @@ targets:
|
||||||
main: src/status.cr
|
main: src/status.cr
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
spec:
|
specfileparser:
|
||||||
git: https://git.karchnu.fr/JunkOS/recipes-parser
|
git: https://git.karchnu.fr/WeirdOS/recipes-parser
|
||||||
|
|
||||||
license: MIT
|
license: MIT
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require "spec"
|
require "specfileparser"
|
||||||
|
|
||||||
class Environment
|
class Environment
|
||||||
enum Type
|
enum Type
|
||||||
|
@ -21,7 +21,7 @@ class Environment
|
||||||
directory: "/srv/${ENVIRONMENT}"
|
directory: "/srv/${ENVIRONMENT}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(specs : Specs)
|
def initialize(specs : SpecFileParser)
|
||||||
assignments = specs.assignments
|
assignments = specs.assignments
|
||||||
|
|
||||||
@name = assignments["name"].as_s
|
@name = assignments["name"].as_s
|
||||||
|
@ -46,7 +46,7 @@ class Environment
|
||||||
file_path = "#{path}/#{child}"
|
file_path = "#{path}/#{child}"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
environment = Environment.new Specs.parse(file_path).not_nil!
|
environment = Environment.new SpecFileParser.parse(file_path).not_nil!
|
||||||
rescue e
|
rescue e
|
||||||
STDERR << "error loading #{file_path}: " << e << "\n"
|
STDERR << "error loading #{file_path}: " << e << "\n"
|
||||||
# FIXME: Print stacktrace? Debug mode?
|
# FIXME: Print stacktrace? Debug mode?
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Service
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(specs : Specs)
|
def initialize(specs : SpecFileParser)
|
||||||
assignments = specs.assignments
|
assignments = specs.assignments
|
||||||
|
|
||||||
@reference = ServiceDefinition.get assignments["name"].as_s
|
@reference = ServiceDefinition.get assignments["name"].as_s
|
||||||
|
@ -302,7 +302,7 @@ class Service
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
specs = Specs.parse("#{path}/#{child}").not_nil!
|
specs = SpecFileParser.parse("#{path}/#{child}").not_nil!
|
||||||
rescue
|
rescue
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
require "yaml"
|
require "yaml"
|
||||||
require "spec"
|
require "specfileparser"
|
||||||
|
|
||||||
class ServiceDefinition
|
class ServiceDefinition
|
||||||
struct Consumes
|
struct Consumes
|
||||||
|
@ -26,7 +26,7 @@ class ServiceDefinition
|
||||||
|
|
||||||
def initialize(@name, @command, @file = nil, @directory = nil)
|
def initialize(@name, @command, @file = nil, @directory = nil)
|
||||||
end
|
end
|
||||||
def initialize(section : Specs::Section)
|
def initialize(section : SpecFileParser::Section)
|
||||||
@name = section.content["name"].as_s
|
@name = section.content["name"].as_s
|
||||||
@file = section.content["file"]?.try &.as_s
|
@file = section.content["file"]?.try &.as_s
|
||||||
@directory = section.content["directory"]?.try &.as_s
|
@directory = section.content["directory"]?.try &.as_s
|
||||||
|
@ -47,7 +47,7 @@ class ServiceDefinition
|
||||||
getter checks : Array(Checks)
|
getter checks : Array(Checks)
|
||||||
getter provides : Array(Provides)
|
getter provides : Array(Provides)
|
||||||
|
|
||||||
def initialize(specs : Specs)
|
def initialize(specs : SpecFileParser)
|
||||||
sections = specs.sections
|
sections = specs.sections
|
||||||
specs = specs.assignments
|
specs = specs.assignments
|
||||||
@name = specs["name"].as_s
|
@name = specs["name"].as_s
|
||||||
|
@ -64,7 +64,7 @@ class ServiceDefinition
|
||||||
def self.load(path)
|
def self.load(path)
|
||||||
Dir.each_child path do |child|
|
Dir.each_child path do |child|
|
||||||
if child.match /\.spec$/
|
if child.match /\.spec$/
|
||||||
@@all << ServiceDefinition.new Specs.parse("#{path}/#{child}").not_nil!
|
@@all << ServiceDefinition.new SpecFileParser.parse("#{path}/#{child}").not_nil!
|
||||||
else
|
else
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue