Sha256: 8f144f101be00e0890ed99b638756b382110e3b9aa21daa1d55bae00dfe0e363

Contents?: true

Size: 836 Bytes

Versions: 2

Compression:

Stored size: 836 Bytes

Contents

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

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

      def execute
        set_file
        run_install_for_step
        print_result
        unlink_file!

        self
      end

      private

      def set_file
        self.file = LearnDoctor::HealthCheck::File.new(step, :install)
      end

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

      def print_result
        if result.match(/Done/)
          puts 'done'.green
        else
          puts 'error'.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.1 lib/learn_doctor/health_check/step_installer.rb
learn-doctor-1.0.0 lib/learn_doctor/health_check/step_installer.rb