gepub 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -18,6 +18,7 @@ a good-enough EPUB generator library.
18
18
  * ...and many other restrictions
19
19
 
20
20
  * note: GEPUB::Generator is now obsolete. use GEPUB::Book.
21
+ * GEPUB::Book does not create directory. GEPUB::Book accepts IO object, not File.
21
22
 
22
23
  == SYNOPSIS:
23
24
 
@@ -31,7 +32,7 @@ a good-enough EPUB generator library.
31
32
  epub = GEPUB::Book.new(title)
32
33
  epub.author="the author"
33
34
  epub.publisher="the publisher"
34
- epub.date = "2010-05-03"
35
+ epub.date = "2010-11-27"
35
36
  epub.identifier = "http://www.skoji.jp/testepub/2010-06-26"
36
37
 
37
38
  # create test contents files
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.3
data/gepub.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gepub}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["KOJIMA Satoshi"]
12
- s.date = %q{2010-07-06}
12
+ s.date = %q{2010-11-27}
13
13
  s.description = %q{an easy-to-use (and easy-to-implement) EPUB generator.}
14
14
  s.email = %q{skoji@skoji.jp}
15
15
  s.extra_rdoc_files = [
data/lib/gepub/book.rb CHANGED
@@ -12,10 +12,11 @@ module GEPUB
12
12
  def initialize(title, contents_prefix="")
13
13
  @metadata = {}
14
14
  @metadata[:identifier] = []
15
+ @metadata[:title] = title
16
+ @metadata[:gepub_version] = '0.1'
15
17
  @manifest = []
16
18
  @spine = []
17
19
  @toc = []
18
- @metadata[:title] = title
19
20
  @contents_prefix = contents_prefix # may insert "OEBPS"
20
21
  @contents_prefix = @contents_prefix + "/" if contents_prefix != ""
21
22
  @itemcount = 0
@@ -86,6 +87,12 @@ module GEPUB
86
87
  add_ref_to_item(href, itemid).add_content(io)
87
88
  end
88
89
 
90
+ def add_ordered_item(href, io, itemid = nil)
91
+ item = add_item(href, io, itemid)
92
+ @spine.push(item)
93
+ item
94
+ end
95
+
89
96
  def add_nav(item, text)
90
97
  @toc.push({ :item => item, :text => text})
91
98
  end
@@ -168,6 +175,10 @@ EOF
168
175
  end
169
176
  node['opf:scheme'] = id[:scheme]
170
177
  }
178
+ elsif (k == :gepub_version)
179
+ metadataelem << node = XML::Node.new("meta")
180
+ node['name'] = 'gepub version'
181
+ node['content'] = v
171
182
  else
172
183
  metadataelem << node = XML::Node.new("dc:#{k}",v)
173
184
  end
data/spec/gepub_spec.rb CHANGED
@@ -40,12 +40,11 @@ describe GEPUB::Book do
40
40
  @generator.identifier = "http://example.jp/foobar/"
41
41
  item1 = @generator.add_ref_to_item('text/foobar.html','c1')
42
42
  item1.add_content(StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c1</title></head><body><p>the first page</p></body></html>'))
43
-
44
- item2 = @generator.add_ref_to_item('text/barbar.html','c2')
45
- item2.add_content(StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c2</title></head><body><p>second page, whith is test chapter.</p></body></html>'))
46
-
47
43
  @generator.spine.push(item1)
48
- @generator.spine.push(item2)
44
+
45
+ item2 = @generator.add_ordered_item('text/barbar.html',
46
+ StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c2</title></head><body><p>second page, whith is test chapter.</p></body></html>'),
47
+ 'c2')
49
48
  @generator.add_nav(item2, 'test chapter')
50
49
  end
51
50
 
@@ -145,9 +144,11 @@ describe GEPUB::Book do
145
144
  opf.root.namespaces.default_prefix='a'
146
145
 
147
146
  metadata = opf.find_first('a:metadata')
148
- metacover = metadata.find_first('a:meta')
149
- metacover['name'].should == 'cover'
150
- metacover['content'].should == item.itemid
147
+ metas = metadata.find('a:meta').select {
148
+ |m| m['name'] == 'cover'
149
+ }
150
+ metas.length.should == 1
151
+ metas[0]['content'].should == item.itemid
151
152
  end
152
153
 
153
154
  it "should generate correct epub" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gepub
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - KOJIMA Satoshi
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-06 00:00:00 +09:00
18
+ date: 2010-11-27 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency