Sha256: 9c9aad4eb735c21947b189e0752347ad776be11ff2e75cf6e4d361a34c976982
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true require 'pathname' require 'tmpdir' require 'mnogootex/utils' module Mnogootex module Job class Porter attr_reader :hid def initialize(hid:, source_path:, work_path: nil) @source_path = Pathname.new(source_path).realpath @work_path = calc_work_path(work_path).tap(&:mkpath).realpath @hid = hid end def target_dir @target_dir ||= @work_path.join(hid) end def target_path @target_path ||= target_dir.join(@source_path.basename) end def clobber target_dir.rmtree if target_dir.directory? end def provide target_dir.mkpath providable_files = @source_path.dirname.children providable_files.reject!(&@work_path.method(:==)) FileUtils.cp_r providable_files, target_dir target_dir.join('.mnogootex.yml').tap { |p| p.delete if p.file? } target_dir.join('.mnogootex.src').make_symlink(@source_path) end private def calc_work_path(path) return Pathname.new(path) unless path.nil? Pathname.new(Dir.tmpdir).join('mnogootex', source_id) end def source_id @source_id ||= Utils.short_md5(@source_path.to_s) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mnogootex-1.1.0 | lib/mnogootex/job/porter.rb |