Module: ReportBuilder

Defined in:
lib/report_builder.rb,
lib/report_builder/builder.rb

Overview

ReportBuilder Main module

Defined Under Namespace

Classes: Builder

Class Method Summary collapse

Class Method Details

.additional_cssString

Returns Report Builder additional CSS string or CSS file path or CSS file url for customizing html report

Returns:

  • (String)

    additional_css additional CSS string or CSS file path or CSS file url for customizing html report



351
352
353
# File 'lib/report_builder.rb', line 351

def self.additional_css
  options[:additional_css]
end

.additional_css=(additional_css) ⇒ Object

Set Report Builder additional CSS string or CSS file path or CSS file url for customizing html report

Example:

ReportBuilder.additional_css = 'css/style.css'

Parameters:

  • additional_css (String)

    additional CSS string or CSS file path or CSS file url for customizing html report



341
342
343
344
# File 'lib/report_builder.rb', line 341

def self.additional_css=(additional_css)
  options
  @options[:additional_css] = additional_css if additional_css.is_a? String
end

.additional_infoHash

Returns Report Builder additional info for report summary

Returns:

  • (Hash)

    additional_info additional info for report summary



236
237
238
# File 'lib/report_builder.rb', line 236

def self.additional_info
  options[:additional_info]
end

.additional_info=(additional_info) ⇒ Object

Set Report Builder additional info for report summary

Example:

ReportBuilder.additional_info = {'Environment' => 'Abc Environment', 'Browser' => 'Chrome'}

Parameters:

  • additional_info (Hash)

    additional info for report summary



226
227
228
229
# File 'lib/report_builder.rb', line 226

def self.additional_info=(additional_info)
  options
  @options[:additional_info] = additional_info if additional_info.is_a? Hash
end

.additional_jsString

Returns Report Builder additional JS string or JS file path or JS file url for customizing html report

Returns:

  • (String)

    additional_js additional JS string or JS file path or JS file url for customizing html report



374
375
376
# File 'lib/report_builder.rb', line 374

def self.additional_js
  options[:additional_js]
end

.additional_js=(additional_js) ⇒ Object

Set Report Builder additional JS string or JS file path or JS file url for customizing html report

Example:

ReportBuilder.json_report_path = 'js/script.js'

Parameters:

  • additional_js (String)

    additional JS string or JS file path or JS file url for customizing html report



364
365
366
367
# File 'lib/report_builder.rb', line 364

def self.additional_js=(additional_js)
  options
  @options[:additional_js=] = additional_js if additional_js.is_a? String
end

.build_report(more_options = {}) ⇒ Object

Build Report

Example:

options = {
  json_path:    'cucumber_sample/logs',
  report_path:  'my_test_report',
  report_types: ['retry', 'html'],
  report_title: 'My Test Results',
  include_images: true,
  voice_commands: true,
  color: 'deep-purple',
  additional_info: {'browser' => 'Chrome', 'environment' => 'Stage 5'}
}

ReportBuilder.build_report options

Parameters:

  • more_options (Hash) (defaults to: {})

    override the default and configured options.



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/report_builder.rb', line 66

def self.build_report(more_options = {})
  options
  if more_options.is_a? String
    @options[:input_path] = more_options
  elsif more_options.is_a? Hash
    @options.merge! more_options
  end
  @options[:input_path] = @options[:json_path] if @options[:json_path]
  @options[:report_types] = [@options[:report_types]] unless @options[:report_types].is_a? Array
  @options[:report_types].map!(&:to_s).map!(&:upcase)
  Builder.new.build_report
end

.colorString

Returns Report Builder report color, Ex: indigo, cyan, purple, grey, lime etc.

Returns:

  • (String)

    color report color, Ex: indigo, cyan, purple, grey, lime etc.



397
398
399
# File 'lib/report_builder.rb', line 397

def self.color
  options[:color]
end

.color=(color) ⇒ Object

Set Report Builder report color, Ex: indigo, cyan, purple, grey, lime etc.

Example:

ReportBuilder.color = 'cucumber_sample/logs'

Parameters:

  • color (String)

    report color, Ex: indigo, cyan, purple, grey, lime etc.



387
388
389
390
# File 'lib/report_builder.rb', line 387

def self.color=(color)
  options
  @options[:color] = color if color.is_a? String
end

.configure {|more_options| ... } ⇒ Object

Configure ReportBuilder

Example:

ReportBuilder.configure do |config|
  config.input_path = 'cucumber_sample/logs'
  config.report_path = 'my_test_report'
  config.report_types = [:RETRY, :HTML]
  config.report_title = 'My Test Results'
  config.include_images = true
  config.voice_commands = true
  config.additional_info = {Browser: 'Chrome', Environment: 'Stage 5'}
end

Yields:

  • (more_options)


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

def self.configure
  options
  more_options = OpenStruct.new
  yield more_options if block_given?
  @options.merge! more_options.marshal_dump
end

.html_report_pathString

Returns Report Builder html report output file path with file name without extension

Returns:

  • (String)

    html_report_path html report output file path with file name without extension



305
306
307
# File 'lib/report_builder.rb', line 305

def self.html_report_path
  options[:html_report_path] || options[:report_path]
end

.html_report_path=(html_report_path) ⇒ Object

Set Report Builder html report output file path with file name without extension

Example:

ReportBuilder.html_report_path = 'reports/report'

Parameters:

  • html_report_path (String)

    html report output file path with file name without extension



295
296
297
298
# File 'lib/report_builder.rb', line 295

def self.html_report_path=(html_report_path)
  options
  @options[:html_report_path] = html_report_path if html_report_path.is_a? String
end

.include_imagesBoolean

Returns Report Builder include or excluding embedded images

Returns:

  • (Boolean)

    include_images include or excluding embedded images



190
191
192
# File 'lib/report_builder.rb', line 190

def self.include_images
  options[:include_images]
end

.include_images=(include_images) ⇒ Object

Set Report Builder include or excluding embedded images

Example:

ReportBuilder.include_images = false

Parameters:

  • include_images (Boolean)

    include or excluding embedded images



180
181
182
183
# File 'lib/report_builder.rb', line 180

def self.include_images=(include_images)
  options
  @options[:include_images] = include_images if !!include_images == include_images
end

.input_pathString/Array/Hash

Returns Report Builder input json files path / array of json files or path / hash of json files or path

Returns:

  • (String/Array/Hash)

    input_path input json files path / array of json files or path / hash of json files or path



121
122
123
# File 'lib/report_builder.rb', line 121

def self.input_path
  options[:input_path]
end

.input_path=(input_path) ⇒ Object

Set Report Builder input json files path / array of json files or path / hash of json files or path

Example:

ReportBuilder.input_path = 'my_project/cucumber_json'

Parameters:

  • input_path (String/Array/Hash)

    input json files path / array of json files or path / hash of json files or path



111
112
113
114
# File 'lib/report_builder.rb', line 111

def self.input_path=(input_path)
  options
  @options[:input_path] = input_path
end

.json_pathString/Array/Hash

Returns Report Builder input json files path / array of json files or path / hash of json files or path

Returns:

  • (String/Array/Hash)

    json_path input json files path / array of json files or path / hash of json files or path



98
99
100
# File 'lib/report_builder.rb', line 98

def self.json_path
  options[:input_path]
end

.json_path=(json_path) ⇒ Object

Set Report Builder input json files path / array of json files or path / hash of json files or path

Example:

ReportBuilder.json_path = 'my_project/cucumber_json'

Parameters:

  • json_path (String/Array/Hash)

    input json files path / array of json files or path / hash of json files or path



88
89
90
91
# File 'lib/report_builder.rb', line 88

def self.json_path=(json_path)
  options
  @options[:input_path] = json_path
end

.json_report_pathString

Returns Report Builder json report output file path with file name without extension

Returns:

  • (String)

    json_report_path json report output file path with file name without extension



282
283
284
# File 'lib/report_builder.rb', line 282

def self.json_report_path
  options[:json_report_path] || options[:report_path]
end

.json_report_path=(json_report_path) ⇒ Object

Set Report Builder json report output file path with file name without extension

Example:

ReportBuilder.json_report_path = 'reports/report'

Parameters:

  • json_report_path (String)

    json report output file path with file name without extension



272
273
274
275
# File 'lib/report_builder.rb', line 272

def self.json_report_path=(json_report_path)
  options
  @options[:json_report_path] = json_report_path if json_report_path.is_a? String
end

.optionsObject

ReportBuilder options



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/report_builder.rb', line 11

def self.options
  @options ||= {
    input_path: Dir.pwd,
    report_types: [:html],
    report_title: 'Test Results',
    include_images: true,
    voice_commands: false,
    additional_info: {},
    report_path: 'test_report',
    color: 'brown'
  }
end

.report_pathString

Returns Report Builder reports output file path with file name without extension

Returns:

  • (String)

    report_path reports output file path with file name without extension



259
260
261
# File 'lib/report_builder.rb', line 259

def self.report_path
  options[:report_path]
end

.report_path=(report_path) ⇒ Object

Set Report Builder reports output file path with file name without extension

Example:

ReportBuilder.report_path = 'reports/report'

Parameters:

  • report_path (String)

    reports output file path with file name without extension



249
250
251
252
# File 'lib/report_builder.rb', line 249

def self.report_path=(report_path)
  options
  options[:report_path] = report_path if report_path.is_a? String
end

.report_titleString

Returns Report Builder HTML report title

Returns:

  • (String)

    report_title HTML report title



167
168
169
# File 'lib/report_builder.rb', line 167

def self.report_title
  options[:report_title]
end

.report_title=(report_title) ⇒ Object

Set Report Builder HTML report title

Example:

ReportBuilder.report_title = 'My Report'

Parameters:

  • report_title (String)

    HTML report title



157
158
159
160
# File 'lib/report_builder.rb', line 157

def self.report_title=(report_title)
  options
  @options[:report_title] = report_title if report_title.is_a? String
end

.report_typesArray

Returns Report Builder report_types :json, :html, :retry (output file types)

Returns:

  • (Array)

    report_types :json, :html, :retry (output file types)



144
145
146
# File 'lib/report_builder.rb', line 144

def self.report_types
  options[:report_types]
end

.report_types=(report_types) ⇒ Object

Set Report Builder report_types :json, :html, :retry (output file types)

Example:

ReportBuilder.report_types = [:html, :retry]

Parameters:

  • report_types (Array)

    :json, :html, :retry (output file types)



134
135
136
137
# File 'lib/report_builder.rb', line 134

def self.report_types=(report_types)
  options
  @options[:report_types] = report_types.is_a? Array ? report_types : [report_types]
end

.retry_report_pathString

Returns Report Builder retry report output file path with file name without extension

Returns:

  • (String)

    retry_report_path retry report output file path with file name without extension



328
329
330
# File 'lib/report_builder.rb', line 328

def self.retry_report_path
  options[:retry_report_path] || options[:report_path]
end

.retry_report_path=(retry_report_path) ⇒ Object

Set Report Builder retry report output file path with file name without extension

Example:

ReportBuilder.retry_report_path = 'reports/report'

Parameters:

  • retry_report_path (String)

    retry report output file path with file name without extension



318
319
320
321
# File 'lib/report_builder.rb', line 318

def self.retry_report_path=(retry_report_path)
  options
  @options[:retry_report_path] = retry_report_path if retry_report_path.is_a? String
end

.set(option, value) ⇒ Object

Set Report Builder Options

Example:

ReportBuilder.set('title', 'My Features')

Parameters:

  • option (String)
  • value (String)


426
427
428
# File 'lib/report_builder.rb', line 426

def self.set(option, value)
  set_option(option, value)
end

.set_option(option, value) ⇒ Object

Set Report Builder Options

Example:

ReportBuilder.set('title', 'My Features')

Parameters:

  • option (String)
  • value (String)


411
412
413
414
# File 'lib/report_builder.rb', line 411

def self.set_option(option, value)
  options
  @options[option.to_sym] = value
end

.voice_commandsBoolean

Returns Report Builder enable or disable voice commands

Returns:

  • (Boolean)

    voice_commands enable or disable voice commands



213
214
215
# File 'lib/report_builder.rb', line 213

def self.voice_commands
  options[:voice_commands]
end

.voice_commands=(voice_commands) ⇒ Object

Set Report Builder enable or disable voice commands

Example:

ReportBuilder.voice_commands = true

Parameters:

  • voice_commands (Boolean)

    enable or disable voice commands



203
204
205
206
# File 'lib/report_builder.rb', line 203

def self.voice_commands=(voice_commands)
  options
  @options[:voice_commands] = voice_commands if !!voice_commands == voice_commands
end