Class: BigKeeper::ModuleCacheOperator
- Inherits:
-
Object
- Object
- BigKeeper::ModuleCacheOperator
- Defined in:
- lib/big_keeper/util/cache_operator.rb
Instance Method Summary collapse
- #add_git_module(module_name) ⇒ Object
- #add_path_module(module_name) ⇒ Object
- #add_path_modules ⇒ Object
- #all_git_modules ⇒ Object
- #all_path_modules ⇒ Object
- #cache_git_modules(modules) ⇒ Object
- #cache_modules ⇒ Object
- #cache_path_modules(modules, add_modules, del_modules) ⇒ Object
- #clean_modules ⇒ Object
- #current_git_modules ⇒ Object
- #current_path_modules ⇒ Object
- #del_git_module(module_name) ⇒ Object
- #del_path_module(module_name) ⇒ Object
- #del_path_modules ⇒ Object
-
#initialize(path) ⇒ ModuleCacheOperator
constructor
A new instance of ModuleCacheOperator.
- #remain_git_modules ⇒ Object
- #remain_path_modules ⇒ Object
Constructor Details
#initialize(path) ⇒ ModuleCacheOperator
Returns a new instance of ModuleCacheOperator.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/big_keeper/util/cache_operator.rb', line 29 def initialize(path) @cache_path = File.("#{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') @modules = JSON.load(file.read(), :encoding => 'UTF-8') file.close else @modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "add" => [], "del" => [], "current" => []}} end end |
Instance Method Details
#add_git_module(module_name) ⇒ Object
87 88 89 90 |
# File 'lib/big_keeper/util/cache_operator.rb', line 87 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) ⇒ Object
97 98 99 100 |
# File 'lib/big_keeper/util/cache_operator.rb', line 97 def add_path_module(module_name) @modules["path"]["current"] << module_name unless @modules["path"]["current"].include?(module_name) cache_modules end |
#add_path_modules ⇒ Object
47 48 49 |
# File 'lib/big_keeper/util/cache_operator.rb', line 47 def add_path_modules @modules["path"]["add"] end |
#all_git_modules ⇒ Object
63 64 65 |
# File 'lib/big_keeper/util/cache_operator.rb', line 63 def all_git_modules @modules["git"]["all"] end |
#all_path_modules ⇒ Object
43 44 45 |
# File 'lib/big_keeper/util/cache_operator.rb', line 43 def all_path_modules @modules["path"]["all"] end |
#cache_git_modules(modules) ⇒ Object
82 83 84 85 |
# File 'lib/big_keeper/util/cache_operator.rb', line 82 def cache_git_modules(modules) @modules["git"]["all"] = modules.uniq cache_modules end |
#cache_modules ⇒ Object
112 113 114 115 116 |
# File 'lib/big_keeper/util/cache_operator.rb', line 112 def cache_modules file = File.new("#{@cache_path}/module.cache", 'w') file << @modules.to_json file.close end |
#cache_path_modules(modules, add_modules, del_modules) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/big_keeper/util/cache_operator.rb', line 75 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 ⇒ Object
107 108 109 110 |
# File 'lib/big_keeper/util/cache_operator.rb', line 107 def clean_modules @modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "add" => [], "del" => [], "current" => []}} cache_modules end |
#current_git_modules ⇒ Object
67 68 69 |
# File 'lib/big_keeper/util/cache_operator.rb', line 67 def current_git_modules @modules["git"]["current"] end |
#current_path_modules ⇒ Object
55 56 57 |
# File 'lib/big_keeper/util/cache_operator.rb', line 55 def current_path_modules @modules["path"]["current"] end |
#del_git_module(module_name) ⇒ Object
92 93 94 95 |
# File 'lib/big_keeper/util/cache_operator.rb', line 92 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) ⇒ Object
102 103 104 105 |
# File 'lib/big_keeper/util/cache_operator.rb', line 102 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 ⇒ Object
51 52 53 |
# File 'lib/big_keeper/util/cache_operator.rb', line 51 def del_path_modules @modules["path"]["del"] end |
#remain_git_modules ⇒ Object
71 72 73 |
# File 'lib/big_keeper/util/cache_operator.rb', line 71 def remain_git_modules @modules["git"]["all"] - @modules["git"]["current"] end |
#remain_path_modules ⇒ Object
59 60 61 |
# File 'lib/big_keeper/util/cache_operator.rb', line 59 def remain_path_modules @modules["path"]["all"] - @modules["path"]["current"] end |