class RenuoBinCheck::Cacher
Public Class Methods
new(name, paths)
click to toggle source
# File lib/renuo_bin_check/cacher.rb, line 7 def initialize(name, paths) @name = name @file_names = paths.map { |path| Dir[path] }.flatten.sort @hash = hash_files end
Public Instance Methods
cache(result)
click to toggle source
# File lib/renuo_bin_check/cacher.rb, line 21 def cache(result) FileUtils.mkdir_p "tmp/bin-check/#{@name}/#{@hash}" File.write "tmp/bin-check/#{@name}/#{@hash}/standard_output", result.standard_output File.write "tmp/bin-check/#{@name}/#{@hash}/error_output", result.error_output File.write "tmp/bin-check/#{@name}/#{@hash}/exit_code", result.exit_code end
exists?()
click to toggle source
# File lib/renuo_bin_check/cacher.rb, line 13 def exists? File.exist?("tmp/bin-check/#{@name}/#{@hash}") end
result()
click to toggle source
# File lib/renuo_bin_check/cacher.rb, line 17 def result read end
Private Instance Methods
hash_file(file_name)
click to toggle source
:reek: UtilityFunction
# File lib/renuo_bin_check/cacher.rb, line 42 def hash_file(file_name) Digest::MD5.file(file_name).hexdigest + Digest::MD5.hexdigest(file_name) end
hash_files()
click to toggle source
# File lib/renuo_bin_check/cacher.rb, line 37 def hash_files Digest::MD5.hexdigest @file_names.map { |file_name| hash_file(file_name) if File.file? file_name }.to_s end
read()
click to toggle source
# File lib/renuo_bin_check/cacher.rb, line 30 def read standard_output = File.read("tmp/bin-check/#{@name}/#{@hash}/standard_output") error_output = File.read("tmp/bin-check/#{@name}/#{@hash}/error_output") exit_code = File.read("tmp/bin-check/#{@name}/#{@hash}/exit_code").to_i Result.new(standard_output, error_output, exit_code) end