Skip to content

Commit

Permalink
+ upload, push
Browse files Browse the repository at this point in the history
require rubygems-rake (sh)
curl --netrc-optional --ftp-ssl --insecure
  • Loading branch information
mvidner committed Jun 10, 2010
1 parent bca1a2b commit a42f802
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions blobec
Expand Up @@ -2,12 +2,16 @@

require "pp"
#require "uri"
#require "rubygems"
require "rubygems"
require "rake"
#require "net/ftp-netrc"

command = ARGV[0]
filename = ARGV[1]
url = File.new(filename + ".blburl").readline.chomp

def url_for(filename)
File.new(filename + ".blburl").readline.chomp
end

#url_s = ARGV[0]
#url = URI.parse url_s
Expand All @@ -25,23 +29,26 @@ def ruby_upload(url, filename)
end

def sys(array)
system *array
sh *array
end

def curl(array)
# insecure sucks. should --cacert help?
sys %w{curl --verbose --netrc-optional --ftp-ssl --insecure} + array
end

def upload(url, filename)
sys %w{curl -v -n -T} + [filename, url.to_s]
curl ["--upload-file", filename, url.to_s]
end

def download(url, filename)
sys %w{curl -v -n --remote-time -o} + [filename, url.to_s]
curl %w{--remote-time --output} + [filename, url.to_s]
end

def timestamp(url, filename)
sys %w{curl -v -n --remote-time --range 0-0 -o} + [filename, url.to_s]
curl %w{--remote-time --range 0-0 --output} + [filename, url.to_s]
end

#upload(url, filename)

def mtime(filename)
File.new(filename).mtime
end
Expand Down Expand Up @@ -74,10 +81,25 @@ def update(url, filename)
merge theirs_fn, mine_fn, filename
end

def push(filename)
local = "file://" + File.expand_path(filename)
git = filename + ".git"
sys %w{git clone --bare} + [local, git]
tar = git + ".tar"
sys %w{tar cvf} + [tar, git]
gtg = filename + ".gtg"
sys %w{gpg --encrypt --default-recipient-self --output} + [gtg, tar]
upload url_for(gtg), gtg
end

case command
when "up", "update":
update(url, filename)
when "ci", "checkin":
when "st", "status":
system "ls -l #{filename}*"
when "upload":
upload(url, filename)
when "push":
push filename
end

0 comments on commit a42f802

Please sign in to comment.