Class: CIAT::Crate
- Inherits:
-
Object
- Object
- CIAT::Crate
- Defined in:
- lib/ciat/crate.rb
Overview
:nodoc:all
Instance Attribute Summary collapse
-
#output_folder ⇒ Object
readonly
Returns the value of attribute output_folder.
-
#stub ⇒ Object
readonly
Returns the value of attribute stub.
-
#test_file ⇒ Object
readonly
Returns the value of attribute test_file.
Instance Method Summary collapse
- #filename(*modifiers) ⇒ Object
-
#initialize(test_file, output_folder) ⇒ Crate
constructor
A new instance of Crate.
-
#process_test_file ⇒ Object
:nodoc:.
- #read_test_file ⇒ Object
-
#split_test_file ⇒ Object
:nodoc:.
Constructor Details
#initialize(test_file, output_folder) ⇒ Crate
Returns a new instance of Crate.
6 7 8 9 |
# File 'lib/ciat/crate.rb', line 6 def initialize(test_file, output_folder) @test_file = test_file @output_folder = output_folder end |
Instance Attribute Details
#output_folder ⇒ Object (readonly)
Returns the value of attribute output_folder.
4 5 6 |
# File 'lib/ciat/crate.rb', line 4 def output_folder @output_folder end |
#stub ⇒ Object (readonly)
Returns the value of attribute stub.
3 4 5 |
# File 'lib/ciat/crate.rb', line 3 def stub @stub end |
#test_file ⇒ Object (readonly)
Returns the value of attribute test_file.
2 3 4 |
# File 'lib/ciat/crate.rb', line 2 def test_file @test_file end |
Instance Method Details
#filename(*modifiers) ⇒ Object
15 16 17 |
# File 'lib/ciat/crate.rb', line 15 def filename(*modifiers) File.join(output_folder, [stub, *modifiers].compact.join("_")) end |
#process_test_file ⇒ Object
:nodoc:
23 24 25 26 27 28 29 |
# File 'lib/ciat/crate.rb', line 23 def process_test_file #:nodoc: elements = empty_elements_hash split_test_file.each do |name, contents| elements[name] = CIAT::TestElement.new(name, filename(name), contents) end elements end |
#read_test_file ⇒ Object
19 20 21 |
# File 'lib/ciat/crate.rb', line 19 def read_test_file File.readlines(test_file) end |
#split_test_file ⇒ Object
:nodoc:
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ciat/crate.rb', line 31 def split_test_file #:nodoc: tag = :description content = "" raw_elements = {} read_test_file.each do |line| if line =~ /^==== ((\w|\s)+?)\W*$/ raw_elements[tag] = content tag = $1.gsub(" ", "_").to_sym content = "" else content += line end end raw_elements[tag] = content raw_elements end |