class Snapshot::ScreenshotRotate
This class takes care of rotating images
Public Instance Methods
rotate(path)
click to toggle source
# File lib/snapshot/screenshot_rotate.rb, line 12 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
run(path)
click to toggle source
@param (String) The path in which the screenshots are located in
# File lib/snapshot/screenshot_rotate.rb, line 7 def run(path) UI.verbose "Rotating the screenshots (if necessary)" rotate(path) end