Class: CarthageCacheRes::CarthageCacheResLock

Inherits:
Object
  • Object
show all
Defined in:
lib/carthage_cache_res/carthage_cache_lock.rb

Constant Summary collapse

LOCK_FILE_NAME =
"CarthageCacheRes.lock"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(build_directory) ⇒ CarthageCacheResLock

Returns a new instance of CarthageCacheResLock.



10
11
12
# File 'lib/carthage_cache_res/carthage_cache_lock.rb', line 10

def initialize(build_directory)
  @lock_file_path = File.join(build_directory, LOCK_FILE_NAME)
end

Instance Attribute Details

#lock_file_pathObject (readonly)

Returns the value of attribute lock_file_path.



8
9
10
# File 'lib/carthage_cache_res/carthage_cache_lock.rb', line 8

def lock_file_path
  @lock_file_path
end

Instance Method Details

#lock_digestObject



14
15
16
# File 'lib/carthage_cache_res/carthage_cache_lock.rb', line 14

def lock_digest
  File.read(lock_file_path).strip if File.exist?(lock_file_path)
end

#valid_digest?(digest) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/carthage_cache_res/carthage_cache_lock.rb', line 22

def valid_digest?(digest)
  lock_digest == digest
end

#write_lock_digest(digest) ⇒ Object



18
19
20
# File 'lib/carthage_cache_res/carthage_cache_lock.rb', line 18

def write_lock_digest(digest)
  File.open(lock_file_path, "w") { |f| f.write(digest) }
end