Sha256: 146bf1a36154ad1e3f42fea422398c740d1dbfd4a68479b4eff22a8cd59d4f27
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
require 'open-uri' require 'json' require 'archive/zip' require 'launchy' module Bukkit def self.install $opt2 = ARGV[1].downcase abort(Bukkit::Help.install) if $opt2.nil? begin plugins_api = JSON.parse(open("http://api.bukget.org/3/plugins/bukkit/#{$opt2}").read) website = plugins_api["website"] download = plugins_api["versions"][0]["download"] filename = plugins_api["versions"][0]["filename"] Dir.chdir("plugins") puts "Downloading #{$opt2} from #{website}..." Bukkit::download(filename, download) if File.extname(filename) == ".zip" # Extract Zip Archive Archive::Zip.extract(filename, $opt2) Dir.chdir($opt2) jarfiles = Dir.glob("*.jar") # Move each jar file outside the folder. jarfiles.each do |jar| %x(mv #{jar} ../) end Dir.chdir("../") # Delete the extracted folder. %x(rm -rf #{$opt2}/) # Delete the archive. %x(rm #{filename}) puts "Plugin successfully installed!" ask_website else puts "Plugin successfully installed!" ask_website end rescue Errno::ENOENT puts " You aren't in a server's root directory.\n 'plugins' directory not found." rescue puts " Plugin not found." end end end def ask_website if ARGV.include? "--website" Bukkit.website($opt2) elsif ARGV.include? "-w" Bukkit.website($opt2) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bukkit-0.1.4 | lib/bukkit/install.rb |