Sha256: b330ec60d015c283f259aec89120a39298bca65dec4e2119769a0874899ba447
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'tmpdir' module Luruju class JudeApiLoader def self.wrap_load_default_option jude_file, options={} default = {:copy => :if_locked} yield jude_file, default.merge(options) end def self.wrap_load_for_tmpdir jude_file, options={} do_jude_file = options[:copy] == :first ? copy_jude_file(jude_file, options) : jude_file yield do_jude_file, options rescue ProjectLockedException raise $! if do_jude_file != jude_file or options[:copy] != :if_locked or options[:retried] do_jude_file = copy_jude_file jude_file, options load do_jude_file, options.update(:retried => true) ensure FileUtils.remove_entry(File.dirname(do_jude_file), :force => true) if do_jude_file != jude_file end @@tmpdir_no = 0 protected def self.copy_jude_file jude_file, options @@tmpdir_no += 1 tmpdir = options[:tmpdir] || Dir.tmpdir FileUtils.makedirs(tmpdir) unless FileTest.exist? tmpdir current_tmpdir = FileUtils.makedirs File.join(tmpdir,"luruju.#{$$}.#{@@tmpdir_no}") copy_jude_file = File.join current_tmpdir, File.basename(jude_file) FileUtils.cp jude_file, copy_jude_file copy_jude_file end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
luruju-0.2.0 | lib/luruju/jude_api_loader_for_locked_project.rb |