Class: Okayu::CookieThief
- Inherits:
-
Object
- Object
- Okayu::CookieThief
show all
- Defined in:
- lib/cookie_thief.rb
Class Method Summary
collapse
Class Method Details
.cookiestxt_from_array(cookie_array) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/cookie_thief.rb', line 24
def cookiestxt_from_array cookie_array
if cookie_array
cookie_array[1] = 'TRUE'
cookie_array[3] = cookie_array[3] != '0' ? 'TRUE' : 'FALSE'
cookie_array.join("\t") + "\n"
end
end
|
.do_on_tmpfile(filename) {|tmpfile| ... } ⇒ Object
32
33
34
35
36
37
|
# File 'lib/cookie_thief.rb', line 32
def do_on_tmpfile filename
tmpfile = "#{AppDir}/tmpfile"
FileUtils.cp(cookies_filename, tmpfile)
yield tmpfile
File.unlink "#{AppDir}/tmpfile"
end
|
.get(args) ⇒ Object
8
9
10
|
# File 'lib/cookie_thief.rb', line 8
def get args
cookiestxt_from_array(send_query(sql_from_hash(args)))
end
|
.send_query(sql) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/cookie_thief.rb', line 12
def send_query sql
cookie_array = []
do_on_tmpfile(cookies_filename) do |tmpfile|
db = SQLite3::Database.new(tmpfile)
cookie_array = db.execute(sql).first
db.close
end
cookie_array
end
|