class Redbreast::Command::ColorGenerator
Class for generating color files
Public Class Methods
init()
click to toggle source
# File lib/redbreast/commands/color_generator.rb, line 8 def self.init new.call end
Public Instance Methods
call()
click to toggle source
# File lib/redbreast/commands/color_generator.rb, line 12 def call return if bundles.first[:outputSourcePathColors].nil? prompt.say('Generating color resources...') generate_color_sources(bundles, programming_language, app_name) success('Color resources generated!') end
Private Instance Methods
generate_color_sources(bundles, programming_language, app_name)
click to toggle source
# File lib/redbreast/commands/color_generator.rb, line 22 def generate_color_sources(bundles, programming_language, app_name) bundles.each do |bundle| color_names = pull_asset_names(bundle[:assetsSearchPath]) write_colors(color_names, bundle, programming_language, app_name) end end
pull_asset_names(assetsSearchPath)
click to toggle source
Pulling data
# File lib/redbreast/commands/color_generator.rb, line 51 def pull_asset_names(assetsSearchPath) Redbreast::Crawler::Color .color_names_uniq(assetsSearchPath) end
write_colors(color_names, bundle, programming_language, app_name)
click to toggle source
Serializing data
# File lib/redbreast/commands/color_generator.rb, line 31 def write_colors(color_names, bundle, programming_language, app_name) output_path = bundle[:outputSourcePathColors] return if output_path.to_s.empty? case programming_language.downcase when 'objc' serializer = Redbreast::Serializer::ObjC template_generator = Redbreast::TemplateGenerator::Color::ObjC when 'swift' serializer = Redbreast::Serializer::Swift template_generator = Redbreast::TemplateGenerator::Color::Swift when 'swiftui' serializer = Redbreast::Serializer::SwiftUI template_generator = Redbreast::TemplateGenerator::Color::SwiftUI end serializer.new(color_names, bundle, app_name).save(output_source_path: output_path, template_generator: template_generator.new, generate_colors: true) end