renaming: Specs => SpecFileParser
This commit is contained in:
parent
79ef66292b
commit
2694ecdae1
16
debug.cr
16
debug.cr
@ -1,5 +1,5 @@
|
||||
require "option_parser"
|
||||
require "./src/spec"
|
||||
require "./src/specfileparser"
|
||||
|
||||
recipe_file_name = "some-non-existant-file"
|
||||
|
||||
@ -18,7 +18,7 @@ end
|
||||
options = Hash(String,String).new
|
||||
options["someoptionexample"] = "option"
|
||||
|
||||
specs = Specs.parse recipe_file_name, options
|
||||
specs = SpecFileParser.parse recipe_file_name, options
|
||||
pp! specs
|
||||
|
||||
|
||||
@ -27,30 +27,30 @@ pp! specs
|
||||
|
||||
# low level stuff
|
||||
|
||||
sectioncontainer = Specs::Section.new "val"
|
||||
sectioncontainer = SpecFileParser::Section.new "val"
|
||||
begin
|
||||
puts sectioncontainer.as_s
|
||||
puts "(NOT OK) Specs::Section should not accept .as_s"
|
||||
puts "(NOT OK) SpecFileParser::Section should not accept .as_s"
|
||||
rescue e
|
||||
puts "(OK) #{e}"
|
||||
end
|
||||
begin
|
||||
pp! sectioncontainer.as_a_or_s
|
||||
puts "(NOT OK) Specs::Section should not accept .as_a_or_s"
|
||||
puts "(NOT OK) SpecFileParser::Section should not accept .as_a_or_s"
|
||||
rescue e
|
||||
puts "(OK) #{e}"
|
||||
end
|
||||
|
||||
arraycontainer = Specs::ArrayContainer.new Array(String).new.push "value"
|
||||
arraycontainer = SpecFileParser::ArrayContainer.new Array(String).new.push "value"
|
||||
begin
|
||||
puts arraycontainer.as_s
|
||||
puts "(NOT OK) Specs::ArrayContainer should not accept .as_s"
|
||||
puts "(NOT OK) SpecFileParser::ArrayContainer should not accept .as_s"
|
||||
rescue e
|
||||
puts "(OK) #{e}"
|
||||
end
|
||||
begin
|
||||
pp! arraycontainer.as_a_or_s
|
||||
puts "(OK) Specs::ArrayContainer should accept .as_a_or_s"
|
||||
puts "(OK) SpecFileParser::ArrayContainer should accept .as_a_or_s"
|
||||
rescue e
|
||||
puts "(NOT OK) #{e}"
|
||||
end
|
||||
|
@ -1,11 +1,11 @@
|
||||
name: spec
|
||||
version: 0.4.1
|
||||
name: specfileparser
|
||||
version: 0.4.2
|
||||
|
||||
authors:
|
||||
- Philippe Pittoli <karchnu@karchnu.fr>
|
||||
|
||||
description: |
|
||||
`Spec` is a parsing library for the `Spec` format.
|
||||
`SpecFileParser` is a parsing library for the `Spec` format.
|
||||
|
||||
|
||||
license: ISC
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
class Specs
|
||||
class SpecFileParser
|
||||
|
||||
macro incompatible_methods(*names)
|
||||
{% for name in names %}
|
||||
@ -40,7 +40,7 @@ class Specs
|
||||
end
|
||||
|
||||
class LongStringContainer
|
||||
Specs.incompatible_methods as_s, as_a_or_s
|
||||
SpecFileParser.incompatible_methods as_s, as_a_or_s
|
||||
property value : String
|
||||
|
||||
def as_s_or_ls : String
|
||||
@ -52,7 +52,7 @@ class Specs
|
||||
end
|
||||
|
||||
class ArrayContainer
|
||||
Specs.incompatible_methods as_s, as_s_or_ls
|
||||
SpecFileParser.incompatible_methods as_s, as_s_or_ls
|
||||
property value : Array(String)
|
||||
|
||||
def as_a_or_s : Array(String)
|
||||
@ -64,7 +64,7 @@ class Specs
|
||||
end
|
||||
|
||||
class Section
|
||||
Specs.incompatible_methods as_s, as_a_or_s, as_s_or_ls
|
||||
SpecFileParser.incompatible_methods as_s, as_a_or_s, as_s_or_ls
|
||||
property name : String
|
||||
property options : Array(String)
|
||||
property content : Hash(String, StringContainer | ArrayContainer | LongStringContainer)
|
||||
@ -367,12 +367,12 @@ class Specs
|
||||
|
||||
# The only function to use from outside.
|
||||
|
||||
def self.parse(file_name : String, options : Hash(String, String) | Nil = nil) : Specs | Nil
|
||||
def self.parse(file_name : String, options : Hash(String, String) | Nil = nil) : SpecFileParser | Nil
|
||||
begin
|
||||
content = File.read(file_name)
|
||||
content = content.rchop
|
||||
|
||||
specs = Specs.new
|
||||
specs = SpecFileParser.new
|
||||
unless options.nil?
|
||||
options.each do |opt, val|
|
||||
specs.assignments[opt] = StringContainer.new val
|
Reference in New Issue
Block a user