Sha256: f8a8a7a78e8499a6076635c137e8df121b9b12e724e983cff45bea26c6e26855

Contents?: true

Size: 1015 Bytes

Versions: 477

Compression:

Stored size: 1015 Bytes

Contents

require 'shellwords'

module Snapshot
  # This class takes care of rotating images
  class ScreenshotRotate
    # @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

477 entries across 477 versions & 2 rubygems

Version Path
fastlane-2.74.0.beta.20180106010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.73.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.73.0.beta.20180105010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.73.0.beta.20180104010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.73.0.beta.20180103010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.72.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.72.0.beta.20180102010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.72.0.beta.20180101010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.72.0.beta.20171231010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.71.1 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.72.0.beta.20171230010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.72.0.beta.20171229010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.72.0.beta.20171228010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.71.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.71.0.beta.20171227010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.71.0.beta.20171226010004 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.71.0.beta.20171225010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.71.0.beta.20171224010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.71.0.beta.20171223010003 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.71.0.beta.20171222010003 snapshot/lib/snapshot/screenshot_rotate.rb