Skip to content

Commit

Permalink
Use "index" attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Feb 25, 2019
1 parent 9deefbe commit 4aab2ec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/chupa-text/decomposers/open-document-presentation.rb
Expand Up @@ -66,7 +66,7 @@ def decompose(data)
slides.each_with_index do |slide, i|
text = slide[:text]
text_data = TextData.new(text, source_data: data)
text_data["nth_slide"] = i
text_data["index"] = i
yield(text_data)
end
end
Expand Down
36 changes: 24 additions & 12 deletions test/decomposers/test-open-document-presentation.rb
Expand Up @@ -94,11 +94,14 @@ def decompose

def test_body
assert_equal([
"",
"Slide1 title\n" +
"Slide1 content\n",
[nil, ""],
[
0,
"Slide1 title\n" +
"Slide1 content\n",
],
],
decompose.collect(&:body))
decompose.collect {|data| [data["index"], data.body]})
end
end

Expand All @@ -109,15 +112,24 @@ def decompose

def test_body
assert_equal([
"",
"Slide1 title\n" +
"Slide1 content\n",
"Slide2 title\n" +
"Slide2 content\n",
"Slide3 title\n" +
"Slide3 content\n",
[nil, ""],
[
0,
"Slide1 title\n" +
"Slide1 content\n",
],
[
1,
"Slide2 title\n" +
"Slide2 content\n",
],
[
2,
"Slide3 title\n" +
"Slide3 content\n",
],
],
decompose.collect(&:body))
decompose.collect {|data| [data["index"], data.body]})
end
end
end
Expand Down

0 comments on commit 4aab2ec

Please sign in to comment.