eeepub 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.rdoc +15 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/examples/simple.rb +61 -0
- data/lib/eeepub/container_item.rb +45 -0
- data/lib/eeepub/ncx.rb +18 -0
- data/lib/eeepub/ocf.rb +34 -0
- data/lib/eeepub/opf.rb +17 -0
- data/lib/eeepub/templates/container.xml.erb +8 -0
- data/lib/eeepub/templates/ncx.erb +22 -0
- data/lib/eeepub/templates/opf.erb +39 -0
- data/lib/eeepub.rb +4 -0
- data/spec/eeepub/ncx_spec.rb +44 -0
- data/spec/eeepub/ocf_spec.rb +36 -0
- data/spec/eeepub/opf_spec.rb +96 -0
- data/spec/eeepub_spec.rb +4 -0
- data/spec/spec_helper.rb +11 -0
- metadata +96 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 jugyo
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "eeepub"
|
8
|
+
gem.summary = %Q{ePub generator}
|
9
|
+
gem.description = %Q{EeePub is a Ruby ePub generator.}
|
10
|
+
gem.email = "jugyo.org@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/jugyo/eeepub"
|
12
|
+
gem.authors = ["jugyo"]
|
13
|
+
gem.add_development_dependency "rspec"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
22
|
+
spec.libs << 'lib' << 'spec'
|
23
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
+
end
|
25
|
+
|
26
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
29
|
+
spec.rcov = true
|
30
|
+
end
|
31
|
+
|
32
|
+
task :spec => :check_dependencies
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
require 'rake/rdoctask'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
if File.exist?('VERSION')
|
39
|
+
version = File.read('VERSION')
|
40
|
+
else
|
41
|
+
version = ""
|
42
|
+
end
|
43
|
+
|
44
|
+
rdoc.rdoc_dir = 'rdoc'
|
45
|
+
rdoc.title = "eeepub #{version}"
|
46
|
+
rdoc.rdoc_files.include('README*')
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/examples/simple.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
require 'rubygems'
|
3
|
+
require 'eeepub'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
dir = 'simple'
|
7
|
+
FileUtils.rm_rf(dir)
|
8
|
+
FileUtils.mkdir(dir)
|
9
|
+
|
10
|
+
epub_name = 'simple.epub'
|
11
|
+
FileUtils.rm_f(epub_name)
|
12
|
+
|
13
|
+
# Create sample html
|
14
|
+
['foo', 'bar'].each do |name|
|
15
|
+
File.open(File.join(dir, "#{name}.html"), 'w') do |f|
|
16
|
+
f << <<-HTML
|
17
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
18
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
19
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
|
20
|
+
<body>
|
21
|
+
<h1>#{name}</h1>
|
22
|
+
</body>
|
23
|
+
</html>
|
24
|
+
HTML
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Create NCX
|
29
|
+
EeePub::NCX.new(
|
30
|
+
:uid => 'xxxx', :doc_title => 'simple',
|
31
|
+
:nav_points => [
|
32
|
+
{:id => 'nav-1', :play_order => '1', :label => '1. foo', :content => 'foo.html'},
|
33
|
+
{:id => 'nav-2', :play_order => '2', :label => '2. bar', :content => 'bar.html'}
|
34
|
+
]
|
35
|
+
).save(File.join(dir, 'toc.ncx'))
|
36
|
+
|
37
|
+
# Create OPF
|
38
|
+
EeePub::OPF.new(
|
39
|
+
:title => 'simple',
|
40
|
+
:language => 'ja',
|
41
|
+
:identifier => 'xxxxxxx',
|
42
|
+
:items => [
|
43
|
+
{:id => 'ncx', :href => 'toc.ncx', :media_type => 'text/xml'},
|
44
|
+
{:id => 'foo', :href => 'foo.html', :media_type => 'text/html'},
|
45
|
+
{:id => 'bar', :href => 'bar.html', :media_type => 'text/html'},
|
46
|
+
],
|
47
|
+
:itemrefs => [
|
48
|
+
{:idref => 'foo'},
|
49
|
+
{:idref => 'bar'}
|
50
|
+
]
|
51
|
+
).save(File.join(dir, 'package.opf'))
|
52
|
+
|
53
|
+
# Create OCF
|
54
|
+
EeePub::OCF.new(
|
55
|
+
:dir => dir,
|
56
|
+
:container => EeePub::OCF::Container.new(
|
57
|
+
:rootfiles => [
|
58
|
+
{:full_path => 'package.opf', :media_type => 'application/oebps-package+xml'}
|
59
|
+
]
|
60
|
+
)
|
61
|
+
).make(epub_name)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module EeePub
|
4
|
+
class ContainerItem
|
5
|
+
include ERB::Util
|
6
|
+
|
7
|
+
TEMPLATE_DIR = File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_reader :template_name
|
11
|
+
|
12
|
+
def template(name)
|
13
|
+
@template_name = name
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(values)
|
18
|
+
set_values(values)
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_values(values)
|
22
|
+
values.each do |k, v|
|
23
|
+
self.send(:"#{k}=", v)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_xml
|
28
|
+
erb(self.class.template_name).result(binding)
|
29
|
+
end
|
30
|
+
|
31
|
+
def erb(filename)
|
32
|
+
ERB.new(
|
33
|
+
File.read(File.join(TEMPLATE_DIR, filename)),
|
34
|
+
nil,
|
35
|
+
'-'
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def save(filepath)
|
40
|
+
File.open(filepath, 'w') do |file|
|
41
|
+
file << self.to_xml
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/eeepub/ncx.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module EeePub
|
2
|
+
class NCX < ContainerItem
|
3
|
+
template 'ncx.erb'
|
4
|
+
attr_accessor :uid,
|
5
|
+
:depth,
|
6
|
+
:total_page_count,
|
7
|
+
:max_page_number,
|
8
|
+
:doc_title,
|
9
|
+
:nav_points
|
10
|
+
|
11
|
+
def set_values(values)
|
12
|
+
super
|
13
|
+
@depth ||= 1
|
14
|
+
@total_page_count ||= 0
|
15
|
+
@max_page_number ||= 0
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/eeepub/ocf.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module EeePub
|
2
|
+
class OCF
|
3
|
+
class Container < ContainerItem
|
4
|
+
template 'container.xml.erb'
|
5
|
+
attr_accessor :rootfiles
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_accessor :dir, :container
|
9
|
+
|
10
|
+
def initialize(values)
|
11
|
+
values.each do |k, v|
|
12
|
+
self.send(:"#{k}=", v)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def make(output_path)
|
17
|
+
output_path = File.expand_path(output_path)
|
18
|
+
|
19
|
+
FileUtils.chdir(dir) do
|
20
|
+
File.open('mimetype', 'w') do |f|
|
21
|
+
f << 'application/epub+zip'
|
22
|
+
end
|
23
|
+
|
24
|
+
meta_inf = 'META-INF'
|
25
|
+
FileUtils.mkdir_p(meta_inf)
|
26
|
+
|
27
|
+
container.save(File.join(meta_inf, 'container.xml'))
|
28
|
+
|
29
|
+
%x(zip -X9 \"#{output_path}\" mimetype)
|
30
|
+
%x(zip -Xr9D \"#{output_path}\" * -xi mimetype)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/eeepub/opf.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
|
3
|
+
<rootfiles>
|
4
|
+
<%- rootfiles.each do |rootfile| -%>
|
5
|
+
<rootfile full-path="<%=h rootfile[:full_path] %>" media-type="<%=h rootfile[:media_type] %>"/>
|
6
|
+
<%- end -%>
|
7
|
+
</rootfiles>
|
8
|
+
</container>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
3
|
+
<head>
|
4
|
+
<meta name="dtb:uid" content="<%=h uid %>"/>
|
5
|
+
<meta name="dtb:depth" content="<%=h depth %>"/>
|
6
|
+
<meta name="dtb:totalPageCount" content="<%=h total_page_count %>"/>
|
7
|
+
<meta name="dtb:maxPageNumber" content="<%=h max_page_number %>"/>
|
8
|
+
</head>
|
9
|
+
<docTitle>
|
10
|
+
<text><%=h doc_title %></text>
|
11
|
+
</docTitle>
|
12
|
+
<navMap>
|
13
|
+
<%- nav_points.each do |nav| -%>
|
14
|
+
<navPoint id="<%=h nav[:id] %>" playOrder="<%=h nav[:play_order] %>">
|
15
|
+
<navLabel>
|
16
|
+
<text><%=h nav[:label] %></text>
|
17
|
+
</navLabel>
|
18
|
+
<content src="<%=h nav[:content] %>"/>
|
19
|
+
</navPoint>
|
20
|
+
<%- end -%>
|
21
|
+
</navMap>
|
22
|
+
</ncx>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
3
|
+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
4
|
+
<dc:title><%=h title %></dc:title>
|
5
|
+
<dc:language><%=h language %></dc:language>
|
6
|
+
<dc:identifier id="BookId"><%=h identifier %></dc:identifier>
|
7
|
+
<%- if date -%>
|
8
|
+
<dc:date><%=h date.to_s %></dc:data>
|
9
|
+
<%- end -%>
|
10
|
+
<%- if subject -%>
|
11
|
+
<dc:subject><%=h subject %></dc:subject>
|
12
|
+
<%- end -%>
|
13
|
+
<%- if description -%>
|
14
|
+
<dc:description><%=h description %></dc:description>
|
15
|
+
<%- end -%>
|
16
|
+
<%- if relation -%>
|
17
|
+
<dc:relation><%=h relation %></dc:relation>
|
18
|
+
<%- end -%>
|
19
|
+
<%- if creator -%>
|
20
|
+
<dc:creator opf:role="aut"><%=h creator %></dc:creator>
|
21
|
+
<%- end -%>
|
22
|
+
<%- if publisher -%>
|
23
|
+
<dc:publisher><%=h publisher %></dc:publisher>
|
24
|
+
<%- end -%>
|
25
|
+
<%- if rights -%>
|
26
|
+
<dc:rights><%=h rights %></dc:rights>
|
27
|
+
<%- end -%>
|
28
|
+
</metadata>
|
29
|
+
<manifest>
|
30
|
+
<%- items.each do |item| -%>
|
31
|
+
<item id="<%=h item[:id] %>" href="<%=h item[:href] %>" media-type="<%=h item[:media_type] %>" />
|
32
|
+
<%- end -%>
|
33
|
+
</manifest>
|
34
|
+
<spine toc="ncx">
|
35
|
+
<%- itemrefs.each do |itemref| -%>
|
36
|
+
<itemref idref="<%=h itemref[:idref] %>" />
|
37
|
+
<%- end -%>
|
38
|
+
</spine>
|
39
|
+
</package>
|
data/lib/eeepub.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
describe "EeePub::NCX" do
|
7
|
+
before do
|
8
|
+
@ncx = EeePub::NCX.new(
|
9
|
+
:uid => 'uid', :doc_title => 'title',
|
10
|
+
:nav_points => [
|
11
|
+
{:id => 'nav-1', :play_order => '1', :label => 'foo', :content => 'foo.html'},
|
12
|
+
{:id => 'nav-2', :play_order => '2', :label => 'bar', :content => 'bar.html'}
|
13
|
+
]
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should set default values' do
|
18
|
+
@ncx.depth.should == 1
|
19
|
+
@ncx.total_page_count.should == 0
|
20
|
+
@ncx.max_page_number.should == 0
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should make xml' do
|
24
|
+
doc = Nokogiri::XML(@ncx.to_xml)
|
25
|
+
head = doc.at('head')
|
26
|
+
head.should_not be_nil
|
27
|
+
|
28
|
+
head.at("//xmlns:meta[@name='dtb:uid']")['content'].should == 'uid'
|
29
|
+
head.at("//xmlns:meta[@name='dtb:depth']")['content'].should == '1'
|
30
|
+
head.at("//xmlns:meta[@name='dtb:totalPageCount']")['content'].should == '0'
|
31
|
+
head.at("//xmlns:meta[@name='dtb:maxPageNumber']")['content'].should == '0'
|
32
|
+
head.at("//xmlns:docTitle/xmlns:text").inner_text.should == 'title'
|
33
|
+
|
34
|
+
nav_map = doc.at('navMap')
|
35
|
+
nav_map.should_not be_nil
|
36
|
+
nav_map.search('navPoint').each_with_index do |nav_point, index|
|
37
|
+
expect = @ncx.nav_points[index]
|
38
|
+
nav_point.attribute('id').value.should == expect[:id]
|
39
|
+
nav_point.attribute('playOrder').value.should == expect[:play_order]
|
40
|
+
nav_point.at('navLabel').at('text').inner_text.should == expect[:label]
|
41
|
+
nav_point.at('content').attribute('src').value.should == expect[:content]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
describe "EeePub::OCF" do
|
7
|
+
before do
|
8
|
+
@tmpdir = File.join(Dir.tmpdir, 'eeepub_test')
|
9
|
+
FileUtils.mkdir_p(@tmpdir)
|
10
|
+
@container = EeePub::OCF::Container.new(
|
11
|
+
:rootfiles => [{:full_path => 'foo.opf', :media_type => 'application/oebps-package+xml'}]
|
12
|
+
)
|
13
|
+
@ocf = EeePub::OCF.new(:dir => @tmpdir, :container => @container)
|
14
|
+
end
|
15
|
+
|
16
|
+
after do
|
17
|
+
FileUtils.rm_rf(@tmpdir)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should make xml' do
|
21
|
+
doc = Nokogiri::XML(@container.to_xml)
|
22
|
+
rootfiles = doc.at('rootfiles')
|
23
|
+
rootfiles.should_not be_nil
|
24
|
+
rootfiles.search('rootfile').each_with_index do |rootfile, index|
|
25
|
+
expect = @container.rootfiles[index]
|
26
|
+
rootfile.attribute('full-path').value.should == expect[:full_path]
|
27
|
+
rootfile.attribute('media-type').value.should == expect[:media_type]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should make epub' do
|
32
|
+
output_path = File.join(Dir.tmpdir, 'eeepub_test.epub')
|
33
|
+
@ocf.make(output_path)
|
34
|
+
File.exists?(output_path)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "EeePub::OPF" do
|
4
|
+
before do
|
5
|
+
@opf = EeePub::OPF.new(
|
6
|
+
:title => 'title',
|
7
|
+
:language => 'ja',
|
8
|
+
:identifier => 'id',
|
9
|
+
:items => [
|
10
|
+
{:id => 'foo', :href => 'foo.html', :media_type => 'text/html'},
|
11
|
+
{:id => 'bar', :href => 'bar.html', :media_type => 'text/html'},
|
12
|
+
{:id => 'picture', :href => 'picture.png', :media_type => 'image/png'}
|
13
|
+
],
|
14
|
+
:itemrefs => [
|
15
|
+
{:idref => 'foo'},
|
16
|
+
{:idref => 'bar'}
|
17
|
+
]
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should export as xml' do
|
22
|
+
doc = Nokogiri::XML(@opf.to_xml)
|
23
|
+
metadata = doc.at('metadata')
|
24
|
+
metadata.should_not be_nil
|
25
|
+
[
|
26
|
+
['dc:title', @opf.title],
|
27
|
+
['dc:language', @opf.language],
|
28
|
+
['dc:identifier', @opf.identifier],
|
29
|
+
['dc:date', ''],
|
30
|
+
['dc:subject', ''],
|
31
|
+
['dc:description', ''],
|
32
|
+
['dc:relation', ''],
|
33
|
+
['dc:creator', ''],
|
34
|
+
['dc:publisher', ''],
|
35
|
+
['dc:rights', ''],
|
36
|
+
].each do |xpath, expect|
|
37
|
+
metadata.xpath(xpath,
|
38
|
+
'xmlns:dc' => "http://purl.org/dc/elements/1.1/").inner_text.should == expect
|
39
|
+
end
|
40
|
+
|
41
|
+
manifest = doc.at('manifest')
|
42
|
+
manifest.should_not be_nil
|
43
|
+
items = manifest.search('item')
|
44
|
+
items.size.should == 3
|
45
|
+
items.each_with_index do |item, index|
|
46
|
+
expect = @opf.items[index]
|
47
|
+
item.attribute('id').value.should == expect[:id]
|
48
|
+
item.attribute('href').value.should == expect[:href]
|
49
|
+
item.attribute('media-type').value.should == expect[:media_type]
|
50
|
+
end
|
51
|
+
|
52
|
+
spine = doc.at('spine')
|
53
|
+
spine.should_not be_nil
|
54
|
+
itemrefs = spine.search('itemref')
|
55
|
+
itemrefs.size.should == 2
|
56
|
+
itemrefs.each_with_index do |itemref, index|
|
57
|
+
expect = @opf.itemrefs[index]
|
58
|
+
itemref.attribute('idref').value.should == expect[:idref]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'set all metadata' do
|
63
|
+
before do
|
64
|
+
@opf.set_values(
|
65
|
+
:date => Date.today,
|
66
|
+
:subject => 'subject',
|
67
|
+
:description => 'description',
|
68
|
+
:relation => 'relation',
|
69
|
+
:creator => 'creator',
|
70
|
+
:publisher => 'publisher',
|
71
|
+
:rights => 'rights'
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should export as xml' do
|
76
|
+
doc = Nokogiri::XML(@opf.to_xml)
|
77
|
+
metadata = doc.at('metadata')
|
78
|
+
metadata.should_not be_nil
|
79
|
+
[
|
80
|
+
['dc:title', @opf.title],
|
81
|
+
['dc:language', @opf.language],
|
82
|
+
['dc:identifier', @opf.identifier],
|
83
|
+
['dc:date', @opf.date.to_s],
|
84
|
+
['dc:subject', 'subject'],
|
85
|
+
['dc:description', 'description'],
|
86
|
+
['dc:relation', 'relation'],
|
87
|
+
['dc:creator', 'creator'],
|
88
|
+
['dc:publisher', 'publisher'],
|
89
|
+
['dc:rights', 'rights'],
|
90
|
+
].each do |xpath, expect|
|
91
|
+
metadata.xpath(xpath,
|
92
|
+
'xmlns:dc' => "http://purl.org/dc/elements/1.1/").inner_text.should == expect
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/spec/eeepub_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'rubygems'
|
4
|
+
require 'eeepub'
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/autorun'
|
7
|
+
require 'nokogiri'
|
8
|
+
|
9
|
+
Spec::Runner.configure do |config|
|
10
|
+
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eeepub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- jugyo
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-05-02 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
description: EeePub is a Ruby ePub generator.
|
33
|
+
email: jugyo.org@gmail.com
|
34
|
+
executables: []
|
35
|
+
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files:
|
39
|
+
- LICENSE
|
40
|
+
- README.rdoc
|
41
|
+
files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
- Rakefile
|
45
|
+
- VERSION
|
46
|
+
- examples/simple.rb
|
47
|
+
- lib/eeepub.rb
|
48
|
+
- lib/eeepub/container_item.rb
|
49
|
+
- lib/eeepub/ncx.rb
|
50
|
+
- lib/eeepub/ocf.rb
|
51
|
+
- lib/eeepub/opf.rb
|
52
|
+
- lib/eeepub/templates/container.xml.erb
|
53
|
+
- lib/eeepub/templates/ncx.erb
|
54
|
+
- lib/eeepub/templates/opf.erb
|
55
|
+
- spec/eeepub/ncx_spec.rb
|
56
|
+
- spec/eeepub/ocf_spec.rb
|
57
|
+
- spec/eeepub/opf_spec.rb
|
58
|
+
- spec/eeepub_spec.rb
|
59
|
+
- spec/spec_helper.rb
|
60
|
+
has_rdoc: true
|
61
|
+
homepage: http://github.com/jugyo/eeepub
|
62
|
+
licenses: []
|
63
|
+
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options:
|
66
|
+
- --charset=UTF-8
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.3.6
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: ePub generator
|
90
|
+
test_files:
|
91
|
+
- spec/eeepub/ncx_spec.rb
|
92
|
+
- spec/eeepub/ocf_spec.rb
|
93
|
+
- spec/eeepub/opf_spec.rb
|
94
|
+
- spec/eeepub_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
96
|
+
- examples/simple.rb
|