Skip to content

Instantly share code, notes, and snippets.

@paulschreiber
Created July 11, 2015 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulschreiber/533ca760522190cb1bb0 to your computer and use it in GitHub Desktop.
Save paulschreiber/533ca760522190cb1bb0 to your computer and use it in GitHub Desktop.
Update WordPress plugin
#!/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