Class: Mnogootex::Job::Porter
Instance Attribute Summary collapse
-
#hid ⇒ Object
readonly
Returns the value of attribute hid.
Instance Method Summary collapse
- #clobber ⇒ Object
-
#initialize(hid:, source_path:) ⇒ Porter
constructor
A new instance of Porter.
- #provide ⇒ Object
- #target_dir ⇒ Object
- #target_path ⇒ Object
Constructor Details
#initialize(hid:, source_path:) ⇒ Porter
13 14 15 16 |
# File 'lib/mnogootex/job/porter.rb', line 13 def initialize(hid:, source_path:) @source_path = Pathname.new(source_path).realpath @hid = hid end |
Instance Attribute Details
#hid ⇒ Object (readonly)
Returns the value of attribute hid.
11 12 13 |
# File 'lib/mnogootex/job/porter.rb', line 11 def hid @hid end |
Instance Method Details
#clobber ⇒ Object
26 27 28 |
# File 'lib/mnogootex/job/porter.rb', line 26 def clobber target_dir.rmtree if target_dir.directory? end |
#provide ⇒ Object
30 31 32 33 34 35 36 |
# 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 ⇒ Object
18 19 20 |
# 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 ⇒ Object
22 23 24 |
# File 'lib/mnogootex/job/porter.rb', line 22 def target_path @target_path ||= target_dir.join(@source_path.basename) end |