Sha256: e695bd7752b9087edb358b21d4034bae477f7c81c7f4223bc96eb2d37ebe89b3

Contents?: true

Size: 1.25 KB

Versions: 15

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'eac_ruby_utils/ruby/on_clean_environment'

module Avm
  module Ruby
    class Rubocop
      require_sub __FILE__
      enable_speaker
      enable_simple_cache
      common_constructor :base_path, :rubocop_args
      set_callback :initialize, :after do
        @base_path = ::Pathname.new(base_path.to_s) unless base_path.is_a?(::Pathname)
      end

      def run
        start_banner
        run_rubocop
      end

      private

      def cmd(*args)
        ::EacRubyUtils::Envs.local.command(*args)
      end

      def rubocop_command_uncached
        %w[env configured gemfile].each do |s|
          cmd = send("#{s}_rubocop_command")
          return cmd if cmd.present?
        end
        cmd('rubocop')
      end

      def rubocop_command_with_args
        rubocop_command.append(rubocop_args)
      end

      def rubocop_version_uncached
        ::EacRubyUtils::Ruby.on_clean_environment do
          rubocop_command.append(['--version']).execute!.strip
        end
      end

      def run_rubocop
        ::EacRubyUtils::Ruby.on_clean_environment { rubocop_command_with_args.system }
      end

      def start_banner
        infov 'Rubocop version', rubocop_version
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
avm-tools-0.116.1 lib/avm/ruby/rubocop.rb
avm-tools-0.116.0 lib/avm/ruby/rubocop.rb
avm-tools-0.115.0 lib/avm/ruby/rubocop.rb
avm-tools-0.114.2 lib/avm/ruby/rubocop.rb
avm-tools-0.114.1 lib/avm/ruby/rubocop.rb
avm-tools-0.114.0 lib/avm/ruby/rubocop.rb
avm-tools-0.113.6 lib/avm/ruby/rubocop.rb
avm-tools-0.113.5 lib/avm/ruby/rubocop.rb
avm-tools-0.113.4 lib/avm/ruby/rubocop.rb
avm-tools-0.113.3 lib/avm/ruby/rubocop.rb
avm-tools-0.113.2 lib/avm/ruby/rubocop.rb
avm-tools-0.113.1 lib/avm/ruby/rubocop.rb
avm-tools-0.113.0 lib/avm/ruby/rubocop.rb
avm-tools-0.112.0 lib/avm/ruby/rubocop.rb
avm-tools-0.111.0 lib/avm/ruby/rubocop.rb