Module: Selenium::WebDriver::ProfileHelper::ClassMethods
- Defined in:
- lib/selenium/webdriver/common/profile_helper.rb
Instance Method Summary collapse
Instance Method Details
#from_json(json) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/selenium/webdriver/common/profile_helper.rb', line 48 def from_json(json) data = JSON.parse(json).fetch('zip') # can't use Tempfile here since it doesn't support File::BINARY mode on 1.8 # can't use Dir.mktmpdir(&blk) because of http://jira.codehaus.org/browse/JRUBY-4082 tmp_dir = Dir.mktmpdir begin zip_path = File.join(tmp_dir, "webdriver-profile-duplicate-#{json.hash}.zip") File.open(zip_path, "wb") { |zip_file| zip_file << Base64.decode64(data) } new Zipper.unzip(zip_path) ensure FileUtils.rm_rf tmp_dir end end |