utility.rb: Rubocop fixes

This commit is contained in:
Bill Niblock 2017-10-19 00:20:21 -04:00
parent e85a882851
commit bd45e60bb7

View file

@ -7,34 +7,32 @@
# documentation. # documentation.
# The default trunk text of a new tree # The default trunk text of a new tree
SKELE_TRUNK_TEXT = "Welcome to the Sapling Editor. For details, please see the SKELE_TRUNK_TEXT = 'Welcome to the Sapling Editor. For details, please see the
documentation!" documentation!'.freeze
# The default first-branch text of a new tree # The default first-branch text of a new tree
SKELE_BRANCH_TEXT = "The first branch is always shown by default. It should act 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!" 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 # 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 # to it's own branch. The only way out of the program is to either force-quit or
# reply with option 0. # 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 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 # The final tree
SKELETON_TREE = [ SKELETON_TREE = [
{"trunk" => "#{SKELE_TRUNK_TEXT}"}, { 'trunk' => SKELE_TRUNK_TEXT.to_s },
{"branch" => { { 'branch' => {
"number" => 1, 'number' => 1,
"text" => "#{SKELE_BRANCH_TEXT}", 'text' => SKELE_BRANCH_TEXT.to_s,
"leaf" => [{ 'leaf' => [{
"text" => "#{SKELE_LEAF_TEXT}", 'text' => SKELE_LEAF_TEXT.to_s,
"branch" => 1 'branch' => 1
}] }]
} } }
} ].freeze
]
# Verify that a file is a dialogue tree file. # Verify that a file is a dialogue tree file.
# #
@ -44,13 +42,13 @@ def verify_tree(file)
results = [] results = []
begin begin
tree = YAML.load_file(file) tree = YAML.load_file(file)
results << tree[0].keys.include?("trunk") results << tree[0].keys.include?('trunk')
results << tree[1]["branch"].keys.include?("number") results << tree[1]['branch'].keys.include?('number')
results << tree[1]["branch"].keys.include?("text") results << tree[1]['branch'].keys.include?('text')
results << tree[1]["branch"].keys.include?("leaf") results << tree[1]['branch'].keys.include?('leaf')
rescue rescue
puts "Sorry chummer, I don't think this is a tree." 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 results << false
end end