Sha256: 2402784fdaef1f767259254f4ead6765afd3dbeab27754fc320177c4f411b564

Contents?: true

Size: 778 Bytes

Versions: 2

Compression:

Stored size: 778 Bytes

Contents

module Phare
  module Checks
    class RubyRubocop
      attr_reader :status

      def initialize
        @command = 'bundle exec rubocop'
      end

      def run
        if should_run?
          print_banner
          system(@command)
          @status = $CHILD_STATUS.exitstatus

          unless @status == 0
            puts "Something went wrong. Program exited with #{@status}"
          end

          puts ''
        else
          @status = 0
        end
      end

    protected

      def should_run?
        !`which rubocop`.empty?
      end

      def print_banner
        puts '----------------------------------------'
        puts 'Running Rubocop to check for Ruby style…'
        puts '----------------------------------------'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phare-0.1.2 lib/phare/checks/ruby_rubocop.rb
phare-0.1.1 lib/phare/checks/ruby_rubocop.rb