Class: ToolsCache

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/lib/cache.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ToolsCache

Returns a new instance of ToolsCache.



5
6
# File 'lib/lib/cache.rb', line 5

def initialize(options = {})
end

Class Method Details

.create_cache_file(cache_name, cache_dir) ⇒ Object

Create a cache file in work area

Parameters:

  • arguments

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/lib/cache.rb', line 13

def self.create_cache_file cache_name, cache_dir

  unless File.exists? cache_dir
   ToolsLog.tools_error "Invalid directory in new config file in '#{cache_dir}'.", :light_red
   ToolsLog.tools_exit
  end
  unless cache_dir.end_with? '/'
    cache_dir += '/'
  end

  cache_file = cache_dir +  cache_name + '.cache'
  if File.exists? cache_file
   ToolsLog.tools_error "The cache file in '#{cache_file}' already exists. Leaving operation...", :light_yellow
  else
    ToolsFiles.create_file cache_dir, cache_name, "cache_#{cache_name}"
  end

end

.method_missing(method, *args, &block) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/lib/cache.rb', line 32

def self.method_missing(method, *args, &block)
  #expected call format =>    STRING_LOGGER_TYPE + '_' + LOGGER_TYPE
  # Ex.:  tools_info
  cache_name   = method.to_s.split('_').first
  cache_method = method.to_s.split('_').last
  cache_file   = ToolsUtil.get_variable "cache_#{cache_name}"

  ap cache_name
  ap cache_method
  ap cache_file
  ap args
  ap block

end