Class: CucumberCharacteristics::Exporter
- Inherits:
-
Object
- Object
- CucumberCharacteristics::Exporter
- Defined in:
- lib/cucumber_characteristics/exporter.rb
Instance Attribute Summary collapse
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
Instance Method Summary collapse
- #export ⇒ Object
- #format_step_usage(step_feature_data) ⇒ Object
-
#format_ts(t) ⇒ Object
HELPERS.
-
#initialize(profile) ⇒ Exporter
constructor
A new instance of Exporter.
- #step_status_summary(profile) ⇒ Object
- #to_html ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(profile) ⇒ Exporter
Returns a new instance of Exporter.
7 8 9 10 |
# File 'lib/cucumber_characteristics/exporter.rb', line 7 def initialize(profile) @profile = profile @config = CucumberCharacteristics.configuration end |
Instance Attribute Details
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
6 7 8 |
# File 'lib/cucumber_characteristics/exporter.rb', line 6 def profile @profile end |
Instance Method Details
#export ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cucumber_characteristics/exporter.rb', line 12 def export filename = @config.full_target_filename if @config.export_html File.open(filename + '.html', 'w') { |file| file.write(to_html) } puts "Step characteristics report written to #{filename}.html" end if @config.export_json File.open(filename + '.json', 'w') { |file| file.write(to_json) } puts "Step characteristics report written to #{filename}.json" end end |
#format_step_usage(step_feature_data) ⇒ Object
40 41 42 43 44 |
# File 'lib/cucumber_characteristics/exporter.rb', line 40 def format_step_usage(step_feature_data) step_feature_data[:feature_location].map do |location, timings| location.to_s + (timings.count > 1 ? " (x#{timings.count})" : '') end.join("\n") end |
#format_ts(t) ⇒ Object
HELPERS
36 37 38 |
# File 'lib/cucumber_characteristics/exporter.rb', line 36 def format_ts(t) t ? format("%0.#{@config.precision}f", t) : '-' end |
#step_status_summary(profile) ⇒ Object
46 47 48 49 |
# File 'lib/cucumber_characteristics/exporter.rb', line 46 def step_status_summary(profile) status = profile.step_count_by_status status.keys.sort.map { |s| status[s] > 0 ? "#{s.capitalize}: #{status[s]}" : nil }.compact.join(', ') end |
#to_html ⇒ Object
24 25 26 27 28 |
# File 'lib/cucumber_characteristics/exporter.rb', line 24 def to_html template = File.read(File.('../view/step_report.html.haml', __FILE__)) haml_engine = Haml::Engine.new(template) haml_engine.render(self) end |
#to_json ⇒ Object
30 31 32 |
# File 'lib/cucumber_characteristics/exporter.rb', line 30 def to_json @profile.step_profiles.to_json end |