Sha256: be03644899465824c19211ef14df80f5b01d00f106db01500c76c6d5bce480d4

Contents?: true

Size: 893 Bytes

Versions: 83

Compression:

Stored size: 893 Bytes

Contents

require "cc/cli/config_generator"

module CC
  module CLI
    class UpgradeConfigGenerator < ConfigGenerator
      def can_generate?
        errors.blank?
      end

      def errors
        existing_yaml.errors
      end

      def exclude_paths
        (existing_yaml.exclude_paths || []).map(&:to_s)
      end

      def post_generation_verb
        "upgraded"
      end

      private

      def engine_eligible?(engine)
        base_eligble = super
        if engine["upgrade_languages"].present?
          base_eligble && (engine["upgrade_languages"] & classic_languages).any?
        else
          base_eligble
        end
      end

      def classic_languages
        @classic_languages ||= existing_yaml.languages.reject { |_, v| !v }.map(&:first)
      end

      def existing_yaml
        @existing_yaml ||= CC::Yaml.parse(File.read(CODECLIMATE_YAML))
      end
    end
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
codeclimate-0.14.1 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.14.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.13.0 lib/cc/cli/upgrade_config_generator.rb