Sha256: afdba0343e54b6b3a7a9bcc90d7d83261c2d654abc311e1ce220606c6cbf9dae

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require "cc/analyzer"

module CC
  module CLI
    module Engines
      class EngineCommand < Command
        include CC::Analyzer

        private

        def engine_name
          @engine_name ||= @args.first
        end

        def parsed_yaml
          @parsed_yaml ||= CC::Analyzer::Config.new(yaml_content)
        end

        def yaml_content
          File.read(filesystem.path_for(CODECLIMATE_YAML)).freeze
        end

        def update_yaml
          File.open(filesystem.path_for(CODECLIMATE_YAML), "w") do |f|
            f.write(parsed_yaml.to_yaml)
          end
        end

        def engine_present_in_yaml?
          parsed_yaml.engine_present?(engine_name)
        end

        def engine_enabled?
          parsed_yaml.engine_enabled?(engine_name)
        end

        def engine_exists?
          engines_registry_list.keys.include?(engine_name)
        end

        def engines_registry_list
          @engines_registry_list ||= CC::Analyzer::EngineRegistry.new.list
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
codeclimate-0.0.7 lib/cc/cli/engines/engine_command.rb
codeclimate-0.0.6 lib/cc/cli/engines/engine_command.rb
codeclimate-0.0.5 lib/cc/cli/engines/engine_command.rb
codeclimate-0.0.1 lib/cc/cli/engines/engine_command.rb