Sha256: 747655beb73f2d0adf0745567d09edb5007f26dc723c828e55cb9f69648959a4
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
#!/usr/bin/env ruby require 'json' require 'uri' require 'net/http' require File.dirname(__FILE__) + '/../lib/nuri/targz' module Nuri module Util TarGzip = Object.new.extend(Util::Tar) def self.install_modules(address, port, modules, protocol="http") data = {} modules.each do |module_name| raise Exception, "Module #{module_name} is not exist!" if not ::File.directory?(module_name) data[module_name] = TarGzip.targzip(module_name, module_name).read end url = "#{protocol}://#{address}:#{port}/modules" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Put.new(uri.request_uri) request.set_form_data(data) response = http.request(request) (response.code == '200') end end end if $0 == __FILE__ if ARGV.length < 2 puts "Usage: #{$0.split('/').last} <address>:[port] <module-name>+ " exit(1) end DefaultPort = 1314 address, port = ARGV.shift.split(':', 2) port = port.to_s.to_i port = DefaultPort unless port > 0 modules = ARGV missing = modules.select { |mod| not ::File.directory?(mod) } modules = modules - missing success = Nuri::Util.install_modules(address, port, modules) output = { :status => success, :installed_modules => modules, :missing_modules => missing } puts JSON.generate(output) exit (success ? 0 : 1) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nuri-0.5.3 | bin/nuri-install-module |