Sha256: 16804023e49af96abc8a6886b2f48e3ba139e8d21c749c354f2c2ff7a7f9cd6f

Contents?: true

Size: 1.32 KB

Versions: 27

Compression:

Stored size: 1.32 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
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
codeclimate-0.2.4 lib/cc/cli/command.rb
codeclimate-0.2.2 lib/cc/cli/command.rb
codeclimate-0.2.1 lib/cc/cli/command.rb
codeclimate-0.2 lib/cc/cli/command.rb
codeclimate-0.1.5 lib/cc/cli/command.rb
codeclimate-0.1.4 lib/cc/cli/command.rb
codeclimate-0.1.3 lib/cc/cli/command.rb
codeclimate-0.1.2 lib/cc/cli/command.rb
codeclimate-0.1.0 lib/cc/cli/command.rb
codeclimate-0.0.25 lib/cc/cli/command.rb
codeclimate-0.0.24 lib/cc/cli/command.rb
codeclimate-0.0.23 lib/cc/cli/command.rb
codeclimate-0.0.22 lib/cc/cli/command.rb
codeclimate-0.0.21 lib/cc/cli/command.rb
codeclimate-0.0.18 lib/cc/cli/command.rb
codeclimate-0.0.17 lib/cc/cli/command.rb
codeclimate-0.0.16 lib/cc/cli/command.rb
codeclimate-0.0.15 lib/cc/cli/command.rb
codeclimate-0.0.14 lib/cc/cli/command.rb
codeclimate-0.0.13 lib/cc/cli/command.rb