class BigKeeper::ModuleCacheOperator
Public Class Methods
new(path)
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 31 def initialize(path) @cache_path = File.expand_path("#{path}/.bigkeeper") FileUtils.mkdir_p(@cache_path) unless File.exist?(@cache_path) if File.exist?("#{@cache_path}/module.cache") file = File.open("#{@cache_path}/module.cache", 'r', :encoding => 'UTF-8') @modules = JSON.load(file.read(), :encoding => 'UTF-8') file.close else @modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "add" => [], "del" => [], "current" => []}} end end
Public Instance Methods
add_git_module(module_name)
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 89 def add_git_module(module_name) @modules["git"]["current"] << module_name unless @modules["git"]["current"].include?(module_name) cache_modules end
add_path_module(module_name)
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 99 def add_path_module(module_name) @modules["path"]["current"] << module_name unless @modules["path"]["current"].include?(module_name) cache_modules end
add_path_modules()
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 49 def add_path_modules @modules["path"]["add"] end
all_git_modules()
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 65 def all_git_modules @modules["git"]["all"] end
all_path_modules()
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 45 def all_path_modules @modules["path"]["all"] end
cache_git_modules(modules)
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 84 def cache_git_modules(modules) @modules["git"]["all"] = modules.uniq cache_modules end
cache_modules()
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 114 def cache_modules file = File.new("#{@cache_path}/module.cache", 'w', :encoding => 'UTF-8') file << @modules.to_json file.close end
cache_path_modules(modules, add_modules, del_modules)
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 77 def cache_path_modules(modules, add_modules, del_modules) @modules["path"]["all"] = modules.uniq @modules["path"]["add"] = add_modules.uniq @modules["path"]["del"] = del_modules.uniq cache_modules end
clean_modules()
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 109 def clean_modules @modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "add" => [], "del" => [], "current" => []}} cache_modules end
current_git_modules()
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 69 def current_git_modules @modules["git"]["current"] end
current_path_modules()
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 57 def current_path_modules @modules["path"]["current"] end
del_git_module(module_name)
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 94 def del_git_module(module_name) @modules["git"]["current"].delete(module_name) if @modules["git"]["current"].include?(module_name) cache_modules end
del_path_module(module_name)
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 104 def del_path_module(module_name) @modules["path"]["current"].delete(module_name) if @modules["path"]["current"].include?(module_name) cache_modules end
del_path_modules()
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 53 def del_path_modules @modules["path"]["del"] end
remain_git_modules()
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 73 def remain_git_modules @modules["git"]["all"] - @modules["git"]["current"] end
remain_path_modules()
click to toggle source
# File lib/big_keeper/util/cache_operator.rb, line 61 def remain_path_modules @modules["path"]["all"] - @modules["path"]["current"] end