Archived
3
0

Library renaming: Specs => SpecFileParser.

This commit is contained in:
Philippe PITTOLI 2019-08-13 18:11:20 +02:00
parent ad4ac62352
commit be84c7d18b
3 changed files with 13 additions and 13 deletions

View File

@ -1,5 +1,5 @@
name: package
version: 0.1.0
version: 0.1.1
# authors:
# - name <email@example.com>
@ -8,7 +8,7 @@ version: 0.1.0
# Short description of package
dependencies:
spec:
specfileparser:
git: https://git.karchnu.fr/WeirdOS/recipes-parser
# dependencies:

View File

@ -3,7 +3,7 @@ require "uuid"
require "uri"
require "file_utils"
require "spec"
require "specfileparser"
require "./context.cr"
require "./package.cr"
@ -31,7 +31,7 @@ module FileUtils
end
# FIXME: This could probably be shorter and less stupid with a macro or two.
class Specs::StringContainer
class SpecFileParser::StringContainer
def as_s : String
value
end
@ -44,7 +44,7 @@ class Specs::StringContainer
end
end
class Specs::LongStringContainer
class SpecFileParser::LongStringContainer
def as_s : String
raise "short string expected, got multiline text section"
end
@ -56,7 +56,7 @@ class Specs::LongStringContainer
end
end
class Specs::ArrayContainer
class SpecFileParser::ArrayContainer
def as_s : String
raise "string expected, got list"
end
@ -68,7 +68,7 @@ class Specs::ArrayContainer
end
end
class Specs::SectionContainer
class SpecFileParser::SectionContainer
def as_s : String
raise "string expected, got section"
end
@ -128,7 +128,7 @@ class Package::Recipe
end
def initialize(@context, filename : String)
specs = Specs.parse filename, {
specs = SpecFileParser.parse filename, {
"pkg" => fake_root_directory
}

10
test.cr
View File

@ -11,7 +11,7 @@ context.packaging_backend = "apk"
recipes = [] of Package::Recipe
class Specs
class SpecFileParser
def get_string?(id) : String?
entry = self.assignments[id]?
@ -49,9 +49,9 @@ class Specs
entry = assignments[id]?
case entry
when Specs::ArrayContainer
when SpecFileParser::ArrayContainer
entry.value
when Specs::StringContainer
when SpecFileParser::StringContainer
entry.value.split(",")
when Nil
return nil
@ -62,7 +62,7 @@ class Specs
end
class Package::Recipe
def initialize(@context, specs : Specs)
def initialize(@context, specs : SpecFileParser)
pp! specs
@name = specs.get_string "name"
@ -120,7 +120,7 @@ end
class Package::Context
def read_recipe(filename : String)
specs = Specs.parse filename
specs = SpecFileParser.parse filename
if specs.nil?
raise Exception.new "file could not be parsed"