class Wordmove::Doctor::Wpcli

Attributes

logger[R]

Public Class Methods

new() click to toggle source
# File lib/wordmove/doctor/wpcli.rb, line 6
def initialize
  @logger = Logger.new(STDOUT).tap { |l| l.level = Logger::INFO }
end

Public Instance Methods

check!() click to toggle source
# File lib/wordmove/doctor/wpcli.rb, line 10
      def check!
        logger.task "Checking local wp-cli installation"

        if in_path?
          logger.success "wp-cli is correctly installed"

          if up_to_date?
            logger.success "wp-cli is up to date"
          else
            logger.error <<-LONG
  wp-cli is not up to date.
                Use `wp cli update` to update to the latest version.
            LONG
          end
        else
          logger.error <<-LONG
  wp-cli is not installed (or not in your $PATH).
              Read http://wp-cli.org/#installing for installation info.
          LONG
        end
      end

Private Instance Methods

in_path?() click to toggle source
# File lib/wordmove/doctor/wpcli.rb, line 34
def in_path?
  system('which wp', out: File::NULL)
end
up_to_date?() click to toggle source
# File lib/wordmove/doctor/wpcli.rb, line 38
def up_to_date?
  `wp cli check-update --format=json`.empty?
end