Sha256: bbb5e08b910b7921f893214cc6bc0f17ca907a7fc0caf5e559f7efa93bbd4f97

Contents?: true

Size: 815 Bytes

Versions: 9

Compression:

Stored size: 815 Bytes

Contents

require 'rocket_fuel/command_line_icon'

module RocketFuel
  module Precheck
    class CommandLineResultPresenter
      include Thor::Base

      SUCCESS_ICON = ["\u2713", '[ok]    ']
      FAILURE_ICON = ["\u00D7", '[failed]']

      def initialize(result)
        @result = result
      end

      def present
        print_wrapped(set_color([icon.render, @result.message].join(" "), color),
          :indent => 2)
      end

      protected
      def icon
        @result.ok? ? success_icon : failure_icon
      end

      def success_icon
        @success_icon ||= RocketFuel::CommandLineIcon.new(*SUCCESS_ICON)
      end

      def failure_icon
        @failure_icon ||= RocketFuel::CommandLineIcon.new(*FAILURE_ICON)
      end

      def color
        @result.ok? ? :green : :red
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rocket_fuel-0.2.0 lib/rocket_fuel/precheck/command_line_result_presenter.rb
rocket_fuel-0.1.0 lib/rocket_fuel/precheck/command_line_result_presenter.rb
rocket_fuel-0.0.8 lib/rocket_fuel/precheck/command_line_result_presenter.rb
rocket_fuel-0.0.7 lib/rocket_fuel/precheck/command_line_result_presenter.rb
rocket_fuel-0.0.6 lib/rocket_fuel/precheck/command_line_result_presenter.rb
rocket_fuel-0.0.5 lib/rocket_fuel/precheck/command_line_result_presenter.rb
rocket_fuel-0.0.4 lib/rocket_fuel/precheck/command_line_result_presenter.rb
rocket_fuel-0.0.3 lib/rocket_fuel/precheck/command_line_result_presenter.rb
rocket_fuel-0.0.2 lib/rocket_fuel/precheck/command_line_result_presenter.rb