commit 50ba53d1d41fefc52cabf0870c2cf2c3838467e1 Author: Robert "ar" Gerus Date: Thu May 23 07:00:19 2013 +0200 Current version, code previously untracked. diff --git a/up b/up new file mode 100755 index 0000000..33631ee --- /dev/null +++ b/up @@ -0,0 +1,32 @@ +#!env ruby +require 'rubygems' +require 'digest/md5' +require 'net/scp' +require 'open-uri' +require 'ruby-progressbar' + +files = [] + +Net::SCP.start("i.am-a.cat", "arachnist") do |scp| + ARGV.each do |path| + ext = "." + path.sub(/.*[.]([^.]*)/, '\1') if path.match(/[^.]+[.][^.]+/) + content = open(path).read + files << { + :title => path.sub(/.*\//, ''), + :ext => ext, + :md5 => Digest::MD5.hexdigest(content), + :content => content, + :size => content.bytes.count + } + end + + files.each do |f| + p = ProgressBar.create(:title => f[:title], :total => f[:size], :format => '%t | %E | %w>') + + scp.upload! StringIO.new(f[:content]), "/home/arachnist/public_html/c/#{f[:md5]}#{f[:ext]}" do |ch, name, sent, total| + p.progress = sent + end + + puts "\t=> https://arachnist.is-a.cat/c/#{f[:md5]}#{f[:ext]}" + end +end