class Mnogootex::Job::Porter
Attributes
hid[R]
Public Class Methods
new(hid:, source_path:)
click to toggle source
# File lib/mnogootex/job/porter.rb, line 13 def initialize(hid:, source_path:) @source_path = Pathname.new(source_path).realpath @hid = hid end
Public Instance Methods
clobber()
click to toggle source
# File lib/mnogootex/job/porter.rb, line 26 def clobber target_dir.rmtree if target_dir.directory? end
provide()
click to toggle source
# File lib/mnogootex/job/porter.rb, line 30 def provide target_dir.mkpath # NOTE: can't use Pathname.join here since it elides the dot: FileUtils.cp_r File.join(@source_path.dirname, '.'), target_dir target_dir.join('.mnogootex.yml').tap { |p| p.delete if p.file? } target_dir.join('.mnogootex.src').make_symlink(@source_path) end
target_dir()
click to toggle source
# File lib/mnogootex/job/porter.rb, line 18 def target_dir @target_dir ||= Pathname.new(Dir.tmpdir).join('mnogootex', source_id, hid) end
target_path()
click to toggle source
# File lib/mnogootex/job/porter.rb, line 22 def target_path @target_path ||= target_dir.join(@source_path.basename) end
Private Instance Methods
source_id()
click to toggle source
# File lib/mnogootex/job/porter.rb, line 40 def source_id @source_id ||= Utils.short_md5(@source_path.to_s) end