Sha256: 4a625e0c79208169a24f21b6909bcaba32c6ca7bcf97ad4f11ed7382e17f133b

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 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 = Open3.popen2e(file.path)[1].read.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

1 entries across 1 versions & 1 rubygems

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