class ScreenShooter::ShotMaster
Public Instance Methods
list()
click to toggle source
# File lib/screenshooter.rb, line 24 def list username, password = get_credentials client = Screenshot::Client.new({"username" => username, "password" => password}) puts client.get_os_and_browsers end
shoot(file="browsers.yaml")
click to toggle source
# File lib/screenshooter.rb, line 34 def shoot(file="browsers.yaml") username, password = get_credentials client = Screenshot::Client.new({"username" => username, "password" => password}) file_extension = file.split('.')[-1] if file_extension == 'yaml' params = YAML::load( File.open( file ) ) elsif file_extension == 'json' params = JSON.parse( File.read(file) ) end if options.has_key? "url" params["url"] = options["url"] end begin request_id = client.generate_screenshots params rescue Exception => e puts e.message end shot_status = "pending" bar = ProgressBar.new(:elapsed) begin shot_status = client.screenshots_status request_id sleep 2.5 bar.increment! end while options["wait"] and shot_status != "done" screenshots_url = "http://www.browserstack.com/screenshots/#{request_id}" if options["open"] Launchy.open(screenshots_url) else puts screenshots_url end end