This repository has been archived by the owner on Sep 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
semi working version but what do i need to do
- Loading branch information
1 parent
fac2c38
commit 3f4013e
Showing
3 changed files
with
23 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|