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.59.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.58.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.57.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.56.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.55.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.54.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.53.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.52.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.51.3 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.51.2 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.51.1 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.51.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.50.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.49.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.48.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.47.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.46.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.45.0 lib/cc/cli/upgrade_config_generator.rb
codeclimate-0.44.0 lib/cc/cli/upgrade_config_generator.rb