Class: Rspec::Bash::BashWrapper
- Inherits:
-
Object
- Object
- Rspec::Bash::BashWrapper
- Defined in:
- lib/rspec/bash/wrapper/bash_wrapper.rb
Instance Method Summary collapse
- #add_override(override) ⇒ Object
- #cleanup ⇒ Object
-
#initialize(port) ⇒ BashWrapper
constructor
A new instance of BashWrapper.
- #remove_file_system_path(path) ⇒ Object
- #stderr_output_path ⇒ Object
- #wrap_script(script) ⇒ Object
- #wrapper_input_path ⇒ Object
- #wrapper_output_path ⇒ Object
Constructor Details
#initialize(port) ⇒ BashWrapper
Returns a new instance of BashWrapper.
4 5 6 7 8 |
# File 'lib/rspec/bash/wrapper/bash_wrapper.rb', line 4 def initialize(port) @port = port @override_list = [] at_exit { cleanup } end |
Instance Method Details
#add_override(override) ⇒ Object
41 42 43 |
# File 'lib/rspec/bash/wrapper/bash_wrapper.rb', line 41 def add_override(override) @override_list << override end |
#cleanup ⇒ Object
32 33 34 35 |
# File 'lib/rspec/bash/wrapper/bash_wrapper.rb', line 32 def cleanup remove_file_system_path wrapper_output_path remove_file_system_path stderr_output_path end |
#remove_file_system_path(path) ⇒ Object
37 38 39 |
# File 'lib/rspec/bash/wrapper/bash_wrapper.rb', line 37 def remove_file_system_path(path) FileUtils.remove_entry_secure(path) if Pathname.new(path).exist? end |
#stderr_output_path ⇒ Object
28 29 30 |
# File 'lib/rspec/bash/wrapper/bash_wrapper.rb', line 28 def stderr_output_path File.join(Dir.tmpdir, "stderr-#{@port}.tmp") end |
#wrap_script(script) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/rspec/bash/wrapper/bash_wrapper.rb', line 10 def wrap_script(script) wrapper_template = ERB.new(File.new(wrapper_input_path).read, nil, '%') File.open(wrapper_output_path, 'w') do |file| file.write(wrapper_template.result(binding)) end File.chmod(0755, wrapper_output_path) wrapper_output_path end |
#wrapper_input_path ⇒ Object
20 21 22 |
# File 'lib/rspec/bash/wrapper/bash_wrapper.rb', line 20 def wrapper_input_path File.join(project_root, 'bin', 'bash_wrapper.sh.erb') end |
#wrapper_output_path ⇒ Object
24 25 26 |
# File 'lib/rspec/bash/wrapper/bash_wrapper.rb', line 24 def wrapper_output_path File.join(Dir.tmpdir, "wrapper-#{@port}.sh") end |