Class: Fastlane::Actions::BrandingAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/branding/actions/branding_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



19
20
21
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 19

def self.authors
  ["Stefan Natchev"]
end

.available_optionsObject



23
24
25
26
27
28
29
30
31
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 23

def self.available_options
  [
    # FastlaneCore::ConfigItem.new(key: :your_option,
    #                         env_name: "BRANDING_YOUR_OPTION",
    #                      description: "A description of your option",
    #                         optional: false,
    #                             type: String)
  ]
end

.best_icon(ideal_width) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 39

def self.best_icon(ideal_width)
  icon_paths = Dir.glob("**/AppIcon.iconset/*.png").map(&File.method(:realpath))

  paths = icon_paths.sort_by do |path|
    png = PNG.from_file(path)
    (ideal_width - png.width).abs
  end

  if paths.empty?
    nil
  else
    paths.first
  end
end

.descriptionObject



15
16
17
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 15

def self.description
  "Add some branding to your fastlane output"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 33

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
  [:ios, :mac].include?(platform)
end

.run(params) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 6

def self.run(params)
  rows, cols = Branding::Canvas.terminal_size
  ideal_width = cols / 6
  path = best_icon(ideal_width)
   = Branding::.new(path)
  .algo = :hires
  .print
end