Class: CarthageCacheRes::CarthageCacheResLock
- Inherits:
-
Object
- Object
- CarthageCacheRes::CarthageCacheResLock
- Defined in:
- lib/carthage_cache_res/carthage_cache_lock.rb
Constant Summary collapse
- LOCK_FILE_NAME =
"CarthageCacheRes.lock"
Instance Attribute Summary collapse
-
#lock_file_path ⇒ Object
readonly
Returns the value of attribute lock_file_path.
Instance Method Summary collapse
-
#initialize(build_directory) ⇒ CarthageCacheResLock
constructor
A new instance of CarthageCacheResLock.
- #lock_digest ⇒ Object
- #valid_digest?(digest) ⇒ Boolean
- #write_lock_digest(digest) ⇒ Object
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_path ⇒ Object (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_digest ⇒ Object
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
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 |