lib/imgurr/command.rb
# Public: Capture and image and upload to imgur
#
# Note: Only supported on OS X for now
# Returns nothing
Capture and image and upload to imgur
Note: Only supported on OS X for now
Returns nothing
Capture and image and upload to imgur Note : Only supported on OS X for now Returns nothing
def capture
        unless Platform.darwin?
          puts "Capture command is only supported on OS X for the time being."
          return
        end
        image_path = "#{ENV['HOME']}/.imgurr.temp.png"
        Platform.capture('-W', image_path)
        3.times do
          if File.exist?(image_path)
            puts "Uploading screenshot..."
            upload(image_path)
            File.delete(image_path)
            break
          end
          sleep(1)
        end
      end
def capture unless Platform . darwin? puts "Capture command is only supported on OS X for the time being." return end image_path = "#{ENV['HOME']}/.imgurr.temp.png" Platform . capture ( '-W' , image_path ) 3 . times do if File . exist? ( image_path ) puts "Uploading screenshot..." upload ( image_path ) File . delete ( image_path ) break end sleep ( 1 ) end end
Public: Capture and image and upload to imgur
Note: Only supported on OS X for now
Returns nothing
Public : Capture and image and upload to imgur Note : Only supported on OS X for now Returns nothing
# User might have canceled or it takes some time to write to disk. # Check up to 3 times with 1 sec delay