isomorfeus-puppetmaster 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b69bddef25d838e7929df96b7e2c7d0cf81393246f13e41f27e6ba339cbc7e8
4
- data.tar.gz: d98c51dcce087917b021dbb84f6bf95498708a2926ef8ef577d7bce936d72192
3
+ metadata.gz: 2d57bb719de397a00cdf97fd40b88a90262f5894016079e45157ac8b2fbf79fe
4
+ data.tar.gz: 5c6b027e3e8667e812204df269e5bb0093667ecb781fd72999d5cbea4282e042
5
5
  SHA512:
6
- metadata.gz: 190f54b29db015148c94435701716dd4dacfe2b500a0a6eea8534cb2dfb607d46ae98e9ed3868a4434e404c1c5d1be32f38a002c54be910f373b30b7a374c111
7
- data.tar.gz: 6bee0a70d9998e700c2ab6bbcc8462efe8c4e45832b1caff6400917b15279daad7f2d01eb6cf057dfa3e5df4bae08000279f172c6a9a7a6c3e3b5e01f7b27dec
6
+ metadata.gz: 9d960a9ebd52461e3ca8366c7c773d060149b7ed70f0ef4fb628315f11a1a15aafec998bd79188241e418db82761e14f3390cba7f12f3a179341e3f8e3974ed8
7
+ data.tar.gz: aad6972e400c9daac1b07e8eca5424fbcc3abb7ff2dcb31b95211be8f34139710c5096bf44ac440a2fd1d5b68d59156c869d9b73c3fd1db58ce8bd782e0fb1bf
@@ -82,7 +82,7 @@ class Puppeteer::ExecutionContext
82
82
 
83
83
  def await_ruby(ruby_source = '', file = nil, line = nil, &block)
84
84
  ruby_source, file = Isomorfeus::Puppetmaster.block_source_code(&block) if block_given?
85
- ruby_source = "#{ruby_source}.always { |result| $promise_result = result; $promise_resolved = true }"
85
+ ruby_source = "#{ruby_source}.then { |result| $promise_result = result; $promise_resolved = true }.fail { |e| $await_ruby_exception = e; $promise_resolved = true }"
86
86
  compiled_ruby = Isomorfeus::Puppetmaster.compile_ruby_source(ruby_source, file)
87
87
  evaluate <<~JAVASCRIPT
88
88
  function(){
@@ -91,13 +91,22 @@ class Puppeteer::ExecutionContext
91
91
  Opal.gvars.promise_resolved = false;
92
92
  Opal.await_ruby_exception = null;
93
93
  try {
94
- return #{compiled_ruby}
94
+ #{compiled_ruby}
95
95
  } catch (e) {
96
96
  Opal.await_ruby_exception = e;
97
97
  Opal.gvars.promise_resolved = true;
98
98
  }
99
99
  } else {
100
- setTimeout(fun, 100);
100
+ if (typeof Opal.gvars.do_not_have_opal !== 'undefined' && Opal.gvars.do_not_have_opal >= 0) { Opal.gvars.do_not_have_opal++; }
101
+ else { Opal.gvars.do_not_have_opal = 1; }
102
+ if (Opal.gvars.do_not_have_opal < 50) {
103
+ Opal.gvars.do_not_have_opal = 0;
104
+ setTimeout(fun, 100);
105
+ } else {
106
+ Opal.await_ruby_exception = new Error('Opal is not available!');
107
+ Opal.gvars.promise_resolved = true;
108
+ Opal.gvars.do_not_have_opal = 0;
109
+ }
101
110
  }
102
111
  }
103
112
  fun();
@@ -107,7 +116,7 @@ class Puppeteer::ExecutionContext
107
116
  start = Time.now
108
117
  until have_result do
109
118
  raise "await_ruby: execution timed out! Is Opal available?" if (Time.now - start) > 30
110
- have_result = evaluate 'function() { return Opal ? Opal.gvars.promise_resolved : null; }'
119
+ have_result = evaluate 'function() { return (Opal ? Opal.gvars.promise_resolved : null); }'
111
120
  sleep 0.1 unless have_result
112
121
  end
113
122
  res, exception = evaluate <<~JAVASCRIPT
@@ -120,11 +129,9 @@ class Puppeteer::ExecutionContext
120
129
  } else if (Opal.gvars.promise_result['$respond_to?']('is_a?') && Opal.gvars.promise_result['$is_a?'](Opal.Exception)) {
121
130
  let r = Opal.gvars.promise_result;
122
131
  exception = { message: r.$message(), name: r.$class().$name(), stack: r.$backtrace() }
123
- } else if (Opal.gvars.promise_result['$respond_to?']('to_n')) {
124
- res = Opal.gvars.promise_result.$to_n()
125
132
  } else { res = Opal.gvars.promise_result };
126
- delete Opal.gvars.promise_result;
127
- delete Opal.gvars.promise_resolved;
133
+ Opal.gvars.promise_result = null;
134
+ Opal.gvars.promise_resolved = null;
128
135
  if (res && res.$to_n) res = res.$to_n();
