Class: Mnogootex::Job::Porter
- Inherits:
-
Object
- Object
- Mnogootex::Job::Porter
- Defined in:
- lib/mnogootex/job/porter.rb
Instance Attribute Summary collapse
-
#hid ⇒ Object
readonly
Returns the value of attribute hid.
Instance Method Summary collapse
- #clobber ⇒ Object
-
#initialize(hid:, source_path:, work_path: nil) ⇒ Porter
constructor
A new instance of Porter.
- #provide ⇒ Object
- #target_dir ⇒ Object
- #target_path ⇒ Object
Constructor Details
#initialize(hid:, source_path:, work_path: nil) ⇒ Porter
Returns a new instance of Porter.
13 14 15 16 17 |
# File 'lib/mnogootex/job/porter.rb', line 13 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 |
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
27 28 29 |
# File 'lib/mnogootex/job/porter.rb', line 27 def clobber target_dir.rmtree if target_dir.directory? end |
#provide ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/mnogootex/job/porter.rb', line 31 def provide target_dir.mkpath providable_files = @source_path.dirname.children providable_files.reject!(&@work_path.method(:==)) FileUtils.cp_r providable_files, target_dir remove_configuration(target_dir) create_link_to_source(target_dir) end |
#target_dir ⇒ Object
19 20 21 |
# File 'lib/mnogootex/job/porter.rb', line 19 def target_dir @target_dir ||= @work_path.join(hid) end |
#target_path ⇒ Object
23 24 25 |
# File 'lib/mnogootex/job/porter.rb', line 23 def target_path @target_path ||= target_dir.join(@source_path.basename) end |