Move the two exactly duplicated methods into a module.

master
Jeff Dallien 2012-02-21 19:53:53 -05:00
parent 61d8f6e13b
commit 2856bd60fe
4 changed files with 22 additions and 32 deletions

View File

@ -1,4 +1,5 @@
require "cookie_extractor/version"
require "cookie_extractor/common"
require "cookie_extractor/firefox_cookie_extractor"
require "cookie_extractor/chrome_cookie_extractor"

View File

@ -2,6 +2,7 @@ require 'sqlite3'
module CookieExtractor
class ChromeCookieExtractor
include Common
def initialize(cookie_file)
@cookie_file = cookie_file
@ -23,21 +24,5 @@ module CookieExtractor
end
@result
end
private
def is_domain_wide(hostname)
hostname[0..0] == "."
end
def true_false_word(value)
if value == "1" || value == 1 || value == true
"TRUE"
elsif value == "0" || value == 0 || value == false
"FALSE"
else
raise "Invalid value passed to true_false_word: #{value.inspect}"
end
end
end
end

View File

@ -0,0 +1,19 @@
module CookieExtractor
module Common
private
def is_domain_wide(hostname)
hostname[0..0] == "."
end
def true_false_word(value)
if value == "1" || value == 1 || value == true
"TRUE"
elsif value == "0" || value == 0 || value == false
"FALSE"
else
raise "Invalid value passed to true_false_word: #{value.inspect}"
end
end
end
end

View File

@ -2,6 +2,7 @@ require 'sqlite3'
module CookieExtractor
class FirefoxCookieExtractor
include Common
def initialize(cookie_file)
@cookie_file = cookie_file
@ -23,21 +24,5 @@ module CookieExtractor
end
@result
end
private
def is_domain_wide(hostname)
hostname[0..0] == "."
end
def true_false_word(value)
if value == "1" || value == 1 || value == true
"TRUE"
elsif value == "0" || value == 0 || value == false
"FALSE"
else
raise "Invalid value passed to true_false_word: #{value.inspect}"
end
end
end
end