diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 490a649..8b30842 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,8 +6,6 @@ jobs: matrix: ruby: [2.7, 3.0, 3.1, 3.2, 3.3, jruby] platform: [ubuntu-latest, macos-latest, windows-latest] - exclude: - - platform: windows-latest runs-on: ${{ matrix.platform }} env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} diff --git a/.gitignore b/.gitignore index 5a0999e..d130cbd 100644 --- a/.gitignore +++ b/.gitignore @@ -19,8 +19,6 @@ rdoc pkg ## PROJECT::SPECIFIC -testepub*.epub -example_test*.epub ## BUNDLER Gemfile.lock diff --git a/lib/gepub/book.rb b/lib/gepub/book.rb index d003ba6..40ff37f 100644 --- a/lib/gepub/book.rb +++ b/lib/gepub/book.rb @@ -102,14 +102,14 @@ def self.parse(io) package = nil package_path = nil book = nil - Zip::File.open_buffer(io) { + Zip::File.open_buffer(io) do |zip_file| package, package_path = parse_container(zip_file, files) check_consistency_of_package(package, package_path) parse_files_into_package(files, package) book = Book.new(package.path) book.instance_eval { @package = package; @optional_files = files } - } + end book end diff --git a/spec/example_spec.rb b/spec/example_spec.rb index 29a4d5e..549b44f 100644 --- a/spec/example_spec.rb +++ b/spec/example_spec.rb @@ -7,6 +7,14 @@ end context 'On generating EPUB' do + before do + @tempdir = Dir.mktmpdir + end + + after do + FileUtils.remove_entry_secure @tempdir + end + it 'should generate simple EPUB3 with Builder and buffer' do workdir = File.join(File.dirname(__FILE__), 'fixtures', 'testdata') builder = GEPUB::Builder.new { @@ -33,7 +41,7 @@ } } } - epubname = File.join(File.dirname(__FILE__), 'example_test_with_builder_buffer.epub') + epubname = File.join(@tempdir, 'example_test_with_builder_buffer.epub') File.open(epubname, 'wb') { |io| io.write builder.generate_epub_stream.string } epubcheck(epubname) end @@ -64,7 +72,7 @@ } } } - epubname = File.join(File.dirname(__FILE__), 'example_test_with_builder.epub') + epubname = File.join(@tempdir, 'example_test_with_builder.epub') builder.generate_epub(epubname) epubcheck(epubname) end @@ -106,7 +114,7 @@ book.add_item('text/chap1-1.xhtml').add_content(StringIO.new('
the second page
')) # do not appear on table of contents book.add_item('text/chap2.xhtml').add_content(StringIO.new('the third page
')).toc_text('Chapter 2') } - epubname = File.join(File.dirname(__FILE__), 'example_test.epub') + epubname = File.join(@tempdir, 'example_test.epub') book.generate_epub(epubname) epubcheck(epubname) end @@ -124,7 +132,7 @@ item.add_content StringIO.new('the first page
') end - epubname = File.join(File.dirname(__FILE__), 'example_test.epub') + epubname = File.join(@tempdir, 'example_test.epub') book.generate_epub(epubname) epubcheck(epubname) end @@ -167,7 +175,7 @@ book.add_item('text/chap1-1.xhtml').add_content(StringIO.new('the second page
')) # do not appear on table of contents book.add_item('text/chap2.xhtml').add_content(StringIO.new('the third page
')).toc_text('Chapter 2') } - epubname = File.join(File.dirname(__FILE__), 'example_test.epub') + epubname = File.join(@tempdir, 'example_test.epub') # check nav doc xml = Nokogiri::XML::Document.parse book.nav_doc diff --git a/spec/gepub_deprectad_api_spec.rb b/spec/gepub_deprectad_api_spec.rb index a5d43c5..0fc1e6f 100644 --- a/spec/gepub_deprectad_api_spec.rb +++ b/spec/gepub_deprectad_api_spec.rb @@ -75,6 +75,11 @@