Class: Fastlane::Helper::BombEmojiHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/bomb_emoji/helper/bomb_emoji_helper.rb

Defined Under Namespace

Modules: Shell

Constant Summary collapse

@@emojis_removed =
0
@@emoji_lines_cleaned =
[]

Class Method Summary collapse

Class Method Details

.bomb(arg) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fastlane/plugin/bomb_emoji/helper/bomb_emoji_helper.rb', line 12

def self.bomb(arg)
  # Only bomb if we want to bomb
  return arg unless ENV['BOMB_EMOJI_ENABLED']

  # Don't bomb a table
  return arg if arg.kind_of?(Terminal::Table)

  # Only bomb a string
  return arg unless arg.kind_of?(String)

  # Don't bomb a separator
  return arg if arg.start_with?("---")

  # Bomb the rest
  clean = arg.to_s.gsub(EmojiRegex::Regex, "").to_s

  count = arg.to_s.size - clean.size
  @@emojis_removed += count
  @@emoji_lines_cleaned << arg if count > 0

  if clean.start_with?("fastlane.tools finished successfully") || clean.start_with?("fastlane.tools just saved you") || clean.start_with?("fastlane finished with errors")
    clean += "\nfastlane-plugin-bomb_emoji saved you #{@@emojis_removed} emoji"
    @@emoji_lines_cleaned.each do |line|
      clean += "\n\t#{line}"
    end if FastlaneCore::Globals.verbose?
  end

  return clean
end