epub_reader 0.0.1

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.
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
3
+ xmlns:epub="http://www.idpf.org/2007/ops">
4
+ <head>
5
+ <meta charset="utf-8"></meta>
6
+ <link rel="stylesheet" type="text/css" href="wasteland.css" class="day" title="day"/>
7
+ <link rel="alternate stylesheet" type="text/css" href="wasteland-night.css" class="night" title="night"/>
8
+ </head>
9
+ <body>
10
+ <nav epub:type="toc" id="toc">
11
+ <ol>
12
+ <li><a href="wasteland-content.xhtml#ch1">I. THE BURIAL OF THE DEAD</a></li>
13
+ <li><a href="wasteland-content.xhtml#ch2">II. A GAME OF CHESS</a></li>
14
+ <li><a href="wasteland-content.xhtml#ch3">III. THE FIRE SERMON</a></li>
15
+ <li><a href="wasteland-content.xhtml#ch4">IV. DEATH BY WATER</a></li>
16
+ <li><a href="wasteland-content.xhtml#ch5">V. WHAT THE THUNDER SAID</a></li>
17
+ <li><a href="wasteland-content.xhtml#rearnotes">NOTES ON "THE WASTE LAND"</a></li>
18
+ </ol>
19
+ </nav>
20
+ <nav epub:type="landmarks">
21
+ <ol>
22
+ <li><a epub:type="frontmatter" href="wasteland-content.xhtml#frontmatter"
23
+ >frontmatter</a></li>
24
+ <li><a epub:type="bodymatter" href="wasteland-content.xhtml#bodymatter"
25
+ >bodymatter</a></li>
26
+ <li><a epub:type="backmatter" href="wasteland-content.xhtml#backmatter"
27
+ >backmatter</a></li>
28
+ </ol>
29
+ </nav>
30
+
31
+ </body>
32
+ </html>
@@ -0,0 +1,19 @@
1
+ @charset "UTF-8";
2
+ @import "wasteland.css";
3
+
4
+ body {
5
+ color: rgb(255,250,205);
6
+ background-color: rgb(20,20,20);
7
+ }
8
+
9
+ span.lnum {
10
+ color: rgb(175,170,125);
11
+ }
12
+
13
+ a.noteref {
14
+ color: rgb(120,120,120);
15
+ }
16
+
17
+ section#rearnotes a {
18
+ color: rgb(255,250,205);
19
+ }
@@ -0,0 +1,57 @@
1
+ @charset "UTF-8";
2
+ @namespace "http://www.w3.org/1999/xhtml";
3
+ @namespace epub "http://www.idpf.org/2007/ops";
4
+
5
+ body {
6
+ margin-left: 6em;
7
+ margin-right: 16em;
8
+ color: black;
9
+ font-family: times, 'times new roman', serif;
10
+ background-color: rgb(255,255,245);
11
+ line-height: 1.5em;
12
+ }
13
+
14
+ h2 {
15
+ margin-top: 5em;
16
+ margin-bottom: 2em;
17
+ }
18
+
19
+ h3 {
20
+ margin-top: 3em;
21
+ }
22
+
23
+ .linegroup {
24
+ margin-top: 1.6em;
25
+ }
26
+
27
+ span.lnum {
28
+ float: right;
29
+ color: gray;
30
+ font-size : 90%;
31
+ }
32
+
33
+ a.noteref {
34
+ color: rgb(215,215,195);
35
+ text-decoration: none;
36
+ margin-left: 0.5em;
37
+ margin-right: 0.5em;
38
+ }
39
+
40
+ section#rearnotes a {
41
+ color: black;
42
+ text-decoration: none;
43
+ border-bottom : 1px dotted gray;
44
+ margin-right: 0.8em;
45
+ }
46
+
47
+ .indent {
48
+ padding-left: 3em;
49
+ }
50
+
51
+ .indent2 {
52
+ padding-left: 5em;
53
+ }
54
+
55
+ *[epub|type~='dedication'] {
56
+ padding-left: 2em;
57
+ }
@@ -0,0 +1,49 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ncx xmlns:ncx="http://www.daisy.org/z3986/2005/ncx/" xmlns="http://www.daisy.org/z3986/2005/ncx/"
3
+ version="2005-1" xml:lang="en">
4
+ <head>
5
+ <meta name="dtb:uid" content="code.google.com.epub-samples.wasteland-basic"/>
6
+ </head>
7
+ <docTitle>
8
+ <text>The Waste Land</text>
9
+ </docTitle>
10
+ <navMap>
11
+ <!-- 2.01 NCX: playOrder is optional -->
12
+ <navPoint id="ch1">
13
+ <navLabel>
14
+ <text>I. THE BURIAL OF THE DEAD</text>
15
+ </navLabel>
16
+ <content src="wasteland-content.xhtml#ch1"/>
17
+ </navPoint>
18
+ <navPoint id="ch2">
19
+ <navLabel>
20
+ <text>II. A GAME OF CHESS</text>
21
+ </navLabel>
22
+ <content src="wasteland-content.xhtml#ch2"/>
23
+ </navPoint>
24
+ <navPoint id="ch3">
25
+ <navLabel>
26
+ <text>III. THE FIRE SERMON</text>
27
+ </navLabel>
28
+ <content src="wasteland-content.xhtml#ch3"/>
29
+ </navPoint>
30
+ <navPoint id="ch4">
31
+ <navLabel>
32
+ <text>IV. DEATH BY WATER</text>
33
+ </navLabel>
34
+ <content src="wasteland-content.xhtml#ch4"/>
35
+ </navPoint>
36
+ <navPoint id="ch5">
37
+ <navLabel>
38
+ <text>V. WHAT THE THUNDER SAID</text>
39
+ </navLabel>
40
+ <content src="wasteland-content.xhtml#ch5"/>
41
+ </navPoint>
42
+ <navPoint id="rearnotes">
43
+ <navLabel>
44
+ <text>NOTES ON "THE WASTE LAND"</text>
45
+ </navLabel>
46
+ <content src="wasteland-content.xhtml#rearnotes"/>
47
+ </navPoint>
48
+ </navMap>
49
+ </ncx>
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid" xml:lang="en-US" prefix="cc: http://creativecommons.org/ns#">
3
+ <metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
4
+ <dc:identifier id="uid">code.google.com.epub-samples.wasteland-basic</dc:identifier>
5
+ <dc:title>The Waste Land</dc:title>
6
+ <dc:creator>T.S. Eliot</dc:creator>
7
+ <dc:language>en-US</dc:language>
8
+ <dc:date>2011-09-01</dc:date>
9
+ <meta property="dcterms:modified">2012-01-18T12:47:00Z</meta>
10
+ <!-- rights expressions for the work as a whole -->
11
+ <dc:rights>This work is shared with the public using the Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.</dc:rights>
12
+ <link rel="cc:license" href="http://creativecommons.org/licenses/by-sa/3.0/"/>
13
+ <meta property="cc:attributionURL">http://code.google.com/p/epub-samples/</meta>
14
+ <!-- rights expression for the cover image -->
15
+ <link rel="cc:license" refines="#cover" href="http://creativecommons.org/licenses/by-sa/3.0/" />
16
+ <link rel="cc:attributionURL" refines="#cover" href="http://en.wikipedia.org/wiki/Simon_Fieldhouse" />
17
+ <!-- cover meta element included for 2.0 reading system compatibility: -->
18
+ <meta name="cover" content="cover"/>
19
+ </metadata>
20
+ <manifest>
21
+ <item id="t1" href="wasteland-content.xhtml" media-type="application/xhtml+xml" />
22
+ <item id="nav" href="wasteland-nav.xhtml" properties="nav" media-type="application/xhtml+xml" />
23
+ <item id="cover" href="wasteland-cover.jpg" media-type="image/jpeg" properties="cover-image" />
24
+ <item id="css" href="wasteland.css" media-type="text/css" />
25
+ <item id="css-night" href="wasteland-night.css" media-type="text/css" />
26
+ <!-- ncx included for 2.0 reading system compatibility: -->
27
+ <item id="ncx" href="wasteland.ncx" media-type="application/x-dtbncx+xml" />
28
+ </manifest>
29
+ <spine toc="ncx">
30
+ <itemref idref="t1" />
31
+ </spine>
32
+ </package>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
3
+ <rootfiles>
4
+ <rootfile full-path="EPUB/wasteland.opf"
5
+ media-type="application/oebps-package+xml"/>
6
+ </rootfiles>
7
+ </container>
@@ -0,0 +1 @@
1
+ application/epub+zip
Binary file
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe EpubReader::Image do
4
+ subject { EpubReader::Image }
5
+ let(:fixture_path) do
6
+ Pathname.new(File.expand_path(__FILE__)).join('..', 'fixtures')
7
+ end
8
+ let(:path) { fixture_path.join('epub20_unzipped', 'EPUB', 'wasteland-cover.jpg') }
9
+
10
+ describe '::new(path)' do
11
+ it 'takes a path to init' do
12
+ image = subject.new(path)
13
+ end
14
+
15
+ it 'raises if path not eixsts' do
16
+ path = Pathname.new('non-exists')
17
+ expect {
18
+ image = subject.new(path)
19
+ }.to raise_error(EpubReader::FileNotExistsException)
20
+ end
21
+ end
22
+
23
+ describe '#path' do
24
+ it 'returns the path' do
25
+ image = subject.new(path)
26
+
27
+ image.path.should == path
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ current_path = File.expand_path(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(current_path, '..'))
3
+ Dir['lib/**/*.rb'].each {|f| require f}
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+
3
+ describe EpubReader::TOCItem do
4
+ subject { EpubReader::TOCItem }
5
+
6
+ describe '::new(:title => title, :html_path => html_path)' do
7
+ it 'takes an title and html path to init' do
8
+ subject.new(:title => 'the-title', :html_path => Pathname.new('html-path'))
9
+ end
10
+ end
11
+
12
+ describe '#html_path' do
13
+ let(:html_path) { Pathname.new('html-path') }
14
+
15
+ it 'returns html_path given' do
16
+ toc_item = subject.new(:title => 'the-title', :html_path => html_path)
17
+ toc_item.html_path.should == html_path
18
+ end
19
+ end
20
+
21
+ describe '#title' do
22
+ it 'returns title passed in' do
23
+ toc_item = subject.new(:title => 'the-title', :html_path => 'whatever')
24
+
25
+ toc_item.title.should == 'the-title'
26
+ end
27
+ end
28
+
29
+ describe 'create_from(unzipped_path)' do
30
+ subject { EpubReader::TOCItem }
31
+ let(:unzipped_path) do
32
+ current_path = File.expand_path(File.dirname(__FILE__))
33
+ Pathname.new(current_path).join('fixtures', 'epub20_unzipped')
34
+ end
35
+ let(:ncx_path) do
36
+ ncx = Dir["#{unzipped_path}/**/*.ncx"].first
37
+ ncx_dirname = File.expand_path(File.dirname(ncx))
38
+ Pathname.new(ncx_dirname)
39
+ end
40
+
41
+ it 'raises if dir not exists' do
42
+ expect {
43
+ subject.create_from('non-exists')
44
+ }.to raise_error(EpubReader::DirectoryNotExistsException)
45
+ end
46
+
47
+ it 'returns items in toc.ncx' do
48
+ toc_items = subject.create_from(unzipped_path)
49
+ expected = [
50
+ {
51
+ :title => "I. THE BURIAL OF THE DEAD",
52
+ :html_path => ncx_path.join("wasteland-content.xhtml")
53
+ },
54
+ {
55
+ :title => "II. A GAME OF CHESS",
56
+ :html_path => ncx_path.join("wasteland-content.xhtml")
57
+ },
58
+ {
59
+ :title => "III. THE FIRE SERMON",
60
+ :html_path => ncx_path.join("wasteland-content.xhtml")
61
+ },
62
+ {
63
+ :title => "IV. DEATH BY WATER",
64
+ :html_path => ncx_path.join("wasteland-content.xhtml")
65
+ },
66
+ {
67
+ :title => "V. WHAT THE THUNDER SAID",
68
+ :html_path => ncx_path.join("wasteland-content.xhtml")
69
+ },
70
+ {
71
+ :title => 'NOTES ON "THE WASTE LAND"',
72
+ :html_path => ncx_path.join("wasteland-content.xhtml")
73
+ },
74
+ ]
75
+
76
+ toc_items.map do |i|
77
+ { :title => i.title, :html_path => i.html_path }
78
+ end.should == expected
79
+ end
80
+ end
81
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: epub_reader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yang-Hsing Lin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: epub_reader is a gem to parse epub file, including it's htmls and images
70
+ email:
71
+ - yanghsing.lin@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - epub_reader.gemspec
83
+ - lib/epub_reader.rb
84
+ - lib/epub_reader/entry.rb
85
+ - lib/epub_reader/epub.rb
86
+ - lib/epub_reader/errors.rb
87
+ - lib/epub_reader/image.rb
88
+ - lib/epub_reader/toc_item.rb
89
+ - lib/epub_reader/version.rb
90
+ - spec/entry_spec.rb
91
+ - spec/epub_spec.rb
92
+ - spec/fixtures/epub20.epub
93
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland-content.xhtml
94
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland-cover.jpg
95
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland-nav.xhtml
96
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland-night.css
97
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland.css
98
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland.ncx
99
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland.opf
100
+ - spec/fixtures/epub20_unzipped/META-INF/container.xml
101
+ - spec/fixtures/epub20_unzipped/epub20.epub
102
+ - spec/fixtures/epub20_unzipped/mimetype
103
+ - spec/fixtures/epub30.epub
104
+ - spec/image_spec.rb
105
+ - spec/spec_helper.rb
106
+ - spec/toc_item_spec.rb
107
+ homepage: ''
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.2.2
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: epub_reader is a gem to parse epub file, including it's htmls and images
131
+ test_files:
132
+ - spec/entry_spec.rb
133
+ - spec/epub_spec.rb
134
+ - spec/fixtures/epub20.epub
135
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland-content.xhtml
136
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland-cover.jpg
137
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland-nav.xhtml
138
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland-night.css
139
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland.css
140
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland.ncx
141
+ - spec/fixtures/epub20_unzipped/EPUB/wasteland.opf
142
+ - spec/fixtures/epub20_unzipped/META-INF/container.xml
143
+ - spec/fixtures/epub20_unzipped/epub20.epub
144
+ - spec/fixtures/epub20_unzipped/mimetype
145
+ - spec/fixtures/epub30.epub
146
+ - spec/image_spec.rb
147
+ - spec/spec_helper.rb
148
+ - spec/toc_item_spec.rb