utility.rb: Rubocop fixes
This commit is contained in:
parent
e85a882851
commit
bd45e60bb7
1 changed files with 21 additions and 23 deletions
|
@ -7,34 +7,32 @@
|
|||
# documentation.
|
||||
|
||||
# The default trunk text of a new tree
|
||||
SKELE_TRUNK_TEXT = "Welcome to the Sapling Editor. For details, please see the
|
||||
documentation!"
|
||||
SKELE_TRUNK_TEXT = 'Welcome to the Sapling Editor. For details, please see the
|
||||
documentation!'.freeze
|
||||
|
||||
# The default first-branch text of a new tree
|
||||
SKELE_BRANCH_TEXT = "The first branch is always shown by default. It should act
|
||||
as the introduction to the story. From here, the user enters your world!"
|
||||
SKELE_BRANCH_TEXT = 'The first branch is always shown by default. It should act
|
||||
as the introduction to the story. From here, the user enters your world!'.freeze
|
||||
|
||||
# The default first-leaf text of the first branch of a new tree. The leaf points
|
||||
# to it's own branch. The only way out of the program is to either force-quit or
|
||||
# reply with option 0.
|
||||
SKELE_LEAF_TEXT = "Each branch can have any number of leaves, which represent
|
||||
SKELE_LEAF_TEXT = 'Each branch can have any number of leaves, which represent
|
||||
the options a user has on that branch. Each leaf points to another branch, or
|
||||
can point to branch 0 to immediately exit."
|
||||
can point to branch 0 to immediately exit.'.freeze
|
||||
|
||||
# The final tree
|
||||
SKELETON_TREE = [
|
||||
{"trunk" => "#{SKELE_TRUNK_TEXT}"},
|
||||
{"branch" => {
|
||||
"number" => 1,
|
||||
"text" => "#{SKELE_BRANCH_TEXT}",
|
||||
"leaf" => [{
|
||||
"text" => "#{SKELE_LEAF_TEXT}",
|
||||
"branch" => 1
|
||||
}]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
{ 'trunk' => SKELE_TRUNK_TEXT.to_s },
|
||||
{ 'branch' => {
|
||||
'number' => 1,
|
||||
'text' => SKELE_BRANCH_TEXT.to_s,
|
||||
'leaf' => [{
|
||||
'text' => SKELE_LEAF_TEXT.to_s,
|
||||
'branch' => 1
|
||||
}]
|
||||
} }
|
||||
].freeze
|
||||
|
||||
# Verify that a file is a dialogue tree file.
|
||||
#
|
||||
|
@ -44,13 +42,13 @@ def verify_tree(file)
|
|||
results = []
|
||||
begin
|
||||
tree = YAML.load_file(file)
|
||||
results << tree[0].keys.include?("trunk")
|
||||
results << tree[1]["branch"].keys.include?("number")
|
||||
results << tree[1]["branch"].keys.include?("text")
|
||||
results << tree[1]["branch"].keys.include?("leaf")
|
||||
results << tree[0].keys.include?('trunk')
|
||||
results << tree[1]['branch'].keys.include?('number')
|
||||
results << tree[1]['branch'].keys.include?('text')
|
||||
results << tree[1]['branch'].keys.include?('leaf')
|
||||
rescue
|
||||
puts "Sorry chummer, I don't think this is a tree."
|
||||
puts "Verify your YAML file is formatted properly."
|
||||
puts 'Verify your YAML file is formatted properly.'
|
||||
results << false
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue