Sha256: 5d2b5cfb956a5b5879f1dde93f0a81a2425dad864c1a7074440cc390eeb0ab51

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

require 'deliver'
require 'fastimage'

module Frameit
  class Runner
    def initialize
      converter = FrameConverter.new
      if converter.frames_exist?
        # Just make sure, the PSD files are converted to PNG
        converter.convert_frames
      else
        # First run
        converter.run
      end
    end

    def run(path, color = nil)
      unless color
        color = Frameit::Color::BLACK
        color = Frameit::Color::SILVER if Frameit.config[:white] || Frameit.config[:silver]
      end

      screenshots = Dir.glob("#{path}/**/*.{png,PNG}").uniq # uniq because thanks to {png,PNG} there are duplicates

      if screenshots.count > 0
        screenshots.each do |full_path|
          next if full_path.include? "_framed.png"
          next if full_path.include? ".itmsp/" # a package file, we don't want to modify that
          next if full_path.include? "device_frames/" # these are the device frames the user is using
          next if full_path.downcase.include? "watch" # we don't care about watches right now

          begin
            screenshot = Screenshot.new(full_path, color)
            screenshot.frame!
          rescue => ex
            UI.error ex.to_s
            UI.error "Backtrace:\n\t#{ex.backtrace.join("\n\t")}" if $verbose
          end
        end
      else
        UI.error "Could not find screenshots"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
frameit-2.8.0 lib/frameit/runner.rb
frameit-2.7.0 lib/frameit/runner.rb
frameit-2.6.2 lib/frameit/runner.rb