Sha256: 446733c81d9fb52e3ea880cd81d1d6517639e7b635b680cfa55397c8ce864e3b

Contents?: true

Size: 835 Bytes

Versions: 2

Compression:

Stored size: 835 Bytes

Contents

require 'app/controllers/grammar_checker.rb'

begin
  GrammarChecker.check(ARGV[0])
  puts "Output saved to '#{ARGV[0]}.#{GrammarChecker.suffix}'"
rescue ArgumentError => e
  puts "Usage: ruby check_grammar.rb file_name"
  puts "Output saved to file_name.#{GrammarChecker.suffix}"
# TODO find a way to avoid using Errno::* because of readability issues
rescue Errno::EEXIST => e # Output file exists
  print "There is already output saved for the file you're checking.  Overwrite? (y/n) "
  response = $stdin.gets.chomp # without $stdin, Ruby will read the file supplied to to the script
  
  if "y" != response
    exit!
  else
    File.delete("#{ARGV[0]}.#{GrammarChecker.suffix}")
    retry
  end
rescue Errno::ENOENT => e # No such file or directory
  puts e.message
rescue Errno::EISDIR => e # Is a directory
  puts e.message
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
odin-0.0.4 check_grammar.rb
odin-0.1.0.alpha.1 check_grammar.rb