Environment#name is obtained from filename and not specs.

master
Luka Vandervelden 2019-10-25 12:34:21 +02:00
parent 479dffc6a0
commit 0fa6ec01c9
1 changed files with 5 additions and 3 deletions

View File

@ -26,10 +26,9 @@ class Environment
directory: "/srv/${ENVIRONMENT}" directory: "/srv/${ENVIRONMENT}"
end end
def initialize(specs : SpecParser) def initialize(@name, specs : SpecParser)
assignments = specs.assignments assignments = specs.assignments
@name = assignments["name"].as_s
assignments["type"].try &.as_s.tap do |type| assignments["type"].try &.as_s.tap do |type|
@type = Type.parse type @type = Type.parse type
end end
@ -53,7 +52,10 @@ class Environment
file_path = "#{path}/#{child}" file_path = "#{path}/#{child}"
begin begin
environment = Environment.new SpecParser.parse(File.read file_path).not_nil! name = File.basename(child, ".spec")
specs = SpecParser.parse File.read(file_path)
environment = Environment.new name, specs
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?