Skip to content

Instantly share code, notes, and snippets.

@evanfarrar
Created November 20, 2010 00:35
Show Gist options
  • Save evanfarrar/707477 to your computer and use it in GitHub Desktop.
Save evanfarrar/707477 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'raspell'
class RdocSpellchecker
attr_accessor :badwords
def initialize
@sp = Aspell.new("en")
@sp.set_option("ignore-case","true")
end
def check(dirry)
@badwords = []
Dir.glob("/home/evan/Documents/docrails/#{dirry}/lib/**/*.rb").inject({}) {|acc, rb_file|
lines = File.readlines(rb_file)
nl = [*1..lines.length].zip(lines)
nl = nl.select do |l|
l[1]=~/^ *\#/&&(!(cheque_line(l[1])))
end
acc[rb_file] = nl
acc
}
end
def cheque_line(line)
line.gsub(/^ *\#/,'').gsub(/[=&<>\#?~!$%\/+@'"*-.,{}\[\]|_\(\);:]/,' ').split(' ').inject(true){ |a,b|
unless @sp.check(b)
@badwords << b
end
a&&@sp.check(b)
}
end
def goodwords
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment