class JustOneLock::World
Attributes
delete_files[RW]
directory[RW]
output[RW]
Public Class Methods
new()
click to toggle source
# File lib/just_one_lock/world.rb, line 4 def initialize @files = {} @output = $stdout @directory = '/tmp' @delete_files = true end
Public Instance Methods
after_lock(name, file)
click to toggle source
# File lib/just_one_lock/world.rb, line 30 def after_lock(name, file) delete_unlocked_files if delete_files end
before_lock(name, file)
click to toggle source
# File lib/just_one_lock/world.rb, line 26 def before_lock(name, file) @files[name] = file end
delete_unlocked_files()
click to toggle source
# File lib/just_one_lock/world.rb, line 11 def delete_unlocked_files paths_to_delete = [] @files.each do |path, f| if File.exists?(path) && f.closed? paths_to_delete << path end end paths_to_delete.each do |path| File.delete(path) @files.delete(path) end end
lock_paths()
click to toggle source
# File lib/just_one_lock/world.rb, line 34 def lock_paths @files.keys end
puts(*args)
click to toggle source
# File lib/just_one_lock/world.rb, line 38 def puts(*args) output.puts(*args) end