test program new SpecParser API
This commit is contained in:
parent
afaf5c2fda
commit
e0d3c6bf7e
12
test.cr
12
test.cr
@ -11,7 +11,7 @@ context.packaging_backend = "apk"
|
|||||||
|
|
||||||
recipes = [] of Package::Recipe
|
recipes = [] of Package::Recipe
|
||||||
|
|
||||||
class SpecFileParser
|
class SpecParser
|
||||||
def get_string?(id) : String?
|
def get_string?(id) : String?
|
||||||
entry = self.assignments[id]?
|
entry = self.assignments[id]?
|
||||||
|
|
||||||
@ -49,9 +49,9 @@ class SpecFileParser
|
|||||||
entry = assignments[id]?
|
entry = assignments[id]?
|
||||||
|
|
||||||
case entry
|
case entry
|
||||||
when SpecFileParser::ArrayContainer
|
when SpecParser::ArrayContainer
|
||||||
entry.value
|
entry.value
|
||||||
when SpecFileParser::StringContainer
|
when SpecParser::StringContainer
|
||||||
entry.value.split(",")
|
entry.value.split(",")
|
||||||
when Nil
|
when Nil
|
||||||
return nil
|
return nil
|
||||||
@ -62,7 +62,7 @@ class SpecFileParser
|
|||||||
end
|
end
|
||||||
|
|
||||||
class Package::Recipe
|
class Package::Recipe
|
||||||
def initialize(@context, specs : SpecFileParser)
|
def initialize(@context, specs : SpecParser)
|
||||||
pp! specs
|
pp! specs
|
||||||
|
|
||||||
@name = specs.get_string "name"
|
@name = specs.get_string "name"
|
||||||
@ -120,10 +120,10 @@ end
|
|||||||
|
|
||||||
class Package::Context
|
class Package::Context
|
||||||
def read_recipe(filename : String)
|
def read_recipe(filename : String)
|
||||||
specs = SpecFileParser.parse filename
|
specs = SpecParser.parse filename
|
||||||
|
|
||||||
if specs.nil?
|
if specs.nil?
|
||||||
raise Exception.new "file could not be parsed"
|
raise ::Exception.new "file could not be parsed"
|
||||||
end
|
end
|
||||||
|
|
||||||
Recipe.new self, specs
|
Recipe.new self, specs
|
||||||
|
Reference in New Issue
Block a user