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(function_name:, script: nil, script_path: nil) ⇒ Tester
constructor
A new instance of Tester.
- #test(compline) ⇒ Object
- #tester_script(compline) ⇒ Object
Constructor Details
#initialize(function_name:, script: nil, script_path: nil) ⇒ Tester
Returns a new instance of Tester.
8 9 10 11 12 |
# File 'lib/completely/tester.rb', line 8 def initialize(function_name:, script: nil, script_path: nil) @script = script @script_path = script_path @function_name = 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
14 15 16 17 18 19 20 |
# File 'lib/completely/tester.rb', line 14 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
22 23 24 25 |
# File 'lib/completely/tester.rb', line 22 def tester_script(compline) set_compline_vars compline ERB.new(template, trim_mode: '%-').result(binding) end |