101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/cheat.rb', line 101
def execute(sheet_yaml)
sheet_body = YAML.load(sheet_yaml).to_a.flatten.last
puts "\n " + sheet_body.gsub("\r",'').gsub("\n", "\n ").wrap
puts "\nWould you like to execute the above sheet? (Y/N)"
answer = STDIN.gets
case answer.chomp
when "Y" then system YAML.load(sheet_yaml).to_a.flatten.last
when "N" then puts "Not executing sheet."
else
puts "Must be Y or N!"
end
rescue Errno::EPIPE
rescue
puts "That didn't work. Maybe try `$ cheat cheat' for help?" end
|