Sha256: f616593cf331f4167a1c9b8f4aa32b27fb3db39b0ba5267f52863c070bc25015

Contents?: true

Size: 1.04 KB

Versions: 23

Compression:

Stored size: 1.04 KB

Contents

require_relative 'module'

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

    # @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
        PTY.spawn(command) do |r, w, pid|
          r.sync
          r.each do |line|
            # We need to read this otherwise things hang
          end
          ::Process.wait(pid)
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
fastlane-2.79.0.beta.20180124010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.79.0.beta.20180123010002 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.78.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.78.0.beta.20180122010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.78.0.beta.20180121010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.78.0.beta.20180120010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.78.0.beta.20180119010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.77.1 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.77.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.77.0.beta.20180118010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.77.0.beta.20180117010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.76.1 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.76.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.76.0.beta.20180116010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.76.0.beta.20180115010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.76.0.beta.20180114010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.76.0.beta.20180113010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.76.0.beta.20180112010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.76.0.beta.20180111010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.76.0.beta.20180110010004 snapshot/lib/snapshot/screenshot_rotate.rb