From 6760a64957f446aa0f3ec8172184fe2bdd052eff Mon Sep 17 00:00:00 2001 From: John Crepezzi Date: Sat, 16 Mar 2013 20:39:20 -0400 Subject: [PATCH] Avoid explosions (code a little different from PR) Closes #11 --- lib/haste.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/haste.rb b/lib/haste.rb index 2093171..4fe5b67 100644 --- a/lib/haste.rb +++ b/lib/haste.rb @@ -11,8 +11,9 @@ module Haste # Pull all of the data from STDIN def initialize if STDIN.tty? - abort 'No input file given' unless ARGV.length == 1 - abort "#{file}: No such path" unless File.exists?(file = ARGV[0]) + file = ARGV.first + abort 'No input file given' unless file + abort "#{file}: No such path" unless File.exists?(file) @input = open(file).read else @input = STDIN.readlines.join