Sha256: a607259104142128124a8c010dd6ee26d00a834f8a58472cbcc96e31c3a6c20f

Contents?: true

Size: 782 Bytes

Versions: 2

Compression:

Stored size: 782 Bytes

Contents

module LearnDoctor
  class HealthCheck
    class StepChecker
      attr_reader   :step, :title
      attr_accessor :file, :result

      def initialize(step)
        @step = step
        @title = step[:title]
      end

      def execute
        set_file
        run_check_for_step
        print_result
        unlink_file!

        self
      end

      private

      def set_file
        print "#{title}..."
        self.file = LearnDoctor::HealthCheck::File.new(step, :check)
      end

      def run_check_for_step
        self.result = `#{file.path}`.strip.to_i
      end

      def print_result
        if result == 1
          puts 'ok'
        else
          puts 'missing'.red
        end
      end

      def unlink_file!
        file.unlink!
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
learn-doctor-1.0.3 lib/learn_doctor/health_check/step_checker.rb
learn-doctor-1.0.2 lib/learn_doctor/health_check/step_checker.rb