Class: Fastlane::Actions::NotificationAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/notification.rb

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, details, output, return_value, sh, step_text

Class Method Details

.authorObject



31
32
33
# File 'lib/fastlane/actions/notification.rb', line 31

def self.author
  ["champo", "cbowns", "KrauseFx", "amarcadet"]
end

.available_optionsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fastlane/actions/notification.rb', line 35

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :title,
                                 description: "The title to display in the notification",
                                 default_value: 'fastlane'),
    FastlaneCore::ConfigItem.new(key: :subtitle,
                                 description: "A subtitle to display in the notification",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :message,
                                 description: "The message to display in the notification",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :sound,
                                 description: "The name of a sound to play when the notification appears (names are listed in Sound Preferences)",
                                 optional: true)
  ]
end

.descriptionObject



27
28
29
# File 'lib/fastlane/actions/notification.rb', line 27

def self.description
  "Display a Mac OS X notification with custom message and title"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/fastlane/actions/notification.rb', line 52

def self.is_supported?(platform)
  Helper.mac?
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fastlane/actions/notification.rb', line 4

def self.run(params)
  require 'terminal-notifier'

  if params[:subtitle] && params[:sound]
    TerminalNotifier.notify(params[:message],
                            title: params[:title],
                            subtitle: params[:subtitle],
                            sound: params[:sound])
  elsif params[:subtitle]
    TerminalNotifier.notify(params[:message],
                            title: params[:title],
                            subtitle: params[:subtitle])
  elsif params[:sound]
    TerminalNotifier.notify(params[:message],
                            title: params[:title],
                            sound: params[:sound])
  else
    # It should look nice without a subtitle too
    TerminalNotifier.notify(params[:message],
                            title: params[:title])
  end
end