Sha256: 4db7bae1b38fd90a9e638ce0aeb28b20efcc4c1d501abfd2c4c5367d298d7d30

Contents?: true

Size: 1.02 KB

Versions: 34

Compression:

Stored size: 1.02 KB

Contents

require 'open3'

module LearnTest
  module PythonUnittest
    class RequirementsChecker
      def self.check_installation
        new.check_installation
      end

      def check_installation
        PythonChecker.check
        PipChecker.check
      end
    end

    class PythonChecker
      def self.check
        new.check
      end

      def check
        if !python_installed? || !correct_python_version?
          puts "Please install python 2.7.x or 3.x.x"
          exit
        end
      end

      def python_installed?
        !`which python`.empty?
      end

      def correct_python_version?
        output = Open3.popen2e('python', '--version')
        version = output[1].read.strip
        !!version.match(/ 2.7.*| 3.*/)
      end
    end

    class PipChecker
      def self.check
        new.check
      end

      def check
        if !pip_installed?
          puts "Please ensure pip is installed"
          exit
        end
      end

      def pip_installed?
        !`which pip`.empty?
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
learn-test-2.5.6 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.5.5 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.5.4 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.5.3 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.5.2 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.5.1 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.5.0 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.5.0.rc2 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.5.0.rc1 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.4.2 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.4.1 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.4.0 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.3.3 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.3.2 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.3.1 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.3.0 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.2.2 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.2.1 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.2.0 lib/learn_test/strategies/python_unittest/requirements_checker.rb
learn-test-2.1.2 lib/learn_test/strategies/python_unittest/requirements_checker.rb