Class: Completely::Tester
- Inherits:
-
Object
- Object
- Completely::Tester
- Defined in:
- lib/completely/tester.rb
Instance Attribute Summary collapse
-
#compline ⇒ Object
readonly
Returns the value of attribute compline.
-
#cword ⇒ Object
readonly
Returns the value of attribute cword.
-
#function_name ⇒ Object
readonly
Returns the value of attribute function_name.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
-
#script_path ⇒ Object
readonly
Returns the value of attribute script_path.
Instance Method Summary collapse
-
#initialize(script: nil, script_path: nil, function_name:) ⇒ Tester
constructor
A new instance of Tester.
- #test(compline) ⇒ Object
- #tester_script(compline) ⇒ Object
Constructor Details
#initialize(script: nil, script_path: nil, function_name:) ⇒ Tester
Returns a new instance of Tester.
8 9 10 |
# File 'lib/completely/tester.rb', line 8 def initialize(script: nil, script_path: nil, function_name: ) @script, @script_path, @function_name = script, script_path, function_name end |
Instance Attribute Details
#compline ⇒ Object (readonly)
Returns the value of attribute compline.
6 7 8 |
# File 'lib/completely/tester.rb', line 6 def compline @compline end |
#cword ⇒ Object (readonly)
Returns the value of attribute cword.
6 7 8 |
# File 'lib/completely/tester.rb', line 6 def cword @cword end |
#function_name ⇒ Object (readonly)
Returns the value of attribute function_name.
6 7 8 |
# File 'lib/completely/tester.rb', line 6 def function_name @function_name end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
6 7 8 |
# File 'lib/completely/tester.rb', line 6 def script @script end |
#script_path ⇒ Object (readonly)
Returns the value of attribute script_path.
6 7 8 |
# File 'lib/completely/tester.rb', line 6 def script_path @script_path end |
Instance Method Details
#test(compline) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/completely/tester.rb', line 12 def test(compline) Tempfile.create "completely-tester" do |f| f << tester_script(compline) f.flush `bash #{f.path}` end.split "\n" end |
#tester_script(compline) ⇒ Object
20 21 22 23 |
# File 'lib/completely/tester.rb', line 20 def tester_script(compline) set_compline_vars compline ERB.new(template, trim_mode: '%-').result(binding) end |