129
136
  let conv = function(o) {
130
137
  if (o === Opal.nil) o = null;
@@ -1,9 +1,9 @@
1
1
  module Isomorfeus
2
2
  module Puppetmaster
3
3
  module DSL
4
- def self.set_launch_options(app: nil, args: nil, channel: nil, default_viewport: nil, devtools: false, dumpio: nil,
4
+ def self.set_launch_options(app: nil, args: nil, channel: nil, default_viewport: nil, devtools: nil, dumpio: nil,
5
5
  env: nil, executable_path: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil,
6
- headless: true, ignore_default_args: nil, ignore_https_errors: nil, pipe: nil,
6
+ headless: nil, ignore_default_args: nil, ignore_https_errors: nil, pipe: nil,
7
7
  product: :chrome, slow_mo: nil, timeout: nil, user_data_dir: nil)
8
8
  Isomorfeus::Puppetmaster.launch_options = {
9
9
  app: app,
@@ -36,9 +36,8 @@ module Isomorfeus
36
36
  session.default_page
37
37
  end
38
38
 
39
- def visit(uri, referer: nil, timeout: nil, wait_until: 'networkidle0', headless: true, devtools: false)
39
+ def visit(uri, referer: nil, timeout: nil, wait_until: 'networkidle0', headless: nil, devtools: nil)
40
40
  session(headless: headless, devtools: devtools).visit(uri, referer: referer, timeout: timeout, wait_until: wait_until, headless: headless, devtools: devtools)
41
- session.default_page
42
41
  end
43
42
  alias_method :goto, :visit
44
43
 
@@ -82,6 +81,8 @@ module Isomorfeus
82
81
  timeout = timeout || opts[:timeout]
83
82
  user_data_dir = user_data_dir || opts[:user_data_dir]
84
83
  end
84
+ headless = true if headless.nil?
85
+ devtools = false if devtools.nil?
85
86
  Isomorfeus::Puppetmaster::Session.new(app: (app ? app : Isomorfeus::Puppetmaster.served_app),
86
87
  args: args, channel: channel&.to_s, devtools: devtools, default_viewport: default_viewport,
87
88
  dumpio: dumpio, env: env, executable_path: executable_path, handle_SIGINT: handle_SIGINT,
@@ -112,7 +113,7 @@ module Isomorfeus
112
113
  Isomorfeus::Puppetmaster.served_app.on_server(ruby_source, file, line)
113
114
  end
114
115
 
115
- def session(headless: true, devtools: false)
116
+ def session(headless: nil, devtools: nil)
116
117
  @@puppetmaster_session ||= new_session(app: Isomorfeus::Puppetmaster.served_app, headless: headless, devtools: devtools)
117
118
  end
118
119
  end
@@ -6,16 +6,18 @@ module Isomorfeus
6
6
  attr_accessor :app, :browser, :default_page, :product, :response
7
7
  attr_reader :headless, :devtools
8
8
 
9
- def initialize(app:, args: nil, channel: nil, default_viewport: nil, devtools: false, dumpio: nil,
9
+ def initialize(app:, args: nil, channel: nil, default_viewport: nil, devtools: nil, dumpio: nil,
10
10
  env: nil, executable_path: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil,
11
- headless: true, ignore_default_args: nil, ignore_https_errors: nil, pipe: nil,
11
+ headless: nil, ignore_default_args: nil, ignore_https_errors: nil, pipe: nil,
12
12
  product: :chrome, slow_mo: nil, timeout: nil, user_data_dir: nil)
13
13
  @parameters = binding.local_variables.map { |v| [v, binding.local_variable_get(v)] }.to_h
14
14
  @parameters[:channel] = @parameters[:channel].to_s if channel
15
15
  @parameters[:timeout] = TIMEOUT unless timeout
16
16
  @app = @parameters.delete(:app)
17
17
  @headless = headless
18
+ @headless = true if @headless.nil?
18
19
  @devtools = devtools
20
+ @devtools = false if @devtools.nil?
19
21
  @channel = channel.to_s
20
22
  default_viewport
21
23
  product = product.to_s
@@ -41,7 +43,9 @@ module Isomorfeus
41
43
  @browser.pages
42
44
  end
43
45
 
44
- def visit(uri, referer: nil, timeout: nil, wait_until: 'networkidle0', headless: true, devtools: false)
46
+ def visit(uri, referer: nil, timeout: nil, wait_until: 'networkidle0', headless: nil, devtools: nil)
47
+ headless = @headless if headless.nil?
48
+ devtools = @devtools if devtools.nil?
45
49
  if @headless != headless || @devtools != devtools
46
50
  @browser.close
47
51
  @headless = headless
@@ -1,3 +1,3 @@
1
1
  module Isomorfeus
2
- PUPPETMASTER_VERSION = '0.9.2'
2
+ PUPPETMASTER_VERSION = '0.9.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-puppetmaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-09 00:00:00.000000000 Z
11
+ date: 2023-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport