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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5514df58d41f2afed4ac37f7a84bf0a8809659df
4
- data.tar.gz: 23d2fe5e8d6177ed4c619db85da87c1a2f8d8423
3
+ metadata.gz: cc1d7a83608fe48cb16cefb854b05e4f203d6145
4
+ data.tar.gz: d2f8e9ee2f7f55133b32cc5f319a21eed791e215
5
5
  SHA512:
6
- metadata.gz: 9a843b49bcfa409ba7b5e64f924c22ddb50484b08ea7a90ebbc83fd02e040df7b6ab5ca9e87ca51c4987747b48476510b618d03447e65e081811ed042af2389d
7
- data.tar.gz: ba6ea3108bb7d389cf9348619c29136bc941b0f522b5921fb64e2318dd255e5acf83f5fc1304cb76d3353ac95da7f50cadecc180d3bd855c1af3f6eb06541f16
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.each(&:remove)
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
- document.at_css('head').children.first
76
- .add_previous_sibling(all_script_src_tag)
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
@@ -1,5 +1,5 @@
1
1
  module Pageflow
2
2
  module Chart
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '1.0.1'.freeze
4
4
  end
5
5
  end
@@ -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.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 00:00:00.000000000 Z
11
+ date: 2017-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pageflow