module Granify module Controller class Hound < Controller::Base def coffee m = @model.data if m.below_acceptable_limit? Notify.info("Linting #{m.status[:total]} coffeescript files\nPrinting files with errors") m.files_with_errors.each do |file| Notify.spit(file) end success_message(m) else if m.log.exists? @model.command.open_editor(m.log) end error_message(m, :coffeescript) end Notify.bubble("Running coffeescript files through coffeelint", "Linting...") end def widgets m = @model.data if m.below_acceptable_limit? Notify.info("Linting #{m.status[:total]} coffeescript files\nPrinting files with errors") m.files_with_errors.each do |file| Notify.spit(file) end success_message(m) else if m.log.exists? @model.command.open_editor(m.log) end error_message(m, :coffeescript) end Notify.bubble("Running coffeescript files through coffeelint", "Linting...") end def ruby m = @model.data if m.below_acceptable_limit? Notify.info("Pass rate is above the acceptable limit, proceeding to next step") else error_message(m, :ruby) end Notify.bubble("Running ruby files through rubocop.", "Linting...") end private def error_message(m, type) post_exec Notify.warning("#{m.issues[:errors]} error(s), #{m.status[:errors_per_file]} EPF - EPF must be less than 5\n#{m.success_rate[:str]} success rate - 90% required") Notify.error("Too many #{type} errors to continue. Errors logged to:\n#{m.log}") end def success_message(m) Notify.spit("\nResults:\n - #{Style.format(m.status[:success].to_s + " passed", :green)}\n - #{Style.format(m.status[:error].to_s + " failed", :red)}\nSuccess rate: #{Style.format(m.success_rate[:str], :green)}\nErrors logged to #{Style.format(m.log, :green)}") end end end end