Sha256: 1e9170873dbfc2f495d0cde1adcf39feb21a01ab092b287bd92265b8fa2c71a0

Contents?: true

Size: 1011 Bytes

Versions: 480

Compression:

Stored size: 1011 Bytes

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

480 entries across 480 versions & 5 rubygems

Version Path
fastlane-2.113.0 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20190107200010 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20190106200016 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20190105200036 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20190104200013 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20190103200013 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20190102200016 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20190101200013 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181231200027 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181230200014 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181229200101 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181228200027 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181227200058 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181226200116 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181225200026 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181224200038 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181223200038 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181222200027 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181221200014 snapshot/lib/snapshot/screenshot_rotate.rb
fastlane-2.113.0.beta.20181220200101 snapshot/lib/snapshot/screenshot_rotate.rb