Sha256: a5d28cc2b57893ebf4e51236c8e5b2c4e858490f57d13ce0f83754e902ca786c

Contents?: true

Size: 1.13 KB

Versions: 152

Compression:

Stored size: 1.13 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

        next unless command

        # Only rotate if we need to
        FastlaneCore::FastlanePty.spawn(command) do |command_stdout, command_stdin, pid|
          command_stdout.sync
          command_stdout.each do |line|
            # We need to read this otherwise things hang
          end
          ::Process.wait(pid)
        end
      end
    end
  end
end

Version data entries

152 entries across 152 versions & 1 rubygems

Version Path
fastlane-2.105.2 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.105.1 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.104.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.103.1 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.103.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.102.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.101.1 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.101.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.100.1 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.100.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.99.1 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.99.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.98.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.97.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.96.1 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.96.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.96.0.beta.20180521050117 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.96.0.beta.20180520050019 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.96.0.beta.20180519050103 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.96.0.beta.20180518050116 snapshot/lib/snapshot/screenshot_rotate.rb