Class: GalaxyStager
- Inherits:
-
Object
- Object
- GalaxyStager
- Defined in:
- lib/protk/galaxy_stager.rb
Instance Attribute Summary collapse
-
#staged_path ⇒ Object
Returns the value of attribute staged_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(original_path, options = {}) ⇒ GalaxyStager
constructor
A new instance of GalaxyStager.
- #replace_references(in_file, options = {}) ⇒ Object
- #restore_references(in_file) ⇒ Object
Constructor Details
#initialize(original_path, options = {}) ⇒ GalaxyStager
Returns a new instance of GalaxyStager.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/protk/galaxy_stager.rb', line 8 def initialize(original_path, = {}) = { :name => nil, :extension => '', :force_copy => false }.merge() @extension = [:extension] @original_path = Pathname.new(original_path) @wd = Dir.pwd @staged_name = [:name] || @original_path.basename @staged_base = File.join(@wd, @staged_name) @staged_path = "#{@staged_base}#{@extension}" if [:force_copy] FileUtils.copy(@original_path, @staged_path) else File.symlink(@original_path, @staged_path) end end |
Instance Attribute Details
#staged_path ⇒ Object
Returns the value of attribute staged_path.
6 7 8 |
# File 'lib/protk/galaxy_stager.rb', line 6 def staged_path @staged_path end |
Class Method Details
.replace_references(in_file, from_path, to_path) ⇒ Object
33 34 35 36 37 |
# File 'lib/protk/galaxy_stager.rb', line 33 def self.replace_references(in_file, from_path, to_path) puts "Replacing #{from_path} with #{to_path} in #{in_file}" cmd="ruby -pi -e \"gsub('#{from_path}', '#{to_path}')\" #{in_file}" %x[#{cmd}] end |
Instance Method Details
#replace_references(in_file, options = {}) ⇒ Object
23 24 25 26 27 |
# File 'lib/protk/galaxy_stager.rb', line 23 def replace_references(in_file, = {}) = { :base_only => false }.merge() replacement = [:base_only] ? @staged_base : @staged_path GalaxyStager.replace_references(in_file, @original_path, replacement) end |
#restore_references(in_file) ⇒ Object
29 30 31 |
# File 'lib/protk/galaxy_stager.rb', line 29 def restore_references(in_file) GalaxyStager.replace_references(in_file, @staged_path, @original_path) end |