puppeteer-ruby 0.0.23 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 133c14dccb0da46cc01bff747bb2e36c1de1f7619ee4a8a898e798b3eb3947af
4
- data.tar.gz: a7cc95948ddef2b45cc3b4a8faa82497334daeb1e47d92c97a7cbcbf9dccd887
3
+ metadata.gz: 73958c6fad7b569150344ee3cc43d20ca6eeaf82898bd1b20d8c9f40772e66f3
4
+ data.tar.gz: 3d39e319ed9e21aeff3868255ae956e16c9ef63f507a8bb591ea9693084110df
5
5
  SHA512:
6
- metadata.gz: de40a672ecbf7089e43463497bd877ed671e366ae022d6224bef0068c9ecbc5a949d4649454348af8d9823abf0e0effe84255ce3e73f8bd6f13c2d4ce2dd514e
7
- data.tar.gz: 96821b3ec521338f6c2a08c31a65113acb1aa808e1f50b9fece78bcdcc19cb6f4072b2dd6d778a5a413f47733b1efa7d3f9ded85fdd0e0dce6c1729f53be47ab
6
+ metadata.gz: e15df5c9f1114cbc599c81d541a4abcb90c6470a37ebfbeeca5c18152b4f034b55ce5af99d7f00ddc717ddf6abdf854dd7a80828deb15ec306b7c2b3e336791e
7
+ data.tar.gz: 0e51a01f8e02c3bdfea8bd0c13f781a4c101d638aacf30bc7bcb21429820326ac1cd2ae186586f49116a6791d046416ef92b59e8ec5121e2bc61097155686c38
@@ -341,47 +341,34 @@ class Puppeteer::Page
341
341
 
342
342
  define_async_method :async_Sx
343
343
 
344
- # /**
345
- # * @param {!Array<string>} urls
346
- # * @return {!Promise<!Array<Network.Cookie>>}
347
- # */
348
- # async cookies(...urls) {
349
- # return (await this._client.send('Network.getCookies', {
350
- # urls: urls.length ? urls : [this.url()]
351
- # })).cookies;
352
- # }
344
+ # @return [Array<Hash>]
345
+ def cookies(*urls)
346
+ @client.send_message('Network.getCookies', urls: (urls.empty? ? [url] : urls))['cookies']
347
+ end
353
348
 
354
- # /**
355
- # * @param {Array<Protocol.Network.deleteCookiesParameters>} cookies
356
- # */
357
- # async deleteCookie(...cookies) {
358
- # const pageURL = this.url();
359
- # for (const cookie of cookies) {
360
- # const item = Object.assign({}, cookie);
361
- # if (!cookie.url && pageURL.startsWith('http'))
362
- # item.url = pageURL;
363
- # await this._client.send('Network.deleteCookies', item);
364
- # }
365
- # }
349
+ def delete_cookie(*cookies)
350
+ page_url = url
351
+ starts_with_http = page_url.start_with?("http")
352
+ cookies.each do |cookie|
353
+ item = (starts_with_http ? { url: page_url } : {}).merge(cookie)
354
+ @client.send_message("Network.deleteCookies", item)
355
+ end
356
+ end
366
357
 
367
- # /**
368
- # * @param {Array<Network.CookieParam>} cookies
369
- # */
370
- # async setCookie(...cookies) {
371
- # const pageURL = this.url();
372
- # const startsWithHTTP = pageURL.startsWith('http');
373
- # const items = cookies.map(cookie => {
374
- # const item = Object.assign({}, cookie);
375
- # if (!item.url && startsWithHTTP)
376
- # item.url = pageURL;
377
- # assert(item.url !== 'about:blank', `Blank page can not have cookie "${item.name}"`);
378
- # assert(!String.prototype.startsWith.call(item.url || '', 'data:'), `Data URL page can not have cookie "${item.name}"`);
379
- # return item;
380
- # });
381
- # await this.deleteCookie(...items);
382
- # if (items.length)
383
- # await this._client.send('Network.setCookies', { cookies: items });
384
- # }
358
+ def set_cookie(*cookies)
359
+ page_url = url
360
+ starts_with_http = page_url.start_with?("http")
361
+ items = cookies.map do |cookie|
362
+ (starts_with_http ? { url: page_url } : {}).merge(cookie).tap do |item|
363
+ raise ArgumentError.new("Blank page can not have cookie \"#{item[:name]}\"") if item[:url] == "about:blank"
364
+ raise ArgumetnError.new("Data URL page can not have cookie \"#{item[:name]}\"") if item[:url]&.start_with?("data:")
365
+ end
366
+ end
367
+ delete_cookie(*items)
368
+ unless items.empty?
369
+ @client.send_message("Network.setCookies", cookies: items)
370
+ end
371
+ end
385
372
 
386
373
  class ScriptTag
387
374
  # @param {!{content?: string, path?: string, type?: string, url?: string}} options
@@ -1,3 +1,3 @@
1
1
  class Puppeteer
2
- VERSION = '0.0.23'
2
+ VERSION = '0.0.25'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppeteer-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-08 00:00:00.000000000 Z
11
+ date: 2020-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby