Sha256: 502a0c5c2d0e92095cd73ddc1fa61113b81c8b5891bd7710dd8da90c95a91488

Contents?: true

Size: 981 Bytes

Versions: 3

Compression:

Stored size: 981 Bytes

Contents

#!/usr/bin/env ruby

require 'uri'
require 'net/http'

module Nuri
	module Util
		def self.delete_module(address, port, modules, protocol="http")
			def self.send_request(url)
				uri = URI.parse(url)
				http = Net::HTTP.new(uri.host, uri.port)
				request = Net::HTTP::Delete.new(uri.request_uri)
				response = http.request(request)
				(response.code == '200')
			end
			if modules.length <= 0
				send_request("#{protocol}://#{address}:#{port}/modules")
			else
				modules.each do |mod|
					return false if not send_request("#{protocol}://#{address}:#{port}/modules/#{mod}")
				end
				true
			end
		end
	end
end

if $0 == __FILE__
	DefaultPort = 1314

	if ARGV.length < 1
		puts "Usage: delete_modules <address>:[port] [module-name]*"
		exit(1)
	end

	address, port = ARGV.shift.split(':', 2)
	port = port.to_s.to_i
	port = DefaultPort unless port > 0

	if Nuri::Util.delete_module(address, port, ARGV)
		puts '{"status":"ok"}'
	else
		puts '{"status":"failed"}'
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nuri-0.5.5 bin/nuri-uninstall-module
nuri-0.5.4 bin/nuri-uninstall-module
nuri-0.5.3 bin/nuri-uninstall-module