trmnl_preview 0.17.0 → 0.17.2
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/CHANGELOG.md +9 -0
- data/lib/trmnlp/testing/inline_stylesheets.rb +6 -3
- data/lib/trmnlp/testing/report.rb +1 -1
- data/lib/trmnlp/testing/rspec.rb +1 -1
- data/lib/trmnlp/testing/snapshot.rb +1 -1
- data/lib/trmnlp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 835368508a529b50bb30de82e6a0170a9d5c14f6edebeb4ffdd2afc774273e58
|
|
4
|
+
data.tar.gz: 7cf9003dde78b9688674ff48fe0e0fa7decd50ee36204de9196078141ae3defa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 339f9c574ee307ebc59ed949d6b12bcdb7c58aaa6191564f0b8b6d5b91c675322e2f329055b2630f6d29db3ca341386e09aded2f02e928c129f297890584fbb4
|
|
7
|
+
data.tar.gz: 3d5c286313c7a75f2b6beaba417917fdc932a51dd8e4e9f3953065111f1accec23d3480164f47588547b6bcc2b482abbe534368328c8107e034308f354197dfd
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
# Changelog
|
|
3
3
|
|
|
4
|
+
## 0.17.2
|
|
5
|
+
|
|
6
|
+
- `trmnlp test` no longer inlines a stylesheet link inside a script's string, such as a CDN fallback written with `document.write`. It broke the script, and every render came out blank. (#174)
|
|
7
|
+
|
|
8
|
+
## 0.17.1
|
|
9
|
+
|
|
10
|
+
- `trmnlp test --report` writes its images readable by everyone, and `--update` its snapshots. They kept the 0600 mode of the screen's temp file, so under the `trmnl/trmnlp` image, which runs as root, the init workflow could not upload the report. (#171)
|
|
11
|
+
- Capybara's matchers compose with `.and` and `.or` in a plugin's tests. (#172)
|
|
12
|
+
|
|
4
13
|
## 0.17.0
|
|
5
14
|
|
|
6
15
|
- `trmnlp init` adds a starter `tests/plugin_spec.rb`, and its GitHub workflow gains a `test` job: `trmnlp test --report` in the `trmnl/trmnlp` image (one `TRMNLP_IMAGE` setting picks the tag), the report uploaded, a manual `update_snapshots` run, and the push to TRMNL waiting for lint and tests. (#168)
|
|
@@ -10,16 +10,19 @@ module TRMNLP
|
|
|
10
10
|
# measures text (a layout solver, say) raced them and drew a different board from run to run.
|
|
11
11
|
module InlineStylesheets
|
|
12
12
|
LINK = /<link\b[^>]*\brel=["']stylesheet["'][^>]*>/i
|
|
13
|
+
SCRIPT = %r{<script\b.*?</script>}im
|
|
13
14
|
HREF = /\bhref=["'](https?:[^"']+)["']/i
|
|
14
15
|
CSS_URL = /url\(\s*(['"]?)(?!data:|https?:|#)([^'")]+)\1\s*\)/i
|
|
15
16
|
|
|
16
17
|
module_function
|
|
17
18
|
|
|
18
19
|
def call(html)
|
|
19
|
-
html.gsub(LINK) do |
|
|
20
|
-
|
|
20
|
+
html.gsub(Regexp.union(SCRIPT, LINK)) do |tag|
|
|
21
|
+
next tag if tag.match?(/\A<script/i)
|
|
22
|
+
|
|
23
|
+
url = tag[HREF, 1]
|
|
21
24
|
css = url && stylesheet(url)
|
|
22
|
-
css ? "<style data-href=\"#{url}\">#{css}</style>" :
|
|
25
|
+
css ? "<style data-href=\"#{url}\">#{css}</style>" : tag
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
28
|
|
|
@@ -71,7 +71,7 @@ module TRMNLP
|
|
|
71
71
|
def copy_image(path)
|
|
72
72
|
name = "images/#{@images += 1}.png"
|
|
73
73
|
FileUtils.mkdir_p(File.join(@dir, 'images'))
|
|
74
|
-
|
|
74
|
+
File.binwrite(File.join(@dir, name), File.binread(path)) # not cp, which keeps the screen's private 0600 mode
|
|
75
75
|
name
|
|
76
76
|
end
|
|
77
77
|
|
data/lib/trmnlp/testing/rspec.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Loaded by `trmnlp test`: gives each example `trmnl`, Capybara's matchers and trmnlp's own.
|
|
4
|
-
require 'capybara/rspec/matchers'
|
|
5
4
|
require 'rspec/core'
|
|
6
5
|
require 'rspec/expectations'
|
|
6
|
+
require 'capybara/rspec/matchers' # after rspec/expectations, or its matchers lose .and and .or
|
|
7
7
|
|
|
8
8
|
require_relative '../../trmnlp'
|
|
9
9
|
require_relative '../browser_pool'
|
data/lib/trmnlp/version.rb
CHANGED