You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.3 KiB
71 lines
1.3 KiB
require "option_parser"
|
|
require "./src/specparser"
|
|
|
|
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
|
|
|
|
|
|
options = Hash(String,String).new
|
|
options["someoptionexample"] = "option"
|
|
|
|
begin
|
|
specs = SpecParser.parse_file recipe_file_name, options
|
|
pp! specs
|
|
rescue e
|
|
puts "(OK) #{e}"
|
|
end
|
|
|
|
data = "
|
|
name: the-name
|
|
version: the-version
|
|
dirname: %{name}-%{version}
|
|
"
|
|
|
|
begin
|
|
specs = SpecParser.parse data, options
|
|
pp! specs
|
|
rescue e
|
|
puts "(NOT OK) #{e}"
|
|
end
|
|
|
|
|
|
# low level stuff
|
|
|
|
sectioncontainer = SpecParser::Section.new "val"
|
|
begin
|
|
puts sectioncontainer.as_s
|
|
puts "(NOT OK) SpecParser::Section should not accept .as_s"
|
|
rescue e
|
|
puts "(OK) #{e}"
|
|
end
|
|
begin
|
|
pp! sectioncontainer.as_a_or_s
|
|
puts "(NOT OK) SpecParser::Section should not accept .as_a_or_s"
|
|
rescue e
|
|
puts "(OK) #{e}"
|
|
end
|
|
|
|
arraycontainer = SpecParser::ArrayContainer.new Array(String).new.push "value"
|
|
begin
|
|
puts arraycontainer.as_s
|
|
puts "(NOT OK) SpecParser::ArrayContainer should not accept .as_s"
|
|
rescue e
|
|
puts "(OK) #{e}"
|
|
end
|
|
begin
|
|
pp! arraycontainer.as_a_or_s
|
|
puts "(OK) SpecParser::ArrayContainer should accept .as_a_or_s"
|
|
rescue e
|
|
puts "(NOT OK) #{e}"
|
|
end
|