Class: Jasmine::Headless::TemplateWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/jasmine/headless/template_writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner) ⇒ TemplateWriter

Returns a new instance of TemplateWriter.



9
10
11
# File 'lib/jasmine/headless/template_writer.rb', line 9

def initialize(runner)
  @runner = runner
end

Instance Attribute Details

#runnerObject (readonly)

Returns the value of attribute runner.



7
8
9
# File 'lib/jasmine/headless/template_writer.rb', line 7

def runner
  @runner
end

Instance Method Details

#all_tests_filenameObject



27
28
29
# File 'lib/jasmine/headless/template_writer.rb', line 27

def all_tests_filename
  runner.runner_filename || "jhw.#{$$}.html"
end

#filtered_tests_filenameObject



31
32
33
# File 'lib/jasmine/headless/template_writer.rb', line 31

def filtered_tests_filename
  all_tests_filename.gsub(%r{\.html$}, '.filter.html')
end

#write!(files_list) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jasmine/headless/template_writer.rb', line 13

def write!(files_list)
  output = [
    [ all_tests_filename, files_list.files_to_html ]
  ]

  output.unshift([filtered_tests_filename , files_list.filtered_files_to_html ]) if files_list.filtered?

  output.each do |name, files|
    File.open(name, 'w') { |fh| fh.print template_for(files, files_list.spec_file_line_numbers) }
  end

  output.collect(&:first)
end