Sha256: fdcd08490db54c0e8b73e1daee08bb487c079e38a06b351dc2c6bf30dbb941b7

Contents?: true

Size: 805 Bytes

Versions: 1

Compression:

Stored size: 805 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
        self.file = LearnDoctor::HealthCheck::File.new(step, :check)
      end

      def run_check_for_step
        print "#{title}..."
        self.result = Open3.popen3('bash', file.path)[1].read.strip.to_i
      end

      def print_result
        if result == 1
          puts 'ok'
        else
          puts 'error'.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.0 lib/learn_doctor/health_check/step_checker.rb