Sha256: 08e5bef33022fc9aa306a01f384180987bce2a9374112bd434887ac452f25175

Contents?: true

Size: 1.82 KB

Versions: 154

Compression:

Stored size: 1.82 KB

Contents

require 'fastimage'

require_relative 'frame_downloader'
require_relative 'module'
require_relative 'screenshot'
require_relative 'device_types'

module Frameit
  class Runner
    def initialize
      downloader = FrameDownloader.new
      unless downloader.frames_exist?
        downloader.download_frames
      end
    end

    def run(path, color = nil)
      unless color
        color = Frameit::Color::BLACK
        color = Frameit::Color::SILVER if Frameit.config[:white] || Frameit.config[:silver]
        color = Frameit::Color::GOLD if Frameit.config[:gold]
        color = Frameit::Color::ROSE_GOLD if Frameit.config[:rose_gold]
      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
          device = full_path.rpartition('/').last.partition('-').first # extract device name
          if device.downcase.include?("watch")
            UI.error("Apple Watch screenshots are not framed: '#{full_path}'")
            next # we don't care about watches right now
          end

          UI.message("Framing screenshot '#{full_path}'")

          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 FastlaneCore::Globals.verbose?
          end
        end
      else
        UI.error("Could not find screenshots in current directory: '#{File.expand_path(path)}'")
      end
    end
  end
end

Version data entries

154 entries across 154 versions & 1 rubygems

Version Path
fastlane-2.96.0.beta.20180515050025 frameit/lib/frameit/runner.rb
fastlane-2.96.0.beta.20180514050029 frameit/lib/frameit/runner.rb
fastlane-2.96.0.beta.20180513050015 frameit/lib/frameit/runner.rb
fastlane-2.96.0.beta.20180512050121 frameit/lib/frameit/runner.rb
fastlane-2.96.0.beta.20180511050050 frameit/lib/frameit/runner.rb
fastlane-2.96.0.beta.20180510050112 frameit/lib/frameit/runner.rb
fastlane-2.95.0 frameit/lib/frameit/runner.rb
fastlane-2.95.0.beta.20180509050014 frameit/lib/frameit/runner.rb
fastlane-2.95.0.beta.20180508050130 frameit/lib/frameit/runner.rb
fastlane-2.95.0.beta.20180507050125 frameit/lib/frameit/runner.rb
fastlane-2.95.0.beta.20180506050030 frameit/lib/frameit/runner.rb
fastlane-2.95.0.beta.20180505050019 frameit/lib/frameit/runner.rb
fastlane-2.95.0.beta.20180504050050 frameit/lib/frameit/runner.rb
fastlane-2.95.0.beta.20180503050136 frameit/lib/frameit/runner.rb
fastlane-2.95.0.beta.20180502050125 frameit/lib/frameit/runner.rb
fastlane-2.94.0 frameit/lib/frameit/runner.rb
fastlane-2.94.0.beta.20180501050030 frameit/lib/frameit/runner.rb
fastlane-2.94.0.beta.20180430050033 frameit/lib/frameit/runner.rb
fastlane-2.94.0.beta.20180429050039 frameit/lib/frameit/runner.rb
fastlane-2.94.0.beta.20180428050023 frameit/lib/frameit/runner.rb