Class: GM::LockfileCSJM

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-byte-csjm/gm.rb

Overview

lock文件读写

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ LockfileCSJM

Returns a new instance of LockfileCSJM.



26
27
28
# File 'lib/cocoapods-byte-csjm/gm.rb', line 26

def initialize(hash)
  @internal_data = hash
end

Class Method Details

.read_from_path(path) ⇒ Object

读取lock文件

Parameters:

  • 文件路径


32
33
34
35
36
37
# File 'lib/cocoapods-byte-csjm/gm.rb', line 32

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文件



39
40
41
42
43
44
45
46
47
48
# File 'lib/cocoapods-byte-csjm/gm.rb', line 39

def write_to_disk(path)
  begin
    is_exist, existing = LockfileCSJM.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