Class: DiscourseEmojis::FluentUIEmojiProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/discourse_emojis/fluentui_emoji_processor.rb

Constant Summary collapse

SKIN_TONE_LEVELS =

The FluentUIEmojiProcessor class processes Fluent UI emoji assets and converts them into PNG format for use in the application. It supports both regular and skin-tone variations of emojis.

Constants:

  • SKIN_TONE_LEVELS: A mapping of skin tone names to numerical levels used for file naming.

  • OUTPUT_DIR: The directory where processed PNG files will be saved.

Usage: To process all Fluent UI emojis from an assets directory, instantiate the class and call the ‘process_all` method:

processor = DiscourseEmojis::FluentUIEmojiProcessor.new(assets_dir, supported_emojis) processor.process_all

Parameters:

  • assets_dir: The directory containing Fluent UI emoji assets.

  • supported_emojis: A mapping of supported emoji names.

This method will iterate over each emoji asset, check if it has skin-tone variations, and convert the SVG files into properly formatted PNG images.

{
  "Light" => 2,
  "Medium-Light" => 3,
  "Medium" => 4,
  "Medium-Dark" => 5,
  "Dark" => 6,
}
OUTPUT_DIR =
"dist/emoji/fluentui"

Instance Method Summary collapse

Constructor Details

#initialize(assets_dir, supported_emojis) ⇒ FluentUIEmojiProcessor

Returns a new instance of FluentUIEmojiProcessor.



40
41
42
43
# File 'lib/discourse_emojis/fluentui_emoji_processor.rb', line 40

def initialize(assets_dir, supported_emojis)
  @assets_dir = assets_dir
  @supported_emojis = supported_emojis
end

Instance Method Details

#process_allObject



45
46
47
# File 'lib/discourse_emojis/fluentui_emoji_processor.rb', line 45

def process_all
  Dir.glob(File.join(@assets_dir, "*")).each { |emoji_dir| process_emoji(emoji_dir) }
end