From b86c8efb79b3ed835d552c4d7416640ef10caf21 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 24 Sep 2016 13:52:43 +0200 Subject: Cask: Use nested classes and modules. --- Library/Homebrew/cask/lib/hbc/utils/file.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'Library/Homebrew/cask/lib/hbc/utils') diff --git a/Library/Homebrew/cask/lib/hbc/utils/file.rb b/Library/Homebrew/cask/lib/hbc/utils/file.rb index 967c6834f..6b80f33ce 100644 --- a/Library/Homebrew/cask/lib/hbc/utils/file.rb +++ b/Library/Homebrew/cask/lib/hbc/utils/file.rb @@ -1,12 +1,14 @@ -module Hbc::Utils - module_function +module Hbc + module Utils + module_function - def file_locked?(file) - unlocked = File.open(file).flock(File::LOCK_EX | File::LOCK_NB) - # revert lock if file was unlocked before check - File.open(file).flock(File::LOCK_UN) if unlocked - !unlocked - rescue - true + def file_locked?(file) + unlocked = File.open(file).flock(File::LOCK_EX | File::LOCK_NB) + # revert lock if file was unlocked before check + File.open(file).flock(File::LOCK_UN) if unlocked + !unlocked + rescue + true + end end end -- cgit v1.2.3