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
- #branch_name ⇒ Object
- #cache_branch_name(branch_name) ⇒ 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
- #current_path_modules_path(path) ⇒ 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.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/big_keeper/util/cache_operator.rb', line 27 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()) file.close else @modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "add" => [], "del" => [], "current" => []},"branch_name" => ""} end end |
Instance Method Details
#add_git_module(module_name) ⇒ Object
116 117 118 119 |
# File 'lib/big_keeper/util/cache_operator.rb', line 116 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
126 127 128 129 |
# File 'lib/big_keeper/util/cache_operator.rb', line 126 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
49 50 51 |
# File 'lib/big_keeper/util/cache_operator.rb', line 49 def add_path_modules @modules["path"]["add"] end |
#all_git_modules ⇒ Object
85 86 87 |
# File 'lib/big_keeper/util/cache_operator.rb', line 85 def all_git_modules @modules["git"]["all"] end |
#all_path_modules ⇒ Object
45 46 47 |
# File 'lib/big_keeper/util/cache_operator.rb', line 45 def all_path_modules @modules["path"]["all"] end |
#branch_name ⇒ Object
41 42 43 |
# File 'lib/big_keeper/util/cache_operator.rb', line 41 def branch_name @modules["branch_name"] end |
#cache_branch_name(branch_name) ⇒ Object
98 99 100 101 |
# File 'lib/big_keeper/util/cache_operator.rb', line 98 def cache_branch_name(branch_name) @modules["branch_name"] = branch_name cache_modules end |
#cache_git_modules(modules) ⇒ Object
111 112 113 114 |
# File 'lib/big_keeper/util/cache_operator.rb', line 111 def cache_git_modules(modules) @modules["git"]["all"] = modules.uniq cache_modules end |
#cache_modules ⇒ Object
142 143 144 145 146 147 |
# File 'lib/big_keeper/util/cache_operator.rb', line 142 def cache_modules file = File.new("#{@cache_path}/module.cache", 'w') p "module缓存地址:#{@cache_path}/module.cache" file << @modules.to_json file.close end |
#cache_path_modules(modules, add_modules, del_modules) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/big_keeper/util/cache_operator.rb', line 104 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
136 137 138 139 140 |
# File 'lib/big_keeper/util/cache_operator.rb', line 136 def clean_modules branch_name = @modules["branch_name"] @modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "add" => [], "del" => [], "current" => []},"branch_name" => branch_name} cache_modules end |
#current_git_modules ⇒ Object
89 90 91 |
# File 'lib/big_keeper/util/cache_operator.rb', line 89 def current_git_modules @modules["git"]["current"] end |
#current_path_modules ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/big_keeper/util/cache_operator.rb', line 68 def current_path_modules # BigkeeperParser.parse("#{@path}/Bigkeeper") # # Get modules' name # module_list = BigkeeperParser.module_names # detector = PodfileDetector.new(@path, module_list) # # Get unlocked third party pods list # current_module_list = detector.get_current_module_list # current_module_list # #@modules["path"]["current"] # # @modules["path"]["current"] end |
#current_path_modules_path(path) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/big_keeper/util/cache_operator.rb', line 57 def current_path_modules_path(path) BigkeeperParser.parse("#{path}/Bigkeeper") # Get modules' name module_list = BigkeeperParser.module_names detector = PodfileDetector.new(path, module_list) # Get unlocked third party pods list current_module_list = detector.get_current_module_list current_module_list #@modules["path"]["current"] end |
#del_git_module(module_name) ⇒ Object
121 122 123 124 |
# File 'lib/big_keeper/util/cache_operator.rb', line 121 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
131 132 133 134 |
# File 'lib/big_keeper/util/cache_operator.rb', line 131 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
53 54 55 |
# File 'lib/big_keeper/util/cache_operator.rb', line 53 def del_path_modules @modules["path"]["del"] end |
#remain_git_modules ⇒ Object
93 94 95 |
# File 'lib/big_keeper/util/cache_operator.rb', line 93 def remain_git_modules @modules["git"]["all"] - @modules["git"]["current"] end |
#remain_path_modules ⇒ Object
81 82 83 |
# File 'lib/big_keeper/util/cache_operator.rb', line 81 def remain_path_modules @modules["path"]["all"] - @modules["path"]["current"] end |