devcenter-parser 1.4.2 → 1.4.3

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
  !binary "U0hBMQ==":
3
- metadata.gz: 45daa632ef49ab001185c85e8211264001fb5905
4
- data.tar.gz: 7838fa926deb1ca2f6c9181fc33e93b4fb210d94
3
+ metadata.gz: 65f6956c4870415104ea82817a26a1985d4b71ec
4
+ data.tar.gz: 56c1b482c8c3cd46d470b4fda57a1940f3aa5592
5
5
  SHA512:
6
- metadata.gz: b8bf5da01e7dd43a7479a68c0bd103a0851e5da59ca11ad4574e02015e0104d78a0cde3001a36486c693e0d4144af12c053c9fb56c38f277c97d432ea834775d
7
- data.tar.gz: a1e0378ede29b79c4fd4e71a6bfd120f95f63a0b27a883ff27deeb6b341bedf0bb6a13eee9b84f172560d535adba5f12a5bea2c47e9a696c590ffa834f0b7e4e
6
+ metadata.gz: ee593eb72da41a4715f50e6531db7b698f41a5eb1cd7d4aee300c5e30bd09533e781562ebea25227b1cef6ec53d52fad1584de14abce3df322ac3542348be337
7
+ data.tar.gz: 2e62917baf949c6f63cef26f589ac91c6e9e155a2e44a8db52cfff79a58cf416ba4d9884b236616a7f344e3d6edc6910ad74cd35db5788d069921d9218507c62
@@ -47,7 +47,7 @@ class HeaderIdGenerator
47
47
  def parent_header_nodes(node)
48
48
  parent_tags(node.name).map do |parent_tag|
49
49
  @header_nodes[0..@header_nodes.index(node)-1].select{ |sibling| sibling.name == parent_tag }.last
50
- end
50
+ end.compact
51
51
  end
52
52
 
53
53
  # "h4" -> ["h2", "h3"]
@@ -1,3 +1,3 @@
1
1
  module DevcenterParser
2
- VERSION = '1.4.2'
2
+ VERSION = '1.4.3'
3
3
  end
@@ -22,40 +22,60 @@ describe 'HeaderIdGeneratorTest' do
22
22
 
23
23
 
24
24
  describe 'ensures that there are not collisions between ids in subheaders' do
25
- it 'by prepending the id of the previous headers as long as necessary' do
26
- html = <<-HTML
27
- <h2>A</h2>
28
- <h3>B</h3>
29
- <h4>Z</h4>
25
+ describe 'by prepending the id of the previous headers as long as necessary' do
26
+ it 'when there are conflicts on headers from different sections' do
27
+ html = <<-HTML
28
+ <h2>A</h2>
29
+ <h3>B</h3>
30
+ <h4>Z</h4>
30
31
 
31
- <h2>C</h2>
32
- <h3>B</h3>
33
- <h4>Z</h4>
32
+ <h2>C</h2>
33
+ <h3>B</h3>
34
+ <h4>Z</h4>
35
+ HTML
36
+ result = result(html)
37
+ %w{ a c }.each{ |id| assert_id(result, 'h2', id) }
38
+ %w{ a-b c-b }.each{ |id| assert_id(result, 'h3', id) }
39
+ %w{ a-b-z c-b-z }.each{ |id| assert_id(result, 'h4', id) }
40
+ end
34
41
 
35
- <h2>D</h2>
36
- <h3>X</h3>
37
- <h4>Z</h4>
38
- <h3>Y</h3>
39
- <h4>Z</h4>
42
+ it 'when there are conflicts on headers from different sections where some headers are missing' do
43
+ html = <<-HTML
44
+ <h2>A</h2>
45
+ <h4>Z</h4>
40
46
 
41
- HTML
42
- result = result(html)
43
- %w{ a c d }.each{ |id| assert_id(result, 'h2', id) }
44
- %w{ a-b c-b x y }.each{ |id| assert_id(result, 'h3', id) }
45
- %w{ a-b-z c-b-z }.each{ |id| assert_id(result, 'h4', id) }
47
+ <h2>C</h2>
48
+ <h3>Z</h3>
49
+ HTML
50
+ result = result(html)
51
+ %w{ a c }.each{ |id| assert_id(result, 'h2', id) }
52
+ %w{ c-z }.each{ |id| assert_id(result, 'h3', id) }
53
+ %w{ a-z }.each{ |id| assert_id(result, 'h4', id) }
54
+ end
46
55
 
47
- %w{ d }.each{ |id| assert_id(result, 'h2', id) }
48
- %w{ x y }.each{ |id| assert_id(result, 'h3', id) }
49
- %w{ x-z y-z }.each{ |id| assert_id(result, 'h4', id) }
56
+ it 'when there are conflicts inside the same section' do
57
+ html = <<-HTML
58
+ <h2>D</h2>
59
+ <h3>X</h3>
60
+ <h4>Z</h4>
61
+ <h3>Y</h3>
62
+ <h4>Z</h4>
63
+ HTML
64
+ result = result(html)
65
+ %w{ d }.each{ |id| assert_id(result, 'h2', id) }
66
+ %w{ x y }.each{ |id| assert_id(result, 'h3', id) }
67
+ %w{ x-z y-z }.each{ |id| assert_id(result, 'h4', id) }
68
+ end
50
69
  end
51
70
 
52
71
  it 'by appending numbers for those subheaders with same nesting level and parent header name' do
53
72
  html = <<-HTML
54
- <h2>A</h2>
55
- <h3>B</h3>
56
- <h3>B</h3>
57
- <h2>C</h2>
58
- <h2>C</h2>
73
+ <h2>A</h2>
74
+ <h3>B</h3>
75
+ <h3>B</h3>
76
+
77
+ <h2>C</h2>
78
+ <h2>C</h2>
59
79
  HTML
60
80
  result = result(html)
61
81
  %w{ a c-1 c-2 }.each{ |id| assert_id(result, 'h2', id) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devcenter-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heroku
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-11 00:00:00.000000000 Z
11
+ date: 2014-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maruku