chop 0.38.0 → 0.38.1
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 +4 -4
- data/lib/chop/diff.rb +37 -20
- data/lib/chop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 667c9f85d886a69ae08b9ae3b4b8ef5c7a012a6f930bbbf38926ef2020660310
|
|
4
|
+
data.tar.gz: 1bbc14a87fae8b894b4bd3a488e298d874c5e6aa4fd09c00d3eeec448c6d35ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 223f9ad5013a389fc96e0bf3b94631e63e9f5936be23972aa2a0baa5f6a87b43796cb61bc1f5e409480972724b32a1a85590cbc0f3add4ae6e50c64333a7c81a
|
|
7
|
+
data.tar.gz: d42b1c343e98dbc2172613873e40fb80a91e5f79a9f5baf975d0e9c1c3629da76ece7ea18cce31e2e8c63094b409dc25ffefc70d31b777801e5bf4b9632909cb
|
data/lib/chop/diff.rb
CHANGED
|
@@ -128,6 +128,8 @@ module Chop
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def to_a
|
|
131
|
+
wait_for_idle! if @atomic
|
|
132
|
+
freeze_page_scripts! if @atomic
|
|
131
133
|
rows = rows_finder.call(root).map { |row| cells_finder.call(row).to_a }
|
|
132
134
|
rows = normalize(rows)
|
|
133
135
|
|
|
@@ -149,10 +151,11 @@ module Chop
|
|
|
149
151
|
|
|
150
152
|
rows.map do |row|
|
|
151
153
|
row.map do |cell|
|
|
152
|
-
|
|
153
|
-
@atomic && text.is_a?(String) ? normalize_atomic_text(text) : text
|
|
154
|
+
text_finder.call(cell)
|
|
154
155
|
end
|
|
155
156
|
end
|
|
157
|
+
ensure
|
|
158
|
+
unfreeze_page_scripts! if @atomic
|
|
156
159
|
end
|
|
157
160
|
|
|
158
161
|
def diff! cucumber_table = table, **kwargs
|
|
@@ -178,37 +181,51 @@ module Chop
|
|
|
178
181
|
end
|
|
179
182
|
end
|
|
180
183
|
|
|
181
|
-
# Normalize text from a Nokogiri snapshot to match what Capybara drivers
|
|
182
|
-
# return from visible_text. Replicates Capybara::Node::WhitespaceNormalizer#normalize_spacing.
|
|
183
|
-
def normalize_atomic_text(text)
|
|
184
|
-
text
|
|
185
|
-
.delete("\u200b\u200e\u200f")
|
|
186
|
-
.tr(" \n\f\t\v\u2028\u2029", " ")
|
|
187
|
-
.squeeze(" ")
|
|
188
|
-
.sub(/\A[[:space:]&&[^\u00a0]]+/, "")
|
|
189
|
-
.sub(/[[:space:]&&[^\u00a0]]+\z/, "")
|
|
190
|
-
.tr("\u00a0", " ")
|
|
191
|
-
end
|
|
192
184
|
|
|
193
185
|
def root
|
|
194
186
|
@root ||= begin
|
|
195
|
-
|
|
187
|
+
if selector.is_a?(Capybara::Node::Element)
|
|
196
188
|
selector
|
|
197
189
|
else
|
|
198
190
|
session.find(selector, wait: timeout)
|
|
199
191
|
end
|
|
200
|
-
if @atomic
|
|
201
|
-
html = element["outerHTML"] || element.native.to_html
|
|
202
|
-
Node(html)
|
|
203
|
-
else
|
|
204
|
-
element
|
|
205
|
-
end
|
|
206
192
|
rescue Capybara::ElementNotFound
|
|
207
193
|
raise unless @allow_not_found
|
|
208
194
|
Node("")
|
|
209
195
|
end
|
|
210
196
|
end
|
|
211
197
|
|
|
198
|
+
def cdp_page
|
|
199
|
+
session.driver.browser.page
|
|
200
|
+
rescue NoMethodError
|
|
201
|
+
nil
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def wait_for_idle!
|
|
205
|
+
return unless cdp_page
|
|
206
|
+
|
|
207
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
208
|
+
loop do
|
|
209
|
+
break if Process.clock_gettime(Process::CLOCK_MONOTONIC) - start > timeout
|
|
210
|
+
pending_frames = session.evaluate_script("document.querySelectorAll('turbo-frame[src]:not([complete]), turbo-frame[busy]').length")
|
|
211
|
+
pending_network = session.driver.browser.network.pending_connections
|
|
212
|
+
break if pending_frames == 0 && pending_network == 0
|
|
213
|
+
sleep 0.05
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def freeze_page_scripts!
|
|
218
|
+
page = cdp_page
|
|
219
|
+
return unless page
|
|
220
|
+
page.command("Emulation.setScriptExecutionDisabled", value: true)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def unfreeze_page_scripts!
|
|
224
|
+
page = cdp_page
|
|
225
|
+
return unless page
|
|
226
|
+
page.command("Emulation.setScriptExecutionDisabled", value: false)
|
|
227
|
+
end
|
|
228
|
+
|
|
212
229
|
def Node value
|
|
213
230
|
if value.respond_to?(:text)
|
|
214
231
|
value
|
data/lib/chop/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.38.
|
|
4
|
+
version: 0.38.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|