Class: CIAT::SuiteBuilder

Inherits:
Object
  • Object
show all
Includes:
IO
Defined in:
lib/ciat/suite_builder.rb

Constant Summary

Constants included from IO

IO::OUTPUT_FOLDER, IO::REPORT_FILENAME

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from IO

#read_file, #write_file

Constructor Details

#initialize(options) ⇒ SuiteBuilder

Returns a new instance of SuiteBuilder.



8
9
10
# File 'lib/ciat/suite_builder.rb', line 8

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/ciat/suite_builder.rb', line 6

def options
  @options
end

Instance Method Details

#build_feedbackObject



39
40
41
42
43
44
# File 'lib/ciat/suite_builder.rb', line 39

def build_feedback
  CIAT::Feedback::Composite.new(
      options[:feedback] || default_feedback,
      CIAT::Feedback::ReturnStatus.new
    )
end

#build_output_folderObject



16
17
18
# File 'lib/ciat/suite_builder.rb', line 16

def build_output_folder
  options[:output_folder] || OUTPUT_FOLDER
end

#build_processorsObject



12
13
14
# File 'lib/ciat/suite_builder.rb', line 12

def build_processors
  options[:processors]
end

#build_test_filesObject



20
21
22
23
24
25
26
27
28
# File 'lib/ciat/suite_builder.rb', line 20

def build_test_files
  if options[:files]
    make_test_files(options[:files])
  else  
    folder = options[:folder] || "ciat"
    pattern = options[:pattern] || "*.ciat"
    make_test_files(Dir[File.join(folder, "**", pattern)])
  end
end

#default_feedbackObject



46
47
48
49
50
51
52
# File 'lib/ciat/suite_builder.rb', line 46

def default_feedback
  counter = CIAT::Feedback::FeedbackCounter.new
  CIAT::Feedback::Composite.new(counter,
    CIAT::Feedback::StandardOutput.new(counter),
    CIAT::Feedback::HtmlFeedback.new(counter, options)
    )
end

#make_test_files(filenames) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/ciat/suite_builder.rb', line 30

def make_test_files(filenames)
  if filenames.empty?
    raise IOError.new("no test files specified")
  end
  filenames.map do |filename|
    CIAT::TestFile.new(filename, build_output_folder)
  end
end