Sha256: c2ea0f95c2cd74770abbb40bf605b965c576b1408a9c87adf0357351c258bf17

Contents?: true

Size: 896 Bytes

Versions: 39

Compression:

Stored size: 896 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_eligible = super
        if engine["upgrade_languages"].present?
          base_eligible && (engine["upgrade_languages"] & classic_languages).any?
        else
          base_eligible
        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

39 entries across 39 versions & 1 rubygems

Version Path
codeclimate-0.69.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.68.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.67.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.66.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.65.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.64.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.63.7 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.63.6 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.63.5 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.63.4 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.63.3 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.63.2 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.63.1 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.63.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.62.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.61.1 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.61.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.60.1 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.60.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.59.1 lib/cc/cli/upgrade_config_generator.rb