Move the two exactly duplicated methods into a module.
This commit is contained in:
parent
61d8f6e13b
commit
2856bd60fe
4 changed files with 22 additions and 32 deletions
|
@ -1,4 +1,5 @@
|
|||
require "cookie_extractor/version"
|
||||
require "cookie_extractor/common"
|
||||
require "cookie_extractor/firefox_cookie_extractor"
|
||||
require "cookie_extractor/chrome_cookie_extractor"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
19
lib/cookie_extractor/common.rb
Normal file
19
lib/cookie_extractor/common.rb
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue