Class: Cucumber::Formatter::PublishBannerPrinter

Inherits:
Object
  • Object
show all
Includes:
Term::Banner
Defined in:
lib/cucumber/formatter/publish_banner_printer.rb

Instance Method Summary collapse

Methods included from Term::Banner

#display_banner

Constructor Details

#initialize(configuration) ⇒ PublishBannerPrinter

Returns a new instance of PublishBannerPrinter.


10
11
12
13
14
15
16
# File 'lib/cucumber/formatter/publish_banner_printer.rb', line 10

def initialize(configuration)
  return if configuration.publish_enabled?

  configuration.on_event :test_run_finished do |_event|
    display_publish_ad(configuration.error_stream)
  end
end

Instance Method Details

#display_publish_ad(io) ⇒ Object

rubocop:disable Metrics/MethodLength


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cucumber/formatter/publish_banner_printer.rb', line 19

def display_publish_ad(io)
  display_banner(
    [
      [
        'Share your Cucumber Report with your team at ',
        link('https://reports.cucumber.io')
      ],
      '',
      [
        'Command line option:    ',
        highlight('--publish')
      ],
      [
        'Environment variable:   ',
        highlight('CUCUMBER_PUBLISH_ENABLED'),
        '=',
        highlight('true')
      ],
      [
        'cucumber.yml:           ',
        highlight('default: --publish')
      ],
      '',
      [
        'More information at ',
        link('https://reports.cucumber.io/docs/cucumber-ruby')
      ],
      '',
      [
        'To disable this message, specify ',
        pre('CUCUMBER_PUBLISH_QUIET=true'),
        ' or use the '
      ],
      [
        pre('--publish-quiet'),
        ' option. You can also add this to your ',
        pre('cucumber.yml:')
      ],
      [pre('default: --publish-quiet')]
    ],
    io
  )
end

#highlight(text) ⇒ Object

rubocop:enable Metrics/MethodLength


64
65
66
# File 'lib/cucumber/formatter/publish_banner_printer.rb', line 64

def highlight(text)
  [text, :cyan]
end

68
69
70
# File 'lib/cucumber/formatter/publish_banner_printer.rb', line 68

def link(text)
  [text, :cyan, :bold, :underline]
end

#pre(text) ⇒ Object


72
73
74
# File 'lib/cucumber/formatter/publish_banner_printer.rb', line 72

def pre(text)
  [text, :bold]
end