sapling.rb: Rubocop and refactor updates

- Fix several rubocop violations
- Update functionality to account for gardner refactor
This commit is contained in:
Bill Niblock 2017-10-18 23:46:00 -04:00
parent 321ce557d8
commit 8700f307a7

View file

@ -8,19 +8,20 @@ Dir[File.join(__dir__, 'sapling', '*.rb')].each { |file| require file }
# The main Sapling interface. # The main Sapling interface.
class Sapling < Thor class Sapling < Thor
desc 'read TREE', 'Load and traverse the TREE' desc 'read TREE', 'Load and traverse the TREE'
def read(tree) def read(file)
exit unless verify_tree(tree)
puts 'Welcome to Sapling, a Dialogue Tree Utility.' puts 'Welcome to Sapling, a Dialogue Tree Utility.'
speaker = Dialogue::Speaker.new(YAML.load_file(tree), false) exit unless verify_tree(file)
tree = Gardner::Plot.new(YAML.load_file(file), false)
speaker = Dialogue::Speaker.new(tree)
speaker.conversation speaker.conversation
end end
desc 'edit TREE', 'Edit a new or existing TREE' desc 'edit TREE', 'Edit a new or existing TREE'
def edit(tree = '') def edit(file = '')
puts 'Welcome to Sapling, a Dialogue Tree Utility.' puts 'Welcome to Sapling, a Dialogue Tree Utility.'
if !tree.empty? if !tree.empty?
puts "Loading tree: #{tree}" puts "Loading tree: #{file}"
exit unless verify_tree(tree) exit unless verify_tree(file)
gardner = Planter::Spade.new(YAML.load_file(tree, false)) gardner = Planter::Spade.new(YAML.load_file(tree, false))
else else
puts 'Creating a new tree!' puts 'Creating a new tree!'