ferrum-har 0.1.1 → 0.1.2

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: 46ed855d025e19faa838772982f3b4e4bf6be389750445d91ff45a240e17da2b
4
- data.tar.gz: 5604f75db7e5fe01ea8d406377c5325ddf59761eef503ebd8e72f581b6cd0017
3
+ metadata.gz: 7d8d40ce71b743bf429c007041d4e1df81c0cf82b9765d8cf886249abf882543
4
+ data.tar.gz: 33c293040e516c1e28fc1ad31c95a8c6e43ed9509b2b773644efcfe0eca74d2a
5
5
  SHA512:
6
- metadata.gz: d16fa7164a200c6eecfd06f51f751f335c38222c95077a3a89ca6923557decab9d4a174846c160b36539be22c42651c024194699a7f861816f13badaec3d37bb
7
- data.tar.gz: 0522dec550b943209ea34edf0991915cd90f23f382e64a8a593eede11f2dfa0fc806534831224e7ca63911654ab95d29acf7751495b238f1f740b81673d2f1c6
6
+ metadata.gz: 6fa0a91fefc4e7a6c14b176257521e9c02941d420e6ad64e0e5681e1efd3b6121b97c33d685338176a0c8c2381213f994f6989fb92ae55f8e44ad68d99bffe4d
7
+ data.tar.gz: 2e93582b28d0c0ceb59638f3e92c0e3ef74178a27ba6d20d1a08b5578d55e091fefc709d14557abe07824cd778c05d8a97b278d79fd4ab9e62ac763842477f05
data/README.md CHANGED
@@ -18,16 +18,13 @@ gem "ferrum-har"
18
18
  ## Usage
19
19
 
20
20
  Use [ferrum](https://github.com/rubycdp/ferrum) as normal and call the `har` method on
21
- the `page` (or `browser`) object. You will have to use some of the required browser options
22
- by using the `Ferrum::Har::REQUIRED_BROWSER_OPTIONS` constant.
21
+ the `page` (or `browser`) object. Chrome must be used as the browser engine.
23
22
 
24
- Note, the devtools window in Chrome will be opened for the duration of the ferrum test run.
25
- This is mandatory to obtain the HAR from Chrome.
23
+ Note, the devtools window in Chrome will be opened by ferrum-har for the duration of the ferrum
24
+ test run. This is mandatory to obtain the HAR from Chrome.
26
25
 
27
26
  ```ruby
28
- browser = Ferrum::Browser.new(
29
- browser_options: Ferrum::Har::REQUIRED_BROWSER_OPTIONS,
30
- )
27
+ browser = Ferrum::Browser.new
31
28
  page = browser.create_page
32
29
  page.go_to("https://www.bbc.co.uk")
33
30
 
@@ -53,7 +50,7 @@ One ramification of this is that the Chrome devtools must be open for the extens
53
50
 
54
51
  To get the extension to be loaded we must pass some switches to the Chrome process via ferrum,
55
52
  specifically the `--auto-open-devtools-for-tabs` and `--load-extension` switches. This is done
56
- by the `Ferrum::Har::REQUIRED_BROWSER_OPTIONS` constant.
53
+ by ferrum-har automatically.
57
54
 
58
55
  For further reading, a full list of Chrome switches can be found
59
56
  [here](https://peter.sh/experiments/chromium-command-line-switches/).
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This module is prepended to Ferrum::Browser::Options::Chrome to alter the default options so they
4
+ # work with the ferrum-har gem.
5
+ module Ferrum
6
+ module Har
7
+ module OptionsExtension
8
+ def merge_default(flags, options)
9
+ super
10
+ # We have to remove the "disable-extensions" option from the default browser extension
11
+ # list because the ferrum-har gem requires an (internal) extension to work.
12
+ .except("disable-extensions")
13
+ .merge(
14
+ "auto-open-devtools-for-tabs" => nil, # Chrome devtools must be open to invoke getHAR
15
+ "load-extension" => "#{Ferrum::Har::GEM_DIR}/extension", # Extension that gets the HAR
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ferrum
4
4
  module Har
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
data/lib/ferrum/har.rb CHANGED
@@ -1,23 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "ferrum"
4
+ require "ferrum/browser/options/chrome"
4
5
  require "ferrum/har/version"
5
6
  require "ferrum/har/page_extension"
7
+ require "ferrum/har/options_extension"
6
8
 
7
9
  module Ferrum
8
10
  module Har
9
11
  GEM_DIR = File.expand_path("../..", __dir__)
10
- REQUIRED_BROWSER_OPTIONS = {
11
- "auto-open-devtools-for-tabs" => nil, # The chrome devtools must be open to invoke getHAR
12
- "load-extension" => "#{Ferrum::Har::GEM_DIR}/extension", # The extension that gets the HAR
13
- }.freeze
14
12
  end
15
13
  end
16
14
 
17
- # We have to remove the "disable-extensions" option from the default browser extension list because
18
- # the ferrum-har gem requires an (internal) extension to work.
19
- Ferrum::Browser::Options::Chrome::DEFAULT_OPTIONS =
20
- Ferrum::Browser::Options::Chrome::DEFAULT_OPTIONS.except("disable-extensions")
21
-
22
15
  # Add the #har method to Ferrum::Page
23
16
  Ferrum::Page.prepend(Ferrum::Har::PageExtension)
17
+
18
+ # Add the #merge_default method to Ferrum::Browser::Options::Chrome
19
+ Ferrum::Browser::Options::Chrome.prepend(Ferrum::Har::OptionsExtension)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ferrum-har
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Lascelles
@@ -11,7 +11,7 @@ cert_chain: []
11
11
  date: 2024-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ferrum
14
+ name: base64
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: base64
28
+ name: ferrum
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -47,6 +47,7 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - README.md
49
49
  - lib/ferrum/har.rb
50
+ - lib/ferrum/har/options_extension.rb
50
51
  - lib/ferrum/har/page_extension.rb
51
52
  - lib/ferrum/har/version.rb
52
53
  homepage: https://github.com/hlascelles/ferrum-har