Sha256: 829f68527f10921e8c8c36eda6e1c20844add656fea002ae287c682a398e66a2

Contents?: true

Size: 935 Bytes

Versions: 1

Compression:

Stored size: 935 Bytes

Contents

require "guard"
require "guard/plugin"
require "rubycritic"
require "rubycritic/reporters/mini"

module Guard

  class Rubycritic < Plugin
    # Called once when Guard starts. Please override initialize method to init stuff.
    #
    # @raise [:task_has_failed] when start has failed
    # @return [Object] the task result
    #
    def start
      @rubycritic = ::Rubycritic::Orchestrator.new
      UI.info "Guard::Rubycritic is critiquing"
    end

    # Default behaviour on file(s) changes that the Guard plugin watches.
    # @param [Array<String>] paths the changes files or paths
    # @raise [:task_has_failed] when run_on_change has failed
    # @return [Object] the task result
    #
    def run_on_changes(paths)
      analysed_files = @rubycritic.critique(paths)
      report_location = ::Rubycritic::Reporter::Mini.new(analysed_files).generate_report
      UI.info "New critique at #{report_location}"
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
guard-rubycritic-1.0.0 lib/guard/rubycritic.rb