gepub 0.6.8.9 → 0.6.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0842819d24c9387921014eea4c75e30a5ecbd28
4
- data.tar.gz: 3210ee8a74fb4e95e00fe82798dddbcd5b12f5f5
3
+ metadata.gz: 2840238e6aba48557afd114e5aa9fe928429a821
4
+ data.tar.gz: abe8e9d1089ebe5c49f6b1ba33244a15477d816c
5
5
  SHA512:
6
- metadata.gz: 6953ffea49755dda0d1529398ffacdfeadfd1b33085a1e25763e4e569e8fe2d3f50f5180ae7922c1a2e72d1406ef120c49be3cbf0aac63a57b85ce75f69efeca
7
- data.tar.gz: ad37f2937b7e8cea8ee11259dc2edc074ef3c52ffcf401f22a4f24268063a7b0029a15085368aeb2735710f3aeb18cf38fc65a1f06d1f942ff0a13456e3bc520
6
+ metadata.gz: f0996df2489524bfcfbeaf277328d959545ed6ab9a8fa532228cdda0e57a7f38c9e87ddb2778a5a5d54811de5c9200a751f35797a3f1b2d6cc5792693bc5b0ed
7
+ data.tar.gz: 7160c790cb89236d70c467a2df05fe106894c4df43e2d32b06e16c8f23bff7bd0335a264ce463df0faa7ddb13c8b8802dfc2c0a92bc19843abe252da34b010c3
data/lib/gepub/builder.rb CHANGED
@@ -265,7 +265,10 @@ module GEPUB
265
265
  raise assert unless ['rtl', 'ltr', 'default'].member? val
266
266
  @book.page_progression_direction = val
267
267
  end
268
-
268
+ # specify version for ibooks
269
+ def ibooks_version(val)
270
+ @book.ibooks_version=val
271
+ end
269
272
  # set optional file.
270
273
  # val should be String or Hash.
271
274
  # if val is String, file is read from the File specified by string and stored in EPUB to the path specified by string.
@@ -46,7 +46,10 @@ module GEPUB
46
46
  @orientation = metanode
47
47
  when 'rendition:spread'
48
48
  @spread = metanode
49
+ when 'ibooks:version'
50
+ @ibooks_version = metanode
49
51
  end
52
+
50
53
  }
51
54
  }
52
55
  }
@@ -62,10 +65,11 @@ module GEPUB
62
65
  @namespaces['xmlns:opf'] = OPF_NS if @opf_version.to_f < 3.0
63
66
  @default_layout = 'reflowable'
64
67
  @default_orientation = 'auto'
65
- @spread = 'auto'
68
+ @default_spread = 'auto'
66
69
  @layout = NilContent
67
70
  @orientation = NilContent
68
71
  @spread = NilContent
72
+ @ibooks_version = NilContent
69
73
  yield self if block_given?
70
74
  end
71
75
 
@@ -285,6 +289,23 @@ module GEPUB
285
289
  @spread = Meta.new('meta', val, self, { 'property' => 'rendition:spread' })
286
290
  (@content_nodes['meta'] ||= []) << @spread
287
291
  end
292
+
293
+ def ibooks_version
294
+ @ibooks_version.content || ''
295
+ end
296
+
297
+ def ibooks_version=(val)
298
+ @ibooks_version = Meta.new('meta', val, self, { 'property' => 'ibooks:version' })
299
+ (@content_nodes['meta'] ||= []) << @ibooks_version
300
+ end
301
+
302
+ def rendition_specified?
303
+ @layout.content || @orientation.content || @spread.content
304
+ end
305
+
306
+ def ibooks_vocaburaly_specified?
307
+ @ibooks_version.content
308
+ end
288
309
 
289
310
  private
290
311
  def parse_node(ns, node)
data/lib/gepub/package.rb CHANGED
@@ -21,6 +21,8 @@ module GEPUB
21
21
  def_delegators :@metadata, :rendition_orientation=
22
22
  def_delegators :@metadata, :rendition_spread
23
23
  def_delegators :@metadata, :rendition_spread=
24
+ def_delegators :@metadata, :ibooks_version
25
+ def_delegators :@metadata, :ibooks_version=
24
26
 
25
27
  def_delegators :@spine, :page_progression_direction=
26
28
  def_delegators :@spine, :page_progression_direction
@@ -242,6 +244,14 @@ module GEPUB
242
244
  def rendition_enabled?
243
245
  @prefixes['rendition'] == 'http://www.idpf.org/vocab/rendition/#'
244
246
  end
247
+
248
+ def enable_ibooks_vocabulary
249
+ @prefixes['ibooks'] = 'http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/'
250
+ end
251
+
252
+ def ibooks_vocabulary_enabled?
253
+ @prefixes['ibooks'] == 'http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/'
254
+ end
245
255
 
