Sha256: dd74b1f61aaba36c71a50931716a4442fc16898879bacd6e72bef98338147188

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

module Redbreast
    module Command
      class ImageGenerator
        include Helper::Terminal
        include Helper::General
  
        def self.init
          new.call
        end
  
        def call
          prompt.say("Generating image resources...")
          generate_image_sources(bundles, programming_language)
          success("Image resources generated!")
        end
  
        private
  
        def generate_image_sources(bundles, programming_language)
            bundles.each do |bundle|
            image_names = pull_asset_names(bundle[:assetsSearchPath])
            
            write_images(image_names, bundle, programming_language)
          end
        end
  
        # Serializing data
  
        def write_images(image_names, bundle, programming_language)
          output_path = bundle[:outputSourcePath]
          return if output_path.to_s.empty?
          case programming_language.downcase
          when "objc"
            serializer = Redbreast::Serializer::ObjC
            template_generator = Redbreast::TemplateGenerator::Image::ObjC
          when "swift"
            serializer = Redbreast::Serializer::Swift
            template_generator = Redbreast::TemplateGenerator::Image::Swift
          end
          serializer.new(image_names, bundle).save(output_path, template_generator.new)
        end
  
        # Pulling data
  
        def pull_asset_names(assetsSearchPath)
            Redbreast::Crawler::Image
            .image_names_uniq(assetsSearchPath)
        end
  
      end
    end
  end
  

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redbreast-0.1.2 lib/redbreast/commands/image_generator.rb
redbreast-0.1.1 lib/redbreast/commands/image_generator.rb
redbreast-0.1.0 lib/redbreast/commands/image_generator.rb