Sha256: b7628ef1300e3493ba09f99a3cb9753e8212df1a407165e688f0ace0a59f8c87

Contents?: true

Size: 1.28 KB

Versions: 184

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

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

module Avm
  module EacRubyBase1
    class Rubocop
      require_sub __FILE__, include_modules: true
      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

184 entries across 184 versions & 3 rubygems

Version Path
avm-eac_ruby_base1-0.5.0 lib/avm/eac_ruby_base1/rubocop.rb
avm-tools-0.117.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop.rb
avm-eac_ruby_base1-0.4.0 lib/avm/eac_ruby_base1/rubocop.rb
avm-tools-0.116.2 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop.rb