class WordPressTools::WPCLICore
Public Instance Methods
check_bash_path()
click to toggle source
# File lib/wordpress_tools/wp_cli_core.rb, line 78 def check_bash_path run_command("which wp") end
download()
click to toggle source
# File lib/wordpress_tools/wp_cli_core.rb, line 36 def download info("Downloading WP-CLI...") get(download_url, download_path, verbose: false, force: true) || error("Cannot download WP-CLI") success("Downloaded WP-CLI") end
download_path()
click to toggle source
# File lib/wordpress_tools/wp_cli_core.rb, line 66 def download_path @download_path ||= Tempfile.new('wp_cli').path end
download_url()
click to toggle source
# File lib/wordpress_tools/wp_cli_core.rb, line 62 def download_url Configuration.for(:wp_cli_download_url) end
install()
click to toggle source
# File lib/wordpress_tools/wp_cli_core.rb, line 8 def install return unless overwrite? download move make_executable if installed? success("WP-CLI installed") check_bash_path || warning("Please, add #{install_path} to your shell '$PATH'") else error("Could not install WP-CLI") end end
install_dir()
click to toggle source
# File lib/wordpress_tools/wp_cli_core.rb, line 74 def install_dir File.dirname(install_path) end
install_path()
click to toggle source
# File lib/wordpress_tools/wp_cli_core.rb, line 70 def install_path Configuration.for(:wp_cli_path) end
installed?()
click to toggle source
# File lib/wordpress_tools/wp_cli_core.rb, line 32 def installed? File.exist?(install_path) && File.executable?(install_path) end
make_executable()
click to toggle source
# File lib/wordpress_tools/wp_cli_core.rb, line 53 def make_executable info("Making WP-CLI executable...") need_sudo = !File.writable?(install_dir) run_command(executable_bit_command(install_path, need_sudo)) || error("Cannot make WP-CLI executable") success("WP-CLI is now executable") end
move()
click to toggle source
# File lib/wordpress_tools/wp_cli_core.rb, line 44 def move info("Installing WP-CLI...") need_sudo = !File.writable?(install_dir) run_command(move_command(download_path, install_path, need_sudo)) || error("Cannot install WP-CLI in '#{install_path}'") success("Installed WP-CLI in '#{install_path}'") end
overwrite?()
click to toggle source
# File lib/wordpress_tools/wp_cli_core.rb, line 24 def overwrite? if installed? && options[:force] != true yes? "WP-CLI already installed [#{install_path}]. Do you want to overwite it? [y]es, [N]o" else true end end