Commit fc0ebfce authored by KitaitiMakoto's avatar KitaitiMakoto

Change adapter name: :File -> :UnpackedDirectory

parent 57917ae8
......@@ -21,7 +21,7 @@ EOB
$0 = File.basename($PROGRAM_NAME)
include EPUB::Book::Features
file = ARGV.shift
EPUB::OCF::PhysicalContainer.adapter = :File if File.directory? file
EPUB::OCF::PhysicalContainer.adapter = :UnpackedDirectory if File.directory? file
unless File.readable? file
uri = URI.parse(file) rescue nil
if uri
......
......@@ -30,7 +30,7 @@ unless file
abort
end
EPUB::OCF::PhysicalContainer.adapter = :File if File.directory? file
EPUB::OCF::PhysicalContainer.adapter = :UnpackedDirectory if File.directory? file
unless File.readable? file
uri = URI.parse(file) rescue nil
if uri
......
......@@ -45,7 +45,7 @@ To load EPUB books from directory, you need specify file adapter via {EPUB::OCF:
require 'epub/parser'
EPUB::OCF::PhysicalContainer.adapter = :File
EPUB::OCF::PhysicalContainer.adapter = :UnpackedDirectory
And then, directory path as EPUB path:
......@@ -67,7 +67,7 @@ If set {EPUB::OCF::PhysicalContainer.adapter}, it is used every time EPUB Parser
archived_book = EPUB::Parser.parse('./page-blanche.epub') # => EPUB::Book
# From directory
File.ftype './page-blanche' # => "directory"
unpacked_book = EPUB::Parser.parse('./page-blanche', container_adapter: :File) # => EPUB::Book
unpacked_book = EPUB::Parser.parse('./page-blanche', container_adapter: :UnpackedDirectory) # => EPUB::Book
Command-line tools
------------------
......
require 'epub/ocf/physical_container/zipruby'
require 'epub/ocf/physical_container/file'
require 'epub/ocf/physical_container/unpacked_directory'
require 'epub/ocf/physical_container/unpacked_uri'
module EPUB
......
module EPUB
class OCF
class PhysicalContainer
class File < self
def open
yield self
end
def read(path_name)
::File.read(::File.join(@container_path, path_name))
end
end
end
end
end
......@@ -53,13 +53,13 @@ class TestOCFPhysicalContainer < Test::Unit::TestCase
end
end
class TestFile < self
class TestUnpackedDirectory < self
include ConcreteContainer
def setup
super
@container_path = @container_path[0..-'.epub'.length-1]
@class = EPUB::OCF::PhysicalContainer::File
@class = EPUB::OCF::PhysicalContainer::UnpackedDirectory
@container = @class.new(@container_path)
end
......
......@@ -29,7 +29,7 @@ class TestParser < Test::Unit::TestCase
def test_parse_from_file_system
adapter = EPUB::OCF::PhysicalContainer.adapter
begin
EPUB::OCF::PhysicalContainer.adapter = :File
EPUB::OCF::PhysicalContainer.adapter = :UnpackedDirectory
epub = EPUB::Parser.parse('test/fixtures/book')
assert_instance_of EPUB::Book, epub
assert_equal 'Mon premier guide de cuisson, un Mémoire', epub.main_title
......@@ -39,11 +39,11 @@ class TestParser < Test::Unit::TestCase
end
def test_can_specify_container_adapter_when_parsing_individually
epub = EPUB::Parser.parse('test/fixtures/book', container_adapter: :File)
epub = EPUB::Parser.parse('test/fixtures/book', container_adapter: :UnpackedDirectory)
assert_equal 'Mon premier guide de cuisson, un Mémoire', epub.main_title
assert_equal File.read('test/fixtures/book/OPS/nav.xhtml'), epub.nav.read
assert_equal EPUB::OCF::PhysicalContainer::File, epub.container_adapter
assert_equal EPUB::OCF::PhysicalContainer::UnpackedDirectory, epub.container_adapter
assert_equal EPUB::OCF::PhysicalContainer::Zipruby, EPUB::OCF::PhysicalContainer.adapter
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment