pageflow-chart 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/pageflow/chart/scraper.rb +8 -3
- data/lib/pageflow/chart/version.rb +1 -1
- data/spec/pageflow/chart/scraper_spec.rb +28 -0
- data/spec/support/html_fragment.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc1d7a83608fe48cb16cefb854b05e4f203d6145
|
4
|
+
data.tar.gz: d2f8e9ee2f7f55133b32cc5f319a21eed791e215
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aedbaab6f9ca7e42272ff0188cf6cb7261d1ea4bcf7e6b12bdcc77a902626ba0974d7a8ea8fbc08596258b9b9bc72a585c9cbb3ca075683a8e61db9e040af1ea
|
7
|
+
data.tar.gz: 96d7cd899d64010e611b4f01a82830c12e0f7974f274f630af1519c1f0198cada990ba09bce1acb0430bd13e9ce998842ce7ddd8d4c38aa030414f364628f92d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
### Version 1.0.1
|
4
|
+
|
5
|
+
2017-08-17
|
6
|
+
|
7
|
+
[Compare changes](https://github.com/codevise/pageflow-chart/compare/v1.0.0...v1.0.1)
|
8
|
+
|
9
|
+
- Try to minimize changes in script tag order
|
10
|
+
([#39](https://github.com/codevise/pageflow-chart/pull/39))
|
11
|
+
|
3
12
|
### Version 1.0.0
|
4
13
|
|
5
14
|
2017-08-11
|
@@ -67,13 +67,18 @@ module Pageflow
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def combine_script_tags_in_head
|
70
|
-
script_src_tags_in_head
|
70
|
+
script_tags_to_remove = script_src_tags_in_head
|
71
|
+
return if script_tags_to_remove.empty?
|
71
72
|
|
72
73
|
all_script_src_tag = Nokogiri::XML::Node.new('script', document)
|
73
74
|
all_script_src_tag[:src] = 'all.js'
|
74
75
|
all_script_src_tag[:type] = 'text/javascript'
|
75
|
-
|
76
|
-
|
76
|
+
|
77
|
+
script_tags_to_remove
|
78
|
+
.first
|
79
|
+
.add_previous_sibling(all_script_src_tag)
|
80
|
+
|
81
|
+
script_tags_to_remove.each(&:remove)
|
77
82
|
end
|
78
83
|
|
79
84
|
def combine_css_link_tags
|
@@ -37,6 +37,34 @@ module Pageflow
|
|
37
37
|
expect(HtmlFragment.new(scraper.html)).to have_tag('head script[src="all.js"]')
|
38
38
|
end
|
39
39
|
|
40
|
+
it 'inserts script tag at position of first script src tag to keep position' \
|
41
|
+
'between inline scripts' do
|
42
|
+
html = <<-HTML
|
43
|
+
<!DOCTYPE html>
|
44
|
+
<html>
|
45
|
+
<head>
|
46
|
+
<script id="setup">
|
47
|
+
// Some setup required for scripts below to execute
|
48
|
+
</script>
|
49
|
+
<script type="text/javascript" src="/some.js"></script>
|
50
|
+
<script type="text/javascript" src="/other.js"></script>
|
51
|
+
<script id="usage">
|
52
|
+
// Some script using stuff loading above
|
53
|
+
</script>
|
54
|
+
</head>
|
55
|
+
<body>
|
56
|
+
</body>
|
57
|
+
</html>
|
58
|
+
HTML
|
59
|
+
scraper = Scraper.new(html)
|
60
|
+
|
61
|
+
fragment = HtmlFragment.new(scraper.html)
|
62
|
+
|
63
|
+
expect(fragment).to have_tags_in_order('head script#setup',
|
64
|
+
'head script[src="all.js"]',
|
65
|
+
'head script#usage')
|
66
|
+
end
|
67
|
+
|
40
68
|
it 'combines link tags in head' do
|
41
69
|
html = <<-HTML
|
42
70
|
<!DOCTYPE html>
|
@@ -10,4 +10,17 @@ class HtmlFragment
|
|
10
10
|
def has_tag?(selector)
|
11
11
|
!!document.at_css(selector)
|
12
12
|
end
|
13
|
+
|
14
|
+
def has_tags_in_order?(*selectors)
|
15
|
+
all_elements = document.css('*')
|
16
|
+
|
17
|
+
elements = selectors.map do |selector|
|
18
|
+
document.at_css(selector) ||
|
19
|
+
raise("Selector '#{selector}}' did not match any element.")
|
20
|
+
end
|
21
|
+
|
22
|
+
elements.each_cons(2).all? do |element1, element2|
|
23
|
+
all_elements.index(element1) < all_elements.index(element2)
|
24
|
+
end
|
25
|
+
end
|
13
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pageflow-chart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Codevise Solutions Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pageflow
|