Class: Testrus::Input::File

Inherits:
Object
  • Object
show all
Defined in:
lib/testrus/input/file.rb

Instance Method Summary collapse

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

#inputObject 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

#pwdObject

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