Sha256: 411a1b2098650d9d00b8a6e3a7bac82a954bd8a1e87bb01053620931d3139014

Contents?: true

Size: 1.41 KB

Versions: 30

Compression:

Stored size: 1.41 KB

Contents

require "highline"
require "active_support"
require "active_support/core_ext"
require "rainbow"

module CC
  module CLI
    class Command
      CODECLIMATE_YAML = ".codeclimate.yml".freeze

      def initialize(args = [])
        @args = args
      end

      def run
        $stderr.puts "unknown command #{self.class.name.split('::').last.underscore}"
      end

      def self.command_name
        name[/[^:]*$/].split(/(?=[A-Z])/).map(&:downcase).join('-')
      end

      def execute
        run
      end

      def say(message)
        terminal.say message
      end

      def warn(message)
        terminal.say(colorize("WARNING: #{message}", :yellow))
      end

      def fatal(message)
        $stderr.puts colorize(message, :red)
        exit 1
      end

      def require_codeclimate_yml
        if !filesystem.exist?(CODECLIMATE_YAML)
          fatal("No '.codeclimate.yml' file found. Run 'codeclimate init' to generate a config file.")
        end
      end

      private

      def colorize(string, *args)
        rainbow.wrap(string).color(*args)
      end

      def rainbow
        @rainbow ||= Rainbow.new
      end

      def filesystem
        @filesystem ||= CC::Analyzer::Filesystem.new(ENV['FILESYSTEM_DIR'])
      end

      def terminal
        @terminal ||= HighLine.new($stdin, $stdout)
      end

      def engine_registry
        @engine_registry ||= CC::Analyzer::EngineRegistry.new
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
codeclimate-0.9.7 lib/cc/cli/command.rb
codeclimate-0.9.6 lib/cc/cli/command.rb
codeclimate-0.9.5 lib/cc/cli/command.rb
codeclimate-0.9.4 lib/cc/cli/command.rb
codeclimate-0.9.3 lib/cc/cli/command.rb
codeclimate-0.9.2 lib/cc/cli/command.rb
codeclimate-0.9.1 lib/cc/cli/command.rb
codeclimate-0.9.0 lib/cc/cli/command.rb
codeclimate-0.8.1 lib/cc/cli/command.rb
codeclimate-0.8.0 lib/cc/cli/command.rb
codeclimate-0.7.2 lib/cc/cli/command.rb
codeclimate-0.7.0 lib/cc/cli/command.rb
codeclimate-0.6.4 lib/cc/cli/command.rb
codeclimate-0.6.3 lib/cc/cli/command.rb
codeclimate-0.6.2 lib/cc/cli/command.rb
codeclimate-0.6.1 lib/cc/cli/command.rb
codeclimate-0.6.0 lib/cc/cli/command.rb
codeclimate-0.5.0 lib/cc/cli/command.rb
codeclimate-0.4.4 lib/cc/cli/command.rb
codeclimate-0.4.3 lib/cc/cli/command.rb