Class: RenuoBinCheck::Cacher

Inherits:
Object
  • Object
show all
Defined in:
lib/renuo_bin_check/cacher.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, paths) ⇒ Cacher

Returns a new instance of Cacher.



7
8
9
10
11
# 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

Instance Method Details

#cache(result) ⇒ Object



21
22
23
24
25
26
# 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?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/renuo_bin_check/cacher.rb', line 13

def exists?
  File.exist?("tmp/bin-check/#{@name}/#{@hash}")
end

#resultObject



17
18
19
# File 'lib/renuo_bin_check/cacher.rb', line 17

def result
  read
end