lib/review/book/base.rb in review-4.0.0 vs lib/review/book/base.rb in review-4.1.0

- old
+ new

@@ -134,23 +134,24 @@ chapters.reverse_each(&block) end def chapter_index return @chapter_index if @chapter_index - - contents = chapters - # TODO: contents += parts.find_all { |prt| prt.id.present? } + @chapter_index = ChapterIndex.new + each_chapter do |chap| + @chapter_index.add_item(Index::Item.new(chap.id, chap.number, chap)) + end parts.each do |prt| if prt.id.present? - contents << prt + @chapter_index.add_item(Index::Item.new(prt.id, prt.number, prt)) end end - @chapter_index = ChapterIndex.new(contents) + @chapter_index end def chapter(id) - chapter_index[id] + chapter_index[id].content end def next_chapter(chapter) finded = false each_chapter do |c| @@ -354,10 +355,10 @@ end end res = '' File.open(filename_join(@basedir, filename), 'rt:BOM|utf-8') do |f| f.each_line do |line| - next if /\A#/ =~ line + next if line.start_with?('#') line.gsub!(/#.*\Z/, '') res << line end end res