Sha256: f7ee0248e7adcc47c3b208cb12040b3fc704737ad7065c7c710dd40087381fb0

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

module Nakal
  module Ios
    class Screen < Common::BaseScreen

      private

      def capture_script
        xcode_7 = !(%x(instruments -s devices ; echo)).match(' Simulator\)')
        simulator_app_name = xcode_7 ? "Simulator" : "iOS Simulator"
        "osascript <<EOF
        tell application \"#{simulator_app_name}\"
        activate
        delay 0.5
        tell application \"System Events\" to keystroke \"1\" using {command down}
        delay 0.5
        tell application \"System Events\" to keystroke \"s\" using {command down}
        end tell
        EOF"
      end


      def capture
        `#{capture_script}`
        sleep 1
        Dir.glob(File.expand_path('~/Desktop/iOS\\ Simulator\\ Screen\\ Shot - Apple\\ Watch*')).each { |f| FileUtils.rm(f) }
        latest_file = Dir.glob(File.expand_path('~/Desktop/iOS\\ Simulator\\ Screen\\ Shot*')).max_by { |f| File.mtime(f) }
        File.rename(latest_file, "#{Nakal.image_location}/#{@name}.png")
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nakal-1.0.3 lib/nakal/ios/screen.rb