Class: Fastlane::Actions::BrandingAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::BrandingAction
- Defined in:
- lib/fastlane/plugin/branding/actions/branding_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .best_icon(brand_icon_path, ideal_width) ⇒ Object
- .description ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
22 23 24 |
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 22 def self. ["Stefan Natchev"] end |
.available_options ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 26 def self. [ FastlaneCore::ConfigItem.new(key: :brand_icon_path, env_name: "BRAND_ICON_PATH", description: "specific path to icon", optional: true, type: String) ] end |
.best_icon(brand_icon_path, ideal_width) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 42 def self.best_icon(brand_icon_path, ideal_width) icon_paths = Dir.glob(brand_icon_path || "**/AppIcon.appiconset/*.png").map(&File.method(:realpath)) paths = icon_paths.filter do |path| begin png = ::Branding::PNG.from_file(path) true rescue NotImplementedError => err false end end paths = paths.sort_by do |path| png = ::Branding::PNG.from_file(path) (ideal_width - png.width).abs end if paths.empty? puts "No branding image found. Only true color is supported at the moment, so check the color depth of your images and try again." nil else paths.first end end |
.description ⇒ Object
18 19 20 |
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 18 def self.description "Add some branding to your fastlane output" end |
.is_supported?(platform) ⇒ Boolean
36 37 38 39 40 |
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 36 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, :android].include?(platform) end |
.run(params) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fastlane/plugin/branding/actions/branding_action.rb', line 6 def self.run(params) rows, cols = ::Branding::Canvas.terminal_size ideal_width = cols / 3 if path = best_icon(params[:brand_icon_path], ideal_width) logo = ::Branding::Logo.new(path) logo.algo = :normal logo.print puts "\e[0m" end end |