246
256
  def opf_xml
247
257
  if version.to_f < 3.0 || @epub_backward_compat
@@ -259,6 +269,13 @@ module GEPUB
259
269
  }
260
270
  end
261
271
  end
272
+ if @metadata.rendition_specified? || @spine.rendition_specified?
273
+ enable_rendition
274
+ end
275
+ if @metadata.ibooks_vocaburaly_specified?
276
+ enable_ibooks_vocabulary
277
+ end
278
+
262
279
  builder = Nokogiri::XML::Builder.new {
263
280
  |xml|
264
281
  if @prefixes.size == 0
data/lib/gepub/spine.rb CHANGED
@@ -46,8 +46,13 @@ module GEPUB
46
46
  add_property 'page-spread-left'
47
47
  end
48
48
 
49
+ def rendition_specified?
50
+ @rendition_specified
51
+ end
52
+
49
53
  def set_rendition_param(name, val)
50
54
  add_property "rendition:#{name}-#{val}"
55
+ @rendition_specified = true
51
56
  end
52
57
 
53
58
  def rendition_layout=(val)
@@ -127,6 +132,10 @@ module GEPUB
127
132
  def <<(item)
128
133
  push item
129
134
  end
135
+
136
+ def rendition_specified?
137
+ @item_refs.select { |itemref| itemref.rendition_specified? }.size > 0
138
+ end
130
139
 
131
140
  def to_xml(builder)
132
141
  builder.spine(@attributes) {
data/lib/gepub/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module GEPUB
2
2
  # GEPUB gem version
3
- VERSION = "0.6.8.9"
3
+ VERSION = "0.6.9.0"
4
4
  end
data/spec/builder_spec.rb CHANGED
@@ -373,8 +373,29 @@ describe GEPUB::Builder do
373
373
  builder.instance_eval{ @book.spine.itemref_list[1].properties[0] }.should == 'rendition:layout-pre-paginated'
374
374
  builder.instance_eval{ @book.spine.itemref_list[1].properties[1] }.should == 'rendition:orientation-landscape'
375
375
  builder.instance_eval{ @book.spine.itemref_list[1].properties[2] }.should == 'rendition:spread-both'
376
+ builder.instance_eval{
377
+ xml = Nokogiri::XML::Document.parse @book.opf_xml
378
+ xml.root['prefix'].should == 'rendition: http://www.idpf.org/vocab/rendition/#'
379
+ }
376
380
  end
377
381
 
382
+ it 'whould handle ibooks version' do
383
+ workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
384
+ builder = GEPUB::Builder.new {
385
+ ibooks_version '1.1.1'
386
+ resources(:workdir => workdir) {
387
+ ordered {
388
+ file('text/cover.xhtml')
389
+ file('text/memo.txt')
390
+ }
391
+ }
392
+ }
393
+ builder.instance_eval{
394
+ xml = Nokogiri::XML::Document.parse @book.opf_xml
395
+ xml.root['prefix'].should == 'ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/'
396
+ xml.at_xpath("//xmlns:meta[@property='ibooks:version']").content.should == '1.1.1'
397
+ }
398
+ end
378
399
  it 'should handle fallback chain' do
379
400
  workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
380
401
  builder = GEPUB::Builder.new {
data/spec/package_spec.rb CHANGED
@@ -94,11 +94,22 @@ describe GEPUB::Package do
94
94
  package.rendition_spread = 'landscape'
95
95
  end
96
96
  xml = Nokogiri::XML::Document.parse package.opf_xml
97
+ xml.root['prefix'].should == 'rendition: http://www.idpf.org/vocab/rendition/#'
97
98
  xml.at_xpath("//xmlns:meta[@property='rendition:layout']").content.should == 'pre-paginated'
98
99
  xml.at_xpath("//xmlns:meta[@property='rendition:orientation']").content.should == 'portlait'
99
100
  xml.at_xpath("//xmlns:meta[@property='rendition:spread']").content.should == 'landscape'
100
101
  end
101
102
 
103
+ it 'should handle ibooks version' do
104
+ package = GEPUB::Package.new('OEBPS/package.opf') do
105
+ |package|
106
+ package.ibooks_version = '1.1.1'
107
+ end
108
+ xml = Nokogiri::XML::Document.parse package.opf_xml
109
+ xml.root['prefix'].should == 'ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/'
110
+ xml.at_xpath("//xmlns:meta[@property='ibooks:version']").content.should == '1.1.1'
111
+ end
112
+
102
113
  it 'should generate opf2.0' do
103
114
  opf = GEPUB::Package.new('OEBPS/package.opf', { 'version' => '2.0'}) {
104
115
  |opf|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gepub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.8.9
4
+ version: 0.6.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - KOJIMA Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-01 00:00:00.000000000 Z
11
+ date: 2013-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec