Class: PM::Lockfile
- Inherits:
-
Object
- Object
- PM::Lockfile
- Defined in:
- lib/cocoapods-byte-panglem-beta/tool.rb
Overview
lock文件读写
Class Method Summary collapse
-
.read_from_path(path) ⇒ Object
读取lock文件.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Lockfile
constructor
A new instance of Lockfile.
-
#write_to_disk(path) ⇒ Object
写入lock文件.
Constructor Details
#initialize(hash) ⇒ Lockfile
Returns a new instance of Lockfile.
12 13 14 |
# File 'lib/cocoapods-byte-panglem-beta/tool.rb', line 12 def initialize(hash) @internal_data = hash end |
Class Method Details
.read_from_path(path) ⇒ Object
读取lock文件
19 20 21 22 23 24 |
# File 'lib/cocoapods-byte-panglem-beta/tool.rb', line 19 def self.read_from_path(path) if File.exist?(path) return true, YAML.load_file(path) end return false, nil end |
Instance Method Details
#write_to_disk(path) ⇒ Object
写入lock文件
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cocoapods-byte-panglem-beta/tool.rb', line 27 def write_to_disk(path) begin is_exist, existing = Lockfile.read_from_path(path) return if existing == @internal_data rescue Exception end File.open(path, 'w+') do |f| YAML.dump(@internal_data,f) end end |