Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

54 lines (38 sloc) 1.225 kB
require 'rubygems'
require 'rest_client'
require 'tmpdir'
# quit unless our script gets two command line arguments
unless ARGV.length == 2
puts "Usage: ruby masterupdate.rb InputFile.csv http://username:password@licensechecker.cloudfoundry.com\n"
exit
end
file_to_parse = ARGV.first.strip
url_to_rest_call = ARGV.last.strip
file = File.new(file_to_parse, 'r')
site = RestClient::Resource.new(url_to_rest_call)
site['master'].delete
tempfilename = File.join(Dir.tmpdir, "restfile")
tempfile = File.new(tempfilename, "w")
i = 0
rest = ""
while (row = file.gets)
tempfile.puts row.strip
#rest = rest + "\r\n" + row.strip
i = i + 1
if i > 1000
tempfile.close
response = site['master/upload'].post :csvfile => File.new(tempfilename, 'rb')
puts "REST Request was sent"
puts response.to_str
File.delete(tempfilename)
tempfile = File.new(tempfilename, "w")
i = 0;
rest = ""
end
end
tempfile.close
response = site['master/upload'].post :csvfile => File.new(tempfilename, 'rb')
puts "REST Request was sent"
puts response.to_str
File.delete(tempfilename)
file.close
Jump to Line
Something went wrong with that request. Please try again.