mumuki-html-runner 1.3.1 → 1.4.0
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/test_hook.rb +20 -11
- data/lib/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: 69334d46a08d472eab0c7f3c876deddb6b112d76c396963788d7d2e667464742
|
4
|
+
data.tar.gz: 676462124aca9486d5874f2100acd8eae6e7de3595622e79241aaa1d4370d52c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d20a1a4a40b4688fec39cb16ee66273cca98cda64b62b056cee45deec23de6be3fbda41c9152272ab52a779550b7dc06bbc967bd2f01d6fe96d7d2c7087e9178
|
7
|
+
data.tar.gz: 7a124a4980f436e105b4c88b75f5b3e9abc34a4da00ce24b7181baea2de47e726bbebabc22c3b4fa8b7a41cf3ddce907486c7c47788fba08a6ea7cd881454688
|
data/lib/test_hook.rb
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
require 'mumukit/hook'
|
2
2
|
|
3
|
-
class String
|
4
|
-
def visible_chars
|
5
|
-
gsub(/\s+/, '').downcase
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
3
|
class HtmlTestHook < Mumukit::Hook
|
10
4
|
def compile(request)
|
11
5
|
request
|
@@ -23,13 +17,18 @@ class HtmlTestHook < Mumukit::Hook
|
|
23
17
|
end
|
24
18
|
|
25
19
|
def contents_match?(expected, actual)
|
26
|
-
|
20
|
+
hexp_without_blanks(expected) == hexp_without_blanks(actual)
|
27
21
|
rescue
|
28
22
|
expected == actual
|
29
23
|
end
|
30
24
|
|
31
|
-
def
|
32
|
-
|
25
|
+
def hexp_without_blanks(content)
|
26
|
+
hexp ["\r", "\n", "\t"]
|
27
|
+
.reduce(content.strip) { |c, it| c.gsub(it, ' ') }
|
28
|
+
.squeeze(' ')
|
29
|
+
end
|
30
|
+
|
31
|
+
def hexp(squeezed_content)
|
33
32
|
Hexp.parse("<html>#{squeezed_content}</html>")
|
34
33
|
end
|
35
34
|
|
@@ -49,10 +48,20 @@ class HtmlTestHook < Mumukit::Hook
|
|
49
48
|
html
|
50
49
|
end
|
51
50
|
|
51
|
+
def page_title(dom)
|
52
|
+
title = dom.xpath('//title').first&.text
|
53
|
+
title.present? ? " data-title=\"#{title}\"" : ''
|
54
|
+
end
|
55
|
+
|
56
|
+
def page_favicon(dom)
|
57
|
+
dom.xpath("//link[@rel='icon' and @href]").first
|
58
|
+
.try { |tag| " data-favicon=\"#{tag['href']}\"" }
|
59
|
+
end
|
60
|
+
|
52
61
|
def build_iframe(content)
|
62
|
+
dom = hexp(content).to_dom
|
53
63
|
<<html
|
54
|
-
<div class="mu-browser">
|
55
|
-
<iframe srcdoc="#{content.gsub('"', '"')}"></iframe>
|
64
|
+
<div class="mu-browser"#{page_title dom}#{page_favicon dom} data-srcdoc="#{content.gsub('"', '"')}">
|
56
65
|
</div>
|
57
66
|
html
|
58
67
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumuki-html-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franco Leonardo Bulgarelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mumukit
|