class Granify::Controller::Hound

Public Instance Methods

coffee() click to toggle source
# File lib/controllers/hound.rb, line 4
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
ruby() click to toggle source
# File lib/controllers/hound.rb, line 48
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
widgets() click to toggle source
# File lib/controllers/hound.rb, line 26
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

Private Instance Methods

error_message(m, type) click to toggle source
# File lib/controllers/hound.rb, line 61
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
success_message(m) click to toggle source
# File lib/controllers/hound.rb, line 67
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