2019-07-31 19:38:40 +02:00
|
|
|
require "option_parser"
|
|
|
|
require "./src/spec"
|
|
|
|
|
|
|
|
recipe_file_name = "some-non-existant-file"
|
|
|
|
|
|
|
|
OptionParser.parse! do |parser|
|
|
|
|
parser.on "-f file", "--file file", "File to parse." do |f|
|
|
|
|
recipe_file_name = f
|
|
|
|
end
|
|
|
|
|
|
|
|
parser.on "-h", "--help", "Show this help" do
|
|
|
|
puts parser
|
|
|
|
exit 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2019-08-02 17:59:33 +02:00
|
|
|
options = Hash(String,String).new
|
|
|
|
options["someoptionexample"] = "option"
|
|
|
|
|
|
|
|
specs = Specs.parse recipe_file_name, options
|
2019-07-31 19:38:40 +02:00
|
|
|
pp! specs
|
2019-08-08 01:02:02 +02:00
|
|
|
|
2019-08-08 10:32:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-08 01:02:02 +02:00
|
|
|
# low level stuff
|
|
|
|
|
2019-08-08 10:32:09 +02:00
|
|
|
sectioncontainer = Specs::Section.new "val"
|
2019-08-08 01:02:02 +02:00
|
|
|
begin
|
|
|
|
puts sectioncontainer.as_s
|
2019-08-08 10:32:09 +02:00
|
|
|
puts "(NOT OK) Specs::Section should not accept .as_s"
|
2019-08-08 01:02:02 +02:00
|
|
|
rescue e
|
|
|
|
puts "(OK) #{e}"
|
|
|
|
end
|
|
|
|
begin
|
|
|
|
pp! sectioncontainer.as_a_or_s
|
2019-08-08 10:32:09 +02:00
|
|
|
puts "(NOT OK) Specs::Section should not accept .as_a_or_s"
|
2019-08-08 01:02:02 +02:00
|
|
|
rescue e
|
|
|
|
puts "(OK) #{e}"
|
|
|
|
end
|
|
|
|
|
|
|
|
arraycontainer = Specs::ArrayContainer.new Array(String).new.push "value"
|
|
|
|
begin
|
|
|
|
puts arraycontainer.as_s
|
|
|
|
puts "(NOT OK) Specs::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"
|
|
|
|
rescue e
|
|
|
|
puts "(NOT OK) #{e}"
|
|
|
|
end
|