Class: Testrus::Input::File
- Inherits:
-
Object
- Object
- Testrus::Input::File
- Defined in:
- lib/testrus/input/file.rb
Instance Method Summary collapse
-
#initialize(context = {}) ⇒ File
constructor
Public: Create a new Input::File object to handle file sources for input and output.
-
#input ⇒ Object
(also: #tests)
Public: Associated the file input and output into Input objects, also caches it so we do not repeat this relatively costly operation on the file system.
-
#pwd ⇒ Object
Public: The working directory of the file input source.
Constructor Details
#initialize(context = {}) ⇒ File
Public: Create a new Input::File object to handle file sources for input and output.
context - The Hash specifying context:
:pwd - Working directory for the file source.
10 11 12 |
# File 'lib/testrus/input/file.rb', line 10 def initialize(context = {}) @context = context end |
Instance Method Details
#input ⇒ Object Also known as: tests
Public: Associated the file input and output into Input objects, also caches it so we do not repeat this relatively costly operation on the file system.
Returns an Array of Input objects.
26 27 28 29 30 31 32 |
# File 'lib/testrus/input/file.rb', line 26 def input @input ||= input_files.map do |input| Input.new input: ::File.read(input), output: ::File.read(output_from_input(input)), name: test_name_from_file_name(input) end end |
#pwd ⇒ Object
Public: The working directory of the file input source.
Returns the String of the working directory.
17 18 19 |
# File 'lib/testrus/input/file.rb', line 17 def pwd @pwd ||= @context[:pwd].nil? || @context[:pwd].empty? ? default_pwd : @context[:pwd] end |