Class: MGit::Manifest::CacheManager
- Inherits:
-
Object
- Object
- MGit::Manifest::CacheManager
- Defined in:
- lib/m-git/manifest/cache_manager.rb
Instance Attribute Summary collapse
-
#hash_data ⇒ Object
readonly
Returns the value of attribute hash_data.
-
#hash_sha1 ⇒ Object
readonly
Returns the value of attribute hash_sha1.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#hash_data ⇒ Object (readonly)
Returns the value of attribute hash_data.
8 9 10 |
# File 'lib/m-git/manifest/cache_manager.rb', line 8 def hash_data @hash_data end |
#hash_sha1 ⇒ Object (readonly)
Returns the value of attribute hash_sha1.
7 8 9 |
# File 'lib/m-git/manifest/cache_manager.rb', line 7 def hash_sha1 @hash_sha1 end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/m-git/manifest/cache_manager.rb', line 6 def path @path end |
Class Method Details
.save_to_cache(cache_path, hash_sha1, hash_data) ⇒ Object
缓存配置文件
31 32 33 34 35 36 37 38 39 |
# File 'lib/m-git/manifest/cache_manager.rb', line 31 def self.save_to_cache(cache_path, hash_sha1, hash_data) FileUtils.mkdir_p(File.dirname(cache_path)) File.open(cache_path, 'w') do |file| file.write({ Constants::CONFIG_CACHE_KEY[:hash] => hash_sha1, Constants::CONFIG_CACHE_KEY[:cache] => hash_data }.to_json) end end |
Instance Method Details
#load_path(cache_path) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/m-git/manifest/cache_manager.rb', line 10 def load_path(cache_path) return unless File.exist?(cache_path) begin cache = JSON.parse(File.read(cache_path)) rescue => _ Output.("配置文件缓存解析失败!将根据原配置文件进行仓库配置。") end @path = cache_path @hash_sha1 = cache[Constants::CONFIG_CACHE_KEY[:hash]] @hash_data = cache[Constants::CONFIG_CACHE_KEY[:cache]] end |