Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Commit

Permalink
semi working version but what do i need to do
Browse files Browse the repository at this point in the history
  • Loading branch information
wizardishungry committed Dec 20, 2010
1 parent fac2c38 commit 3f4013e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Safari Plist code taken from http://seriousorange.com/2010/01/converting-safari-cookies-plist-to-cookies-txt/


This is my first Gem! Hello Whirled!
7 changes: 3 additions & 4 deletions bin/safari-cookiejar.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env ruby

require './lib/safari-cookiejar'
require 'rubygems'

#require('rubygems')

jar = SafariCookiejar.new

if ARGV.empty?
jar.usage
puts "#{$0} [curl|wget] arguments";
else
jar = SafariCookiejar.new
jar.run(ARGV)
end
22 changes: 17 additions & 5 deletions lib/safari-cookiejar.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
require 'rubygems'
require 'plist'
class SafariCookiejar
def usage
puts "#{$0} [curl|wget] arguments";
end
require 'tempfile'

class SafariCookiejar
def initialize
reload
end

def reload
result = Plist::parse_xml File.expand_path "~/Library/Cookies/Cookies.plist"
@tmp_file = Tempfile.new(self.class.name) {|f| result.each {|r| f.write("#{r["Domain"]}\tTRUE\t#{r["Path"]}\tFALSE\t#{r["Expires"].strftime("%s")}\t#{r["Name"]}\t#{r["Value"]}\n")}}
end

def run (argv)
def run (args)
args.unshift(prog=args.shift, case prog
when /wget[^\/]*$/
"--load-cookies"
when /curl[^\/]*$/
"--cookie"
else
return nil
end,
@tmp_file.path)

puts(args)
Kernel.system *args
@tmp_file.close!
end
end

0 comments on commit 3f4013e

Please sign in to comment.