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.23.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.22.3 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.22.2 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.22.1 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.22.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.21.4 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.21.3 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.21.2 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.21.1 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.21.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.20.2 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.20.1 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.20.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.19.2 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.19.1 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.19.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.18.6 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.18.5 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.18.4 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.18.3 lib/cc/cli/upgrade_config_generator.rb