Sha256: 687b0c8297868602fba74136e466f64a14695ced4795851c1a0b0be9dcb0db1b

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require_relative 'module'
require 'fastlane_core/fastlane_pty'

module Snapshot
  # This class takes care of rotating images
  class ScreenshotRotate
    require 'shellwords'

    # @param (String) The path in which the screenshots are located in
    def run(path)
      UI.verbose("Rotating the screenshots (if necessary)")
      rotate(path)
    end

    def rotate(path)
      Dir.glob([path, '/**/*.png'].join('/')).each do |file|
        UI.verbose("Rotating '#{file}'")

        command = nil
        if file.end_with?("landscapeleft.png")
          command = "sips -r -90 '#{file}'"
        elsif file.end_with?("landscaperight.png")
          command = "sips -r 90 '#{file}'"
        elsif file.end_with?("portrait_upsidedown.png")
          command = "sips -r 180 '#{file}'"
        end

        # Only rotate if we need to
        next unless command

        # Rotate
        FastlaneCore::CommandExecutor.execute(command: command, print_all: false, print_command: false)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fastlane_hotfix-2.165.1 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane_hotfix-2.165.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane_hotfix-2.187.0 snapshot/lib/snapshot/screenshot_rotate.rb