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, method_missing, other_action, output, return_value, sh, step_text

Class Method Details

.authorObject



24
25
26
# File 'lib/fastlane/actions/notification.rb', line 24

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

.available_optionsObject



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
# File 'lib/fastlane/actions/notification.rb', line 28

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),
    FastlaneCore::ConfigItem.new(key: :activate,
                                 description: "Bundle identifier of application to be opened when the notification is clicked",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :app_icon,
                                 description: "The URL of an image to display instead of the application icon (Mavericks+ only)",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :content_image,
                                 description: "The URL of an image to display attached to the notification (Mavericks+ only)",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :open,
                                 description: "URL of the resource to be opened when the notification is clicked",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :execute,
                                 description: "Shell command to run when the notification is clicked",
                                 optional: true)
  ]
end

.descriptionObject



20
21
22
# File 'lib/fastlane/actions/notification.rb', line 20

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/fastlane/actions/notification.rb', line 60

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
# File 'lib/fastlane/actions/notification.rb', line 4

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

  options = params.values
  # :message is non-optional
  message = options.delete :message
  # remove nil keys, since `notify` below does not ignore them and instead translates them into empty strings in output, which looks ugly
  options = options.select { |_, v| v }
  option_map = {
    app_icon: :appIcon,
    content_image: :contentImage
  }
  options = Hash[options.map { |k, v| [option_map.fetch(k, k), v] }]
  TerminalNotifier.notify(message, options)
end