Created
July 11, 2015 13:54
-
-
Save paulschreiber/533ca760522190cb1bb0 to your computer and use it in GitHub Desktop.
Update WordPress plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "fileutils" | |
require "httparty" | |
def update(slug) | |
url = "https://api.wordpress.org/plugins/info/1.0/#{slug}.json?fields=-compatibility,-sections,-tags,-ratings,-short_description" | |
response = HTTParty.get(url, {request: :json}) | |
unless response["version"] | |
puts "Could not find data for #{slug}" | |
return | |
end | |
version = response["version"] | |
download_url = response["download_link"] | |
zipfile = download_url.split("/")[-1] | |
FileUtils.rm_rf(slug) | |
File.open(zipfile, "wb"){|f| f.write HTTParty.get(download_url).parsed_response} | |
`unzip -qq #{zipfile}` | |
end | |
if $ARGV.size != 1 | |
puts "Usage: foo <plugin>" | |
exit | |
end | |
update($ARGV[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment