Class: CucumberTimingPresenter::HtmlTemplate
- Inherits:
-
Object
- Object
- CucumberTimingPresenter::HtmlTemplate
- Defined in:
- lib/cucumber_timing_presenter/html_template.rb
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(template_path) ⇒ HtmlTemplate
constructor
A new instance of HtmlTemplate.
- #output(filename) ⇒ Object
- #replace(to_remove, to_insert) ⇒ Object
Constructor Details
#initialize(template_path) ⇒ HtmlTemplate
Returns a new instance of HtmlTemplate.
3 4 5 6 7 8 9 10 11 |
# File 'lib/cucumber_timing_presenter/html_template.rb', line 3 def initialize template_path @content = "" File.open(template_path) do |file| while line = file.gets @content = "#{@content}#{line}" end end end |
Instance Method Details
#content ⇒ Object
24 25 26 |
# File 'lib/cucumber_timing_presenter/html_template.rb', line 24 def content @content end |
#output(filename) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cucumber_timing_presenter/html_template.rb', line 13 def output filename tmp_path = "tmp/cucumber_timing_presenter" unless File.exists? tmp_path Dir::mkdir tmp_path end File.open("tmp/cucumber_timing_presenter/#{filename}", "w") do |file| file.write @content end end |
#replace(to_remove, to_insert) ⇒ Object
28 29 30 |
# File 'lib/cucumber_timing_presenter/html_template.rb', line 28 def replace to_remove, to_insert @content = "#{@content.split(to_remove).first}#{to_insert}#{@content.split(to_remove).last}" end |