Module: FlossFunding::Lockfile
- Defined in:
- lib/floss_funding/lockfile.rb
Overview
Facade to access the two lockfiles from existing call sites
:nocov:
rubocop:disable ThreadSafety/ClassInstanceVariable
NOTE: These facade methods are heavily defensive to protect production apps if
lockfile initialization fails. Forcing these error branches in tests is not
practical without stubbing core classes in ways that reduce test value. The
primary (happy) paths are exercised throughout the suite.
Class Method Summary collapse
Class Method Details
.at_exit ⇒ Object
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/floss_funding/lockfile.rb', line 350 def at_exit expected = begin root = ::FlossFunding.project_root begin root ||= Dir.pwd rescue StandardError root = nil end root ? File.join(root, ".floss_funding.ruby.at_exit.lock") : nil rescue StandardError nil end if defined?(@at_exit) && @at_exit && @at_exit.respond_to?(:path) if expected && @at_exit.path != expected @at_exit = AtExitLockfile.new end end @at_exit ||= AtExitLockfile.new rescue StandardError => e ::FlossFunding.error!(e, "Lockfile.at_exit") begin AtExitLockfile.new rescue StandardError => e2 ::FlossFunding.error!(e2, "Lockfile.at_exit/fallback") nil end end |
.on_load ⇒ Object
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/floss_funding/lockfile.rb', line 320 def on_load expected = begin root = ::FlossFunding.project_root begin root ||= Dir.pwd rescue StandardError root = nil end root ? File.join(root, ".floss_funding.ruby.on_load.lock") : nil rescue StandardError nil end if defined?(@on_load) && @on_load && @on_load.respond_to?(:path) if expected && @on_load.path != expected @on_load = OnLoadLockfile.new end end @on_load ||= OnLoadLockfile.new rescue StandardError => e ::FlossFunding.error!(e, "Lockfile.on_load") begin OnLoadLockfile.new rescue StandardError => e2 ::FlossFunding.error!(e2, "Lockfile.on_load/fallback") nil end end |