Class: FastlaneFlutterFlavor::StatusManager

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/ann_flutter_flavor/helper/utils_status.rb

Overview


StatusManager (Helper Class)


Instance Method Summary collapse

Constructor Details

#initialize(lane:) ⇒ StatusManager

Returns a new instance of StatusManager.



17
18
19
20
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_status.rb', line 17

def initialize(lane:)
  @status = Hash.new
  @lane = lane
end

Instance Method Details

#amber(text) ⇒ Object



24
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_status.rb', line 24

def amber(text) ; "\e[33m#{text}\e[0m" ; end

#displayStatusObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_status.rb', line 67

def displayStatus()
  errMsg = ""
  message = "\n"
  message += "+-------------------+-------------------------------+-------------------------------+----------------+\n"
  message += "|                           #{green('Annai Fastlane summary')}                                       |\n"
  message += "+-------------------+-------------------------------+-------------------------------+----------------+\n"

  message += "| Flavor            | Variant                       | Lane                          | Status         |\n"
  message += "+-------------------+-------------------------------+-------------------------------+----------------+\n"

  @status.each { |key,value|
    flavor = key[0].to_s
    laneName = key[1].to_s
    variantName = key[2].to_s
    statusStr = value[0]
    statusMessage = value[1]

    if statusStr == 'info'
      sts = green("Success".ljust(15))
    elsif statusStr == 'warn'
      sts = amber("Warning".ljust(15))
      if errMsg != "" then
        errMsg += "\n"
      end
      errMsg += "Flavor - #{flavor} : "
      errMsg += "#{statusMessage}"
    else
      sts = red("Failure".ljust(15))
      if errMsg != "" then
        errMsg += "\n"
      end
      errMsg += "Flavor - #{flavor} : "
      errMsg += "#{statusMessage}"
    end
    message += "| #{flavor.ljust(18)}| #{variantName.ljust(30)}| #{laneName.ljust(30)}| #{sts}|\n"
  }
  message += "+-------------------+-------------------------------+-------------------------------+----------------+"

  if errMsg != "" then
    Fastlane::UI.message("Summary of all the Errors/Warnings")
    Fastlane::UI.error(errMsg)
    # Mailgun calls removed, assuming external communication is handled outside the core action
  else
    # Mailgun calls removed
  end
  Fastlane::UI.message(message)
end

#green(text) ⇒ Object



23
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_status.rb', line 23

def green(text) ; "\e[32m#{text}\e[0m" ; end

#logError(flavor, laneName, variant, message) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_status.rb', line 26

def logError(flavor, laneName, variant, message)
  key = [flavor, laneName, variant]

  errorPresent = false
  if @status.key?(key)
    errorPresent = @status[key][0] == "err"
  end

  if errorPresent
    message = "#{@status[key][1]}\n#{message}"
  end

  @status[key] = ["err", message]
end

#logSuccess(flavor, laneName, variant) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_status.rb', line 54

def logSuccess(flavor, laneName, variant)
  key = [flavor, laneName, variant]

  errorPresent = false
  if @status.key?(key)
    errorPresent = @status[key][0] == "err" || @status[key][0] == "warn"
  end

  unless errorPresent
    @status[key] = ["info", ""]
  end
end

#logWarning(flavor, laneName, variant, message) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_status.rb', line 41

def logWarning(flavor, laneName, variant, message)
  key = [flavor, laneName, variant]

  errorPresent = false
  if @status.key?(key)
    errorPresent = @status[key][0] == "err"
  end

  unless errorPresent
    @status[key] = ["warn", message]
  end
end

#red(text) ⇒ Object



22
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_status.rb', line 22

def red(text) ; "\e[31m#{text}\e[0m" ; end