ucf 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes.rdoc +8 -0
- data/Licence.rdoc +1 -1
- data/Rakefile +11 -7
- data/ReadMe.rdoc +15 -4
- data/lib/ucf/container.rb +8 -5
- data/lib/ucf/meta-inf.rb +37 -8
- data/lib/ucf/schema/OpenDocument-manifest-schema-v1.0-os.rng +111 -0
- data/lib/ucf/schema/container.rng +41 -0
- data/lib/ucf.rb +2 -0
- data/test/data/META-INF/container.xml +13 -0
- data/test/data/META-INF/manifest.xml +26 -0
- data/test/data/example.ucf +0 -0
- data/test/tc_create.rb +19 -3
- data/test/tc_managed_entries.rb +7 -5
- data/test/tc_read.rb +10 -1
- data/test/ts_ucf.rb +2 -1
- data/ucf.gemspec +13 -6
- data/version.yml +1 -1
- metadata +27 -7
data/Changes.rdoc
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
= Changes log for the UCF Ruby Gem
|
2
2
|
|
3
|
+
== Version 0.7.0
|
4
|
+
|
5
|
+
* Update to be able to use the newer zip-container gem.
|
6
|
+
* Add ability to use a custom mimetype.
|
7
|
+
* Verify META-INF/container.xml against its schema.
|
8
|
+
* Verify META-INF/manifest.xml against its schema.
|
9
|
+
* Add META-INF content to the example ucf file.
|
10
|
+
|
3
11
|
== Version 0.6.0
|
4
12
|
|
5
13
|
* Move to use version 0.9.0 of the zip-container library.
|
data/Licence.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
1
|
+
# Copyright (c) 2013, 2014 The University of Manchester, UK.
|
2
2
|
#
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
@@ -52,10 +52,11 @@ Jeweler::Tasks.new do |s|
|
|
52
52
|
s.platform = Gem::Platform::RUBY
|
53
53
|
s.summary = "Universal Container Format (UCF) Ruby Library"
|
54
54
|
s.description = "A Ruby library for working with Universal Container "\
|
55
|
-
"Format files - a type of EPUB document. See the "\
|
56
|
-
"
|
57
|
-
"for details. They are very similar, although not as restrictive, as
|
58
|
-
"
|
55
|
+
"Format files - a type of EPUB document. See the UCF specification "\
|
56
|
+
"(https://learn.adobe.com/wiki/display/PDFNAV/Universal+Container+Format)"\
|
57
|
+
" for details. They are very similar, although not as restrictive, as "\
|
58
|
+
"the EPUB Open Container Format (OCF) "\
|
59
|
+
"(http://www.idpf.org/epub/30/spec/epub30-ocf.html)."
|
59
60
|
s.require_path = "lib"
|
60
61
|
s.test_file = "test/ts_ucf.rb"
|
61
62
|
s.has_rdoc = true
|
@@ -64,7 +65,8 @@ Jeweler::Tasks.new do |s|
|
|
64
65
|
s.add_development_dependency('rake', '~> 10.0.4')
|
65
66
|
s.add_development_dependency('rdoc', '~> 4.0.1')
|
66
67
|
s.add_development_dependency('jeweler', '~> 1.8.4')
|
67
|
-
s.
|
68
|
+
s.add_development_dependency('nokogiri', '~> 1.6')
|
69
|
+
s.add_runtime_dependency('zip-container', '>= 0.9.0')
|
68
70
|
end
|
69
71
|
|
70
72
|
Rake::TestTask.new do |t|
|
@@ -75,7 +77,9 @@ end
|
|
75
77
|
|
76
78
|
RDoc::Task.new do |r|
|
77
79
|
r.main = "ReadMe.rdoc"
|
78
|
-
lib = Dir.glob("lib/**/*.rb")
|
80
|
+
lib = Dir.glob("lib/**/*.rb").delete_if do |item|
|
81
|
+
item.include?("meta-inf.rb")
|
82
|
+
end
|
79
83
|
r.rdoc_files.include("ReadMe.rdoc", "Licence.rdoc", "Changes.rdoc", lib)
|
80
84
|
r.options << "-t Universal Container Format Ruby Library version " +
|
81
85
|
"#{UCF::Version::STRING}"
|
data/ReadMe.rdoc
CHANGED
@@ -5,8 +5,9 @@ Contact:: mailto:support@mygrid.org.uk
|
|
5
5
|
Homepage:: http://mygrid.github.io/ruby-ucf
|
6
6
|
Source code:: https://github.com/myGrid/ruby-ucf
|
7
7
|
Licence:: BSD (See Licence file or http://www.opensource.org/licenses/bsd-license.php)
|
8
|
-
Copyright:: (c) 2013 The University of Manchester, UK
|
8
|
+
Copyright:: (c) 2013, 2014 The University of Manchester, UK
|
9
9
|
|
10
|
+
{<img src="https://badge.fury.io/rb/ucf.png" alt="Gem Version" />}[http://badge.fury.io/rb/ucf]
|
10
11
|
{<img src="https://codeclimate.com/github/myGrid/ruby-ucf.png" />}[https://codeclimate.com/github/myGrid/ruby-ucf]
|
11
12
|
|
12
13
|
== Synopsis
|
@@ -31,6 +32,16 @@ addition to this.
|
|
31
32
|
There are some examples of how to use the library provided in the examples
|
32
33
|
directory. See the contents of the tests directory for even more.
|
33
34
|
|
35
|
+
== Files in the META-INF directory
|
36
|
+
|
37
|
+
The UCF specification requires that files in the META-INF directory are
|
38
|
+
validated against a schema if they are present. If the
|
39
|
+
{nokogiri gem}[https://rubygems.org/gems/nokogiri] is available then this
|
40
|
+
library will use it to validate the contents of the <tt>container.xml</tt> and
|
41
|
+
<tt>manifest.xml</tt> files. This functionality is not enforced on the user in
|
42
|
+
case they are not using the META-INF directory and so would not need the extra
|
43
|
+
dependency on nokogiri.
|
44
|
+
|
34
45
|
== What this library can not do yet
|
35
46
|
|
36
47
|
The basic requirements of a UCF document are all implemented but there are a
|
@@ -40,9 +51,9 @@ number of optional features that are not yet provided.
|
|
40
51
|
documents that are resident on disk as the underlying
|
41
52
|
{rubyzip library}[https://github.com/aussiegeek/rubyzip] currently
|
42
53
|
{cannot do anything else}[https://github.com/aussiegeek/rubyzip/issues/74].
|
43
|
-
* Validation of file contents in the META-INF directory.
|
44
|
-
|
45
|
-
yet.
|
54
|
+
* Validation of all file contents in the META-INF directory. The
|
55
|
+
<tt>container.xml</tt> and <tt>manifest.xml</tt> files are validated but
|
56
|
+
others are not yet.
|
46
57
|
* Digital signatures (this feature has been deferred until a future revision
|
47
58
|
of the UCF specification. It will be supported by this gem when it is added
|
48
59
|
to the specification).
|
data/lib/ucf/container.rb
CHANGED
@@ -30,8 +30,7 @@
|
|
30
30
|
#
|
31
31
|
# Author: Robert Haines
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
#
|
35
34
|
module UCF
|
36
35
|
|
37
36
|
# This class represents a UCF document - also known as an EPUB and very
|
@@ -64,16 +63,20 @@ module UCF
|
|
64
63
|
|
65
64
|
# :call-seq:
|
66
65
|
# Container.create(filename) -> Container
|
66
|
+
# Container.create(filename, mimetype) -> Container
|
67
67
|
# Container.create(filename) {|container| ...}
|
68
|
+
# Container.create(filename, mimetype) {|container| ...}
|
68
69
|
#
|
69
|
-
# Create a new UCF document on disk and open it for editing.
|
70
|
+
# Create a new UCF document on disk and open it for editing. A custom
|
71
|
+
# mimetype for the container may be specified but if not the default,
|
72
|
+
# "application/epub+zip", will be used.
|
70
73
|
#
|
71
74
|
# Please see the
|
72
75
|
# {ZipContainer documentation}[http://mygrid.github.io/ruby-zip-container/]
|
73
76
|
# for much more information and a list of all the other methods available
|
74
77
|
# in this class. RDoc does not list inherited methods, unfortunately.
|
75
|
-
def Container.create(filename, &block)
|
76
|
-
super(filename,
|
78
|
+
def Container.create(filename, mimetype = DEFAULT_MIMETYPE, &block)
|
79
|
+
super(filename, mimetype, &block)
|
77
80
|
end
|
78
81
|
|
79
82
|
end
|
data/lib/ucf/meta-inf.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
1
|
+
# Copyright (c) 2013, 2014 The University of Manchester, UK.
|
2
2
|
#
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
@@ -30,7 +30,11 @@
|
|
30
30
|
#
|
31
31
|
# Author: Robert Haines
|
32
32
|
|
33
|
-
|
33
|
+
begin
|
34
|
+
require 'nokogiri'
|
35
|
+
rescue LoadError
|
36
|
+
# We don't care if there's no nokogiri but can't validate things without it.
|
37
|
+
end
|
34
38
|
|
35
39
|
module UCF
|
36
40
|
|
@@ -38,18 +42,43 @@ module UCF
|
|
38
42
|
# in a basic UCF Document.
|
39
43
|
class MetaInf < ZipContainer::ManagedDirectory
|
40
44
|
|
45
|
+
SCHEMA_DIR = ::File.join(::File.dirname(__FILE__), "schema")
|
46
|
+
CONTAINER_SCHEMA = ::File.join(SCHEMA_DIR, "container.rng")
|
47
|
+
MANIFEST_SCHEMA = ::File.join(SCHEMA_DIR, "OpenDocument-manifest-schema-v1.0-os.rng")
|
48
|
+
|
41
49
|
# :call-seq:
|
42
50
|
# new -> MetaInf
|
43
51
|
#
|
44
52
|
# Create a standard META-INF ManagedDirectory.
|
45
53
|
def initialize
|
46
54
|
super("META-INF", false,
|
47
|
-
[
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
55
|
+
[
|
56
|
+
File.new("container.xml", CONTAINER_SCHEMA),
|
57
|
+
File.new("manifest.xml", MANIFEST_SCHEMA),
|
58
|
+
File.new("metadata.xml"),
|
59
|
+
File.new("signatures.xml"),
|
60
|
+
File.new("encryption.xml"),
|
61
|
+
File.new("rights.xml")
|
62
|
+
]
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
class File < ZipContainer::ManagedFile
|
67
|
+
|
68
|
+
def initialize(name, schema = nil)
|
69
|
+
super(name, false)
|
70
|
+
|
71
|
+
@schema = nil
|
72
|
+
if defined?(::Nokogiri)
|
73
|
+
@schema = schema.nil? ? nil : Nokogiri::XML::RelaxNG(::File.open(schema))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
protected
|
78
|
+
|
79
|
+
def validate
|
80
|
+
@schema.nil? ? true : @schema.validate(Nokogiri::XML(contents)) == []
|
81
|
+
end
|
53
82
|
end
|
54
83
|
|
55
84
|
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!--
|
3
|
+
OASIS OpenDocument v1.0
|
4
|
+
OASIS standard, 1 May 2005
|
5
|
+
Relax-NG Manifest Schema
|
6
|
+
|
7
|
+
$Id$
|
8
|
+
|
9
|
+
© 2002-2005 OASIS Open
|
10
|
+
© 1999-2005 Sun Microsystems, Inc.
|
11
|
+
-->
|
12
|
+
|
13
|
+
<grammar
|
14
|
+
xmlns="http://relaxng.org/ns/structure/1.0"
|
15
|
+
|
16
|
+
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
|
17
|
+
|
18
|
+
xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
|
19
|
+
<define name="manifest">
|
20
|
+
<element name="manifest:manifest">
|
21
|
+
<oneOrMore>
|
22
|
+
<ref name="file-entry"/>
|
23
|
+
</oneOrMore>
|
24
|
+
</element>
|
25
|
+
</define>
|
26
|
+
|
27
|
+
<start>
|
28
|
+
<choice>
|
29
|
+
<ref name="manifest"/>
|
30
|
+
</choice>
|
31
|
+
</start>
|
32
|
+
<define name="file-entry">
|
33
|
+
<element name="manifest:file-entry">
|
34
|
+
<ref name="file-entry-attlist"/>
|
35
|
+
<optional>
|
36
|
+
<ref name="encryption-data"/>
|
37
|
+
</optional>
|
38
|
+
</element>
|
39
|
+
</define>
|
40
|
+
<define name="file-entry-attlist" combine="interleave">
|
41
|
+
<attribute name="manifest:full-path">
|
42
|
+
<data type="string"/>
|
43
|
+
</attribute>
|
44
|
+
</define>
|
45
|
+
<define name="file-entry-attlist" combine="interleave">
|
46
|
+
<optional>
|
47
|
+
<attribute name="manifest:size">
|
48
|
+
<data type="nonNegativeInteger"/>
|
49
|
+
</attribute>
|
50
|
+
</optional>
|
51
|
+
</define>
|
52
|
+
<define name="file-entry-attlist" combine="interleave">
|
53
|
+
<attribute name="manifest:media-type">
|
54
|
+
<data type="string"/>
|
55
|
+
</attribute>
|
56
|
+
</define>
|
57
|
+
<define name="encryption-data">
|
58
|
+
<element name="manifest:encryption-data">
|
59
|
+
<ref name="encryption-data-attlist"/>
|
60
|
+
<ref name="algorithm"/>
|
61
|
+
<ref name="key-derivation"/>
|
62
|
+
</element>
|
63
|
+
</define>
|
64
|
+
<define name="encryption-data-attlist" combine="interleave">
|
65
|
+
<attribute name="manifest:checksum-type">
|
66
|
+
<data type="string"/>
|
67
|
+
</attribute>
|
68
|
+
</define>
|
69
|
+
<define name="encryption-data-attlist" combine="interleave">
|
70
|
+
<attribute name="manifest:checksum">
|
71
|
+
<data type="base64Binary"/>
|
72
|
+
</attribute>
|
73
|
+
</define>
|
74
|
+
<define name="algorithm">
|
75
|
+
<element name="manifest:algorithm">
|
76
|
+
<ref name="algorithm-attlist"/>
|
77
|
+
<empty/>
|
78
|
+
</element>
|
79
|
+
</define>
|
80
|
+
<define name="algorithm-attlist" combine="interleave">
|
81
|
+
<attribute name="manifest:algorithm-name">
|
82
|
+
<data type="string"/>
|
83
|
+
</attribute>
|
84
|
+
</define>
|
85
|
+
<define name="algorithm-attlist" combine="interleave">
|
86
|
+
<attribute name="manifest:initialisation-vector">
|
87
|
+
<data type="base64Binary"/>
|
88
|
+
</attribute>
|
89
|
+
</define>
|
90
|
+
<define name="key-derivation">
|
91
|
+
<element name="manifest:key-derivation">
|
92
|
+
<ref name="key-derivation-attlist"/>
|
93
|
+
<empty/>
|
94
|
+
</element>
|
95
|
+
</define>
|
96
|
+
<define name="key-derivation-attlist" combine="interleave">
|
97
|
+
<attribute name="manifest:key-derivation-name">
|
98
|
+
<data type="string"/>
|
99
|
+
</attribute>
|
100
|
+
</define>
|
101
|
+
<define name="key-derivation-attlist" combine="interleave">
|
102
|
+
<attribute name="manifest:salt">
|
103
|
+
<data type="base64Binary"/>
|
104
|
+
</attribute>
|
105
|
+
</define>
|
106
|
+
<define name="key-derivation-attlist" combine="interleave">
|
107
|
+
<attribute name="manifest:iteration-count">
|
108
|
+
<data type="nonNegativeInteger"/>
|
109
|
+
</attribute>
|
110
|
+
</define>
|
111
|
+
</grammar>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<grammar ns="urn:oasis:names:tc:opendocument:xmlns:container" xmlns="http://relaxng.org/ns/structure/1.0">
|
3
|
+
<start>
|
4
|
+
<ref name="ucf.container"/>
|
5
|
+
</start>
|
6
|
+
<define name="ucf.container">
|
7
|
+
<element name="container">
|
8
|
+
<attribute name="version">
|
9
|
+
<value>1.0</value>
|
10
|
+
</attribute>
|
11
|
+
<optional>
|
12
|
+
<element name="rootfiles">
|
13
|
+
<oneOrMore>
|
14
|
+
<element name="rootfile">
|
15
|
+
<attribute name="full-path">
|
16
|
+
<text/>
|
17
|
+
</attribute>
|
18
|
+
<attribute name="media-type">
|
19
|
+
<text/>
|
20
|
+
</attribute>
|
21
|
+
</element>
|
22
|
+
</oneOrMore>
|
23
|
+
</element>
|
24
|
+
</optional>
|
25
|
+
<optional>
|
26
|
+
<element name="relationships">
|
27
|
+
<oneOrMore>
|
28
|
+
<element name="relationship">
|
29
|
+
<attribute name="type">
|
30
|
+
<text/>
|
31
|
+
</attribute>
|
32
|
+
<attribute name="target">
|
33
|
+
<text/>
|
34
|
+
</attribute>
|
35
|
+
</element>
|
36
|
+
</oneOrMore>
|
37
|
+
</element>
|
38
|
+
</optional>
|
39
|
+
</element>
|
40
|
+
</define>
|
41
|
+
</grammar>
|
data/lib/ucf.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
|
3
|
+
<rootfiles>
|
4
|
+
<rootfile full-path="OEBPS/As You Like It.opf"
|
5
|
+
media-type="application/oebps-package+xml" />
|
6
|
+
<rootfile full-path="OEBPS/As You Like It.pdf"
|
7
|
+
media-type="application/pdf" />
|
8
|
+
</rootfiles>
|
9
|
+
<relationships xmlns:pdf="http://ns.adobe.com/pdf/2006">
|
10
|
+
<relationship type="metadata" target="$path.xmp"/>
|
11
|
+
<relationship type="pdf:annotation" target="$path.ann"/>
|
12
|
+
</relationships>
|
13
|
+
</container>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
|
3
|
+
<manifest:manifest
|
4
|
+
xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
|
5
|
+
<manifest:file-entry
|
6
|
+
manifest:media-type="application/vnd.oasis.opendocument.text"
|
7
|
+
manifest:full-path="/"/>
|
8
|
+
<manifest:file-entry
|
9
|
+
manifest:media-type="application/vnd.sun.xml.ui.configuration"
|
10
|
+
manifest:full-path="Configurations2/"/>
|
11
|
+
<manifest:file-entry
|
12
|
+
manifest:media-type="" manifest:full-path="Pictures/"/>
|
13
|
+
<manifest:file-entry
|
14
|
+
manifest:media-type="text/xml" manifest:full-path="content.xml"/>
|
15
|
+
<manifest:file-entry
|
16
|
+
manifest:media-type="text/xml" manifest:full-path="styles.xml"/>
|
17
|
+
<manifest:file-entry
|
18
|
+
manifest:media-type="text/xml" manifest:full-path="meta.xml"/>
|
19
|
+
<manifest:file-entry
|
20
|
+
manifest:media-type=""
|
21
|
+
manifest:full-path="Thumbnails/thumbnail.png"/>
|
22
|
+
<manifest:file-entry
|
23
|
+
manifest:media-type="" manifest:full-path="Thumbnails/"/>
|
24
|
+
<manifest:file-entry
|
25
|
+
manifest:media-type="text/xml" manifest:full-path="settings.xml"/>
|
26
|
+
</manifest:manifest>
|
data/test/data/example.ucf
CHANGED
Binary file
|
data/test/tc_create.rb
CHANGED
@@ -46,7 +46,13 @@ class TestCreation < Test::Unit::TestCase
|
|
46
46
|
assert(c.on_disk?)
|
47
47
|
refute(c.in_memory?)
|
48
48
|
|
49
|
-
|
49
|
+
# At this point we can still use the version of zip-container that
|
50
|
+
# uses the old version of the rubyzip API...
|
51
|
+
if Gem.loaded_specs["zip-container"].version < Gem::Version.create("1.0")
|
52
|
+
assert(c.find_entry("mimetype").localHeaderOffset == 0)
|
53
|
+
else
|
54
|
+
assert(c.find_entry("mimetype").local_header_offset == 0)
|
55
|
+
end
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
@@ -58,15 +64,25 @@ class TestCreation < Test::Unit::TestCase
|
|
58
64
|
|
59
65
|
# Check creation of empty ucf files with a different mimetype.
|
60
66
|
def test_create_mimetype_file
|
67
|
+
mimetype = "application/x-something-really-odd"
|
68
|
+
|
61
69
|
Dir.mktmpdir do |dir|
|
62
70
|
filename = File.join(dir, "test.ucf")
|
63
71
|
|
64
72
|
assert_nothing_raised do
|
65
|
-
UCF::Container.create(filename) do |c|
|
73
|
+
UCF::Container.create(filename, mimetype) do |c|
|
66
74
|
assert(c.on_disk?)
|
67
75
|
refute(c.in_memory?)
|
68
76
|
|
69
|
-
|
77
|
+
# At this point we can still use the version of zip-container that
|
78
|
+
# uses the old version of the rubyzip API...
|
79
|
+
if Gem.loaded_specs["zip-container"].version < Gem::Version.create("1.0")
|
80
|
+
assert(c.find_entry("mimetype").localHeaderOffset == 0)
|
81
|
+
else
|
82
|
+
assert(c.find_entry("mimetype").local_header_offset == 0)
|
83
|
+
end
|
84
|
+
|
85
|
+
assert_equal mimetype, c.read("mimetype")
|
70
86
|
end
|
71
87
|
end
|
72
88
|
|
data/test/tc_managed_entries.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
1
|
+
# Copyright (c) 2013, 2014 The University of Manchester, UK.
|
2
2
|
#
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
@@ -104,7 +104,8 @@ class TestManagedEntries < Test::Unit::TestCase
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
# Check that a standard Container can be created
|
107
|
+
# Check that a standard UCF Container can be created and things within it
|
108
|
+
# are verified correctly.
|
108
109
|
def test_create_standard_container
|
109
110
|
Dir.mktmpdir do |dir|
|
110
111
|
filename = File.join(dir, "test.ucf")
|
@@ -114,10 +115,11 @@ class TestManagedEntries < Test::Unit::TestCase
|
|
114
115
|
c.mkdir("META-INF")
|
115
116
|
assert(c.file.exists?("META-INF"))
|
116
117
|
|
117
|
-
|
118
|
-
|
118
|
+
%w(container.xml manifest.xml).each do |file|
|
119
|
+
full_path = "META-INF/#{file}"
|
120
|
+
c.add(full_path, File.join($meta_inf_dir, file))
|
121
|
+
assert(c.file.exists?(full_path))
|
119
122
|
end
|
120
|
-
assert(c.file.exists?("META-INF/container.xml"))
|
121
123
|
end
|
122
124
|
end
|
123
125
|
|
data/test/tc_read.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
1
|
+
# Copyright (c) 2013, 2014 The University of Manchester, UK.
|
2
2
|
#
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
@@ -53,6 +53,15 @@ class TestRead < Test::Unit::TestCase
|
|
53
53
|
assert(UCF::Container.verify($ucf_empty))
|
54
54
|
end
|
55
55
|
|
56
|
+
# Check that the example ucf file does verify.
|
57
|
+
def test_verify_example_ucf
|
58
|
+
assert_nothing_raised(ZipContainer::MalformedContainerError, Zip::ZipError) do
|
59
|
+
UCF::Container.verify!($ucf_example)
|
60
|
+
end
|
61
|
+
|
62
|
+
assert(UCF::Container.verify($ucf_example))
|
63
|
+
end
|
64
|
+
|
56
65
|
# Check that the empty zip file does not verify.
|
57
66
|
def test_verify_empty_zip
|
58
67
|
assert_raise(ZipContainer::MalformedContainerError) do
|
data/test/ts_ucf.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
1
|
+
# Copyright (c) 2013, 2014 The University of Manchester, UK.
|
2
2
|
#
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
@@ -36,6 +36,7 @@ $ucf_empty = "test/data/empty.ucf"
|
|
36
36
|
$zip_empty = "test/data/empty.zip"
|
37
37
|
$ucf_compressed_mimetype = "test/data/compressed_mimetype.ucf"
|
38
38
|
$ucf_example = "test/data/example.ucf"
|
39
|
+
$meta_inf_dir = "test/data/META-INF"
|
39
40
|
|
40
41
|
# Run test cases.
|
41
42
|
require 'tc_create'
|
data/ucf.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "ucf"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.7.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Robert Haines"]
|
12
|
-
s.date = "
|
13
|
-
s.description = "A Ruby library for working with Universal Container Format files - a type of EPUB document. See the
|
12
|
+
s.date = "2014-01-03"
|
13
|
+
s.description = "A Ruby library for working with Universal Container Format files - a type of EPUB document. See the UCF specification (https://learn.adobe.com/wiki/display/PDFNAV/Universal+Container+Format) for details. They are very similar, although not as restrictive, as the EPUB Open Container Format (OCF) (http://www.idpf.org/epub/30/spec/epub30-ocf.html)."
|
14
14
|
s.email = ["support@mygrid.org.uk"]
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"Changes.rdoc",
|
@@ -28,6 +28,10 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/ucf.rb",
|
29
29
|
"lib/ucf/container.rb",
|
30
30
|
"lib/ucf/meta-inf.rb",
|
31
|
+
"lib/ucf/schema/OpenDocument-manifest-schema-v1.0-os.rng",
|
32
|
+
"lib/ucf/schema/container.rng",
|
33
|
+
"test/data/META-INF/container.xml",
|
34
|
+
"test/data/META-INF/manifest.xml",
|
31
35
|
"test/data/compressed_mimetype.ucf",
|
32
36
|
"test/data/empty.ucf",
|
33
37
|
"test/data/empty.zip",
|
@@ -55,18 +59,21 @@ Gem::Specification.new do |s|
|
|
55
59
|
s.add_development_dependency(%q<rake>, ["~> 10.0.4"])
|
56
60
|
s.add_development_dependency(%q<rdoc>, ["~> 4.0.1"])
|
57
61
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
58
|
-
s.
|
62
|
+
s.add_development_dependency(%q<nokogiri>, ["~> 1.6"])
|
63
|
+
s.add_runtime_dependency(%q<zip-container>, [">= 0.9.0"])
|
59
64
|
else
|
60
65
|
s.add_dependency(%q<rake>, ["~> 10.0.4"])
|
61
66
|
s.add_dependency(%q<rdoc>, ["~> 4.0.1"])
|
62
67
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
63
|
-
s.add_dependency(%q<
|
68
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.6"])
|
69
|
+
s.add_dependency(%q<zip-container>, [">= 0.9.0"])
|
64
70
|
end
|
65
71
|
else
|
66
72
|
s.add_dependency(%q<rake>, ["~> 10.0.4"])
|
67
73
|
s.add_dependency(%q<rdoc>, ["~> 4.0.1"])
|
68
74
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
69
|
-
s.add_dependency(%q<
|
75
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.6"])
|
76
|
+
s.add_dependency(%q<zip-container>, [">= 0.9.0"])
|
70
77
|
end
|
71
78
|
end
|
72
79
|
|
data/version.yml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ucf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -60,11 +60,27 @@ dependencies:
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.8.4
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: nokogiri
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.6'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.6'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: zip-container
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
68
84
|
- !ruby/object:Gem::Version
|
69
85
|
version: 0.9.0
|
70
86
|
type: :runtime
|
@@ -72,13 +88,13 @@ dependencies:
|
|
72
88
|
version_requirements: !ruby/object:Gem::Requirement
|
73
89
|
none: false
|
74
90
|
requirements:
|
75
|
-
- -
|
91
|
+
- - ! '>='
|
76
92
|
- !ruby/object:Gem::Version
|
77
93
|
version: 0.9.0
|
78
94
|
description: A Ruby library for working with Universal Container Format files - a
|
79
|
-
type of EPUB document. See the
|
80
|
-
for details. They are very similar, although not as restrictive, as the
|
81
|
-
Container Format (OCF)
|
95
|
+
type of EPUB document. See the UCF specification (https://learn.adobe.com/wiki/display/PDFNAV/Universal+Container+Format)
|
96
|
+
for details. They are very similar, although not as restrictive, as the EPUB Open
|
97
|
+
Container Format (OCF) (http://www.idpf.org/epub/30/spec/epub30-ocf.html).
|
82
98
|
email:
|
83
99
|
- support@mygrid.org.uk
|
84
100
|
executables: []
|
@@ -98,6 +114,10 @@ files:
|
|
98
114
|
- lib/ucf.rb
|
99
115
|
- lib/ucf/container.rb
|
100
116
|
- lib/ucf/meta-inf.rb
|
117
|
+
- lib/ucf/schema/OpenDocument-manifest-schema-v1.0-os.rng
|
118
|
+
- lib/ucf/schema/container.rng
|
119
|
+
- test/data/META-INF/container.xml
|
120
|
+
- test/data/META-INF/manifest.xml
|
101
121
|
- test/data/compressed_mimetype.ucf
|
102
122
|
- test/data/empty.ucf
|
103
123
|
- test/data/empty.zip
|