ucf 0.7.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTZhODA5Mzk1MDg1NWRlNzI4ZDk1M2IzZTEyNjAyNjVlNjYyYzNiZg==
5
+ data.tar.gz: !binary |-
6
+ YzBlMWZkNmI5M2M1MzgzOTAzYTYxYTBmOTZhZjZkNmYwOGExNTdjOA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDc2YTAxOGUwMTc2N2ZhZTg2ZjJjNzUxMjJmNWJjOGJhOTJhZTRkMDFjY2M2
10
+ YjExZTIwMzIyZThhMjY5NmExYjE5MmYzMWIxNzZjYWFhN2YwMGVlNWM1NWQ3
11
+ YmNlOTAyMTUwNmQ4MjNjY2NlOWVkYzFlZDdhZTI0MTE2YmZhMDM=
12
+ data.tar.gz: !binary |-
13
+ ZGNlZmI1ZTBlNjNkMWZmOTEyYzFlNWUzZGFiZDU2NmJhMjFkMDdlMGM1NmY4
14
+ YzQzMjI1NjA3MzFhYjk1Njc3Yjg4MDA3NGQyYTAyMDQ5OWU4OTkyMjRlOTY1
15
+ ZTY3MDUyOWM2ZDI3ZTNjNjkxYjllZmIyM2E4Y2Q5YzU5YmU4MmY=
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ pkg/
2
+ html/
3
+ coverage/
4
+ .buildpath
5
+ .project
6
+ .idea
7
+ .rvmrc
8
+ Gemfile.lock
9
+ example.zip
data/.ruby-gemset ADDED
@@ -0,0 +1,2 @@
1
+ ucf
2
+
data/.ruby-version ADDED
@@ -0,0 +1,2 @@
1
+ ruby-1.9.3
2
+
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.2
6
+ - ruby-head
7
+ - rbx-2
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: ruby-head
11
+ - rvm: rbx-2
data/Changes.rdoc CHANGED
@@ -1,5 +1,11 @@
1
1
  = Changes log for the UCF Ruby Gem
2
2
 
3
+ == Version 1.0.0
4
+
5
+ * Rename UCF::Container to UCF::File.
6
+ * Use released zip-container 2.0 gem.
7
+ * Remove UCF::Container compatibility.
8
+
3
9
  == Version 0.7.0
4
10
 
5
11
  * Update to be able to use the newer zip-container gem.
data/Gemfile ADDED
@@ -0,0 +1,35 @@
1
+ # Copyright (c) 2014 The University of Manchester, UK.
2
+ #
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice,
9
+ # this list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # * Neither the names of The University of Manchester nor the names of its
16
+ # contributors may be used to endorse or promote products derived from this
17
+ # software without specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ # POSSIBILITY OF SUCH DAMAGE.
30
+ #
31
+ # Author: Robert Haines
32
+
33
+ source "https://rubygems.org"
34
+
35
+ gemspec
data/Rakefile CHANGED
@@ -30,45 +30,12 @@
30
30
  #
31
31
  # Author: Robert Haines
32
32
 
33
- require 'rubygems'
34
- require 'rake'
35
- require 'rake/clean'
36
- require 'rake/testtask'
37
- require 'rdoc/task'
38
- require 'jeweler'
39
-
40
- # we need to add lib to the path because we're not installed yet!
41
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), "lib")
42
- require 'ucf'
33
+ require "bundler/gem_tasks"
34
+ require "rake/testtask"
35
+ require "rdoc/task"
43
36
 
44
37
  task :default => [:test]
45
38
 
46
- Jeweler::Tasks.new do |s|
47
- s.name = "ucf"
48
- s.version = UCF::Version::STRING
49
- s.authors = ["Robert Haines"]
50
- s.email = ["support@mygrid.org.uk"]
51
- s.homepage = "http://mygrid.github.io/ruby-ucf/"
52
- s.platform = Gem::Platform::RUBY
53
- s.summary = "Universal Container Format (UCF) Ruby Library"
54
- s.description = "A Ruby library for working with Universal Container "\
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)."
60
- s.require_path = "lib"
61
- s.test_file = "test/ts_ucf.rb"
62
- s.has_rdoc = true
63
- s.extra_rdoc_files = ["ReadMe.rdoc", "Licence.rdoc", "Changes.rdoc"]
64
- s.rdoc_options = ["-N", "--tab-width=2", "--main=ReadMe.rdoc"]
65
- s.add_development_dependency('rake', '~> 10.0.4')
66
- s.add_development_dependency('rdoc', '~> 4.0.1')
67
- s.add_development_dependency('jeweler', '~> 1.8.4')
68
- s.add_development_dependency('nokogiri', '~> 1.6')
69
- s.add_runtime_dependency('zip-container', '>= 0.9.0')
70
- end
71
-
72
39
  Rake::TestTask.new do |t|
73
40
  t.libs << "test"
74
41
  t.test_files = FileList['test/ts_ucf.rb']
data/ReadMe.rdoc CHANGED
@@ -9,6 +9,8 @@ Copyright:: (c) 2013, 2014 The University of Manchester, UK
9
9
 
10
10
  {<img src="https://badge.fury.io/rb/ucf.png" alt="Gem Version" />}[http://badge.fury.io/rb/ucf]
11
11
  {<img src="https://codeclimate.com/github/myGrid/ruby-ucf.png" />}[https://codeclimate.com/github/myGrid/ruby-ucf]
12
+ {<img src="https://travis-ci.org/myGrid/ruby-ucf.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/myGrid/ruby-ucf]
13
+ {<img src="https://coveralls.io/repos/myGrid/ruby-ucf/badge.png?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/myGrid/ruby-ucf?branch=master]
12
14
 
13
15
  == Synopsis
14
16
 
@@ -42,6 +44,16 @@ library will use it to validate the contents of the <tt>container.xml</tt> and
42
44
  case they are not using the META-INF directory and so would not need the extra
43
45
  dependency on nokogiri.
44
46
 
47
+ == Backwards incompatibility warning!
48
+
49
+ The UCF::Container class is deprecated in favour of UCF::File. These classes
50
+ are functionally identical; it is just a change of name. The new name brings
51
+ this API into closer alignment with the underlying
52
+ {zip-container API}[http://mygrid.github.io/ruby-zip-container/]
53
+ (ZipContainer::File).
54
+
55
+ UCF::Container is not available from version 1.0.0 onwards.
56
+
45
57
  == What this library can not do yet
46
58
 
47
59
  The basic requirements of a UCF document are all implemented but there are a
data/examples/create-ucf CHANGED
@@ -32,6 +32,7 @@
32
32
  # Author: Robert Haines
33
33
 
34
34
  require 'rubygems'
35
+ require 'bundler/setup'
35
36
  require 'ucf'
36
37
 
37
38
  def usage
data/examples/ucfinfo CHANGED
@@ -32,6 +32,7 @@
32
32
  # Author: Robert Haines
33
33
 
34
34
  require 'rubygems'
35
+ require 'bundler/setup'
35
36
  require 'ucf'
36
37
 
37
38
  def usage
data/examples/verify-ucf CHANGED
@@ -32,6 +32,7 @@
32
32
  # Author: Robert Haines
33
33
 
34
34
  require 'rubygems'
35
+ require 'bundler/setup'
35
36
  require 'ucf'
36
37
 
37
38
  def usage
data/lib/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
  #
@@ -30,28 +30,20 @@
30
30
  #
31
31
  # Author: Robert Haines
32
32
 
33
- require 'yaml'
33
+ require 'rubygems'
34
+ require 'bundler/setup'
35
+
34
36
  require 'zip-container'
35
37
 
38
+ require 'ucf/version'
36
39
  require 'ucf/meta-inf'
37
- require 'ucf/container'
40
+ require 'ucf/file'
38
41
 
39
42
  # This is a ruby library to read and write UCF files in PK Zip format. See the
40
- # UCF::Container class for more information.
43
+ # UCF::File class for more information.
41
44
  #
42
45
  # See
43
46
  # {the UCF specification}[https://learn.adobe.com/wiki/display/PDFNAV/Universal+Container+Format]
44
47
  # for more details.
45
48
  module UCF
46
-
47
- # Library version information.
48
- module Version
49
- # Version information in a Hash
50
- INFO = YAML.load_file(File.join(File.dirname(__FILE__), "..",
51
- "version.yml"))
52
-
53
- # Version number as a String
54
- STRING = [:major, :minor, :patch].map {|d| INFO[d]}.compact.join('.')
55
- end
56
-
57
49
  end
@@ -33,20 +33,20 @@
33
33
  #
34
34
  module UCF
35
35
 
36
- # This class represents a UCF document - also known as an EPUB and very
36
+ # This class represents a UCF document file - also known as an EPUB and very
37
37
  # similar to the
38
38
  # {EPUB Open Container Format (OCF)}[http://www.idpf.org/epub/30/spec/epub30-ocf.html].
39
39
  # See the
40
40
  # {UCF specification}[https://learn.adobe.com/wiki/display/PDFNAV/Universal+Container+Format]
41
41
  # for more details.
42
42
  #
43
- # This class is a specialization of ZipContainer so you should see the
43
+ # This class is a specialization of ZipContainer::File so you should see the
44
44
  # {ZipContainer documentation}[http://mygrid.github.io/ruby-zip-container/]
45
45
  # for much more information and a list of all the other methods available in
46
46
  # this class. RDoc does not list inherited methods, unfortunately.
47
47
  #
48
48
  # There are code examples available with the source code of this library.
49
- class Container < ZipContainer::Container
49
+ class File < ZipContainer::File
50
50
 
51
51
  private_class_method :new
52
52
 
@@ -62,12 +62,12 @@ module UCF
62
62
  # :startdoc:
63
63
 
64
64
  # :call-seq:
65
- # Container.create(filename) -> Container
66
- # Container.create(filename, mimetype) -> Container
67
- # Container.create(filename) {|container| ...}
68
- # Container.create(filename, mimetype) {|container| ...}
65
+ # create(filename) -> UCF::File
66
+ # create(filename, mimetype) -> UCF::FILE
67
+ # create(filename) {|file| ...}
68
+ # create(filename, mimetype) {|file| ...}
69
69
  #
70
- # Create a new UCF document on disk and open it for editing. A custom
70
+ # Create a new UCF document file on disk and open it for editing. A custom
71
71
  # mimetype for the container may be specified but if not the default,
72
72
  # "application/epub+zip", will be used.
73
73
  #
@@ -75,7 +75,7 @@ module UCF
75
75
  # {ZipContainer documentation}[http://mygrid.github.io/ruby-zip-container/]
76
76
  # for much more information and a list of all the other methods available
77
77
  # in this class. RDoc does not list inherited methods, unfortunately.
78
- def Container.create(filename, mimetype = DEFAULT_MIMETYPE, &block)
78
+ def self.create(filename, mimetype = DEFAULT_MIMETYPE, &block)
79
79
  super(filename, mimetype, &block)
80
80
  end
81
81
 
data/lib/ucf/meta-inf.rb CHANGED
@@ -51,7 +51,7 @@ module UCF
51
51
  #
52
52
  # Create a standard META-INF ManagedDirectory.
53
53
  def initialize
54
- super("META-INF", false,
54
+ super("META-INF", :required => false, :entries =>
55
55
  [
56
56
  File.new("container.xml", CONTAINER_SCHEMA),
57
57
  File.new("manifest.xml", MANIFEST_SCHEMA),
@@ -66,7 +66,7 @@ module UCF
66
66
  class File < ZipContainer::ManagedFile
67
67
 
68
68
  def initialize(name, schema = nil)
69
- super(name, false)
69
+ super(name, :required => false)
70
70
 
71
71
  @schema = nil
72
72
  if defined?(::Nokogiri)
@@ -0,0 +1,46 @@
1
+ # Copyright (c) 2014 The University of Manchester, UK.
2
+ #
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice,
9
+ # this list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # * Neither the names of The University of Manchester nor the names of its
16
+ # contributors may be used to endorse or promote products derived from this
17
+ # software without specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ # POSSIBILITY OF SUCH DAMAGE.
30
+ #
31
+ # Author: Robert Haines
32
+
33
+ require 'yaml'
34
+
35
+ module UCF
36
+
37
+ # Library version information.
38
+ module Version
39
+ # Version information in a Hash
40
+ INFO = YAML.load_file(File.join(File.dirname(__FILE__), "..", "..",
41
+ "version.yml"))
42
+
43
+ # Version number as a String
44
+ STRING = [:major, :minor, :patch].map {|d| INFO[d]}.compact.join('.')
45
+ end
46
+ end
data/test/tc_create.rb CHANGED
@@ -42,7 +42,7 @@ class TestCreation < Test::Unit::TestCase
42
42
  filename = File.join(dir, "test.ucf")
43
43
 
44
44
  assert_nothing_raised do
45
- UCF::Container.create(filename) do |c|
45
+ UCF::File.create(filename) do |c|
46
46
  assert(c.on_disk?)
47
47
  refute(c.in_memory?)
48
48
 
@@ -57,7 +57,7 @@ class TestCreation < Test::Unit::TestCase
57
57
  end
58
58
 
59
59
  assert_nothing_raised(ZipContainer::MalformedContainerError, Zip::ZipError) do
60
- UCF::Container.verify!(filename)
60
+ UCF::File.verify!(filename)
61
61
  end
62
62
  end
63
63
  end
@@ -70,7 +70,7 @@ class TestCreation < Test::Unit::TestCase
70
70
  filename = File.join(dir, "test.ucf")
71
71
 
72
72
  assert_nothing_raised do
73
- UCF::Container.create(filename, mimetype) do |c|
73
+ UCF::File.create(filename, mimetype) do |c|
74
74
  assert(c.on_disk?)
75
75
  refute(c.in_memory?)
76
76
 
@@ -87,7 +87,7 @@ class TestCreation < Test::Unit::TestCase
87
87
  end
88
88
 
89
89
  assert_nothing_raised(ZipContainer::MalformedContainerError, Zip::ZipError) do
90
- UCF::Container.verify!(filename)
90
+ UCF::File.verify!(filename)
91
91
  end
92
92
  end
93
93
  end
@@ -99,7 +99,7 @@ class TestCreation < Test::Unit::TestCase
99
99
  filename = File.join(dir, "test.ucf")
100
100
 
101
101
  assert_nothing_raised do
102
- UCF::Container.create(filename) do |ucf|
102
+ UCF::File.create(filename) do |ucf|
103
103
  assert(ucf.on_disk?)
104
104
  refute(ucf.in_memory?)
105
105
 
@@ -130,7 +130,7 @@ class TestCreation < Test::Unit::TestCase
130
130
  end
131
131
 
132
132
  assert_nothing_raised(ZipContainer::MalformedContainerError, Zip::ZipError) do
133
- UCF::Container.open(filename) do |ucf|
133
+ UCF::File.open(filename) do |ucf|
134
134
  assert(ucf.on_disk?)
135
135
  refute(ucf.in_memory?)
136
136
 
@@ -35,33 +35,37 @@ require 'tmpdir'
35
35
  require 'ucf'
36
36
 
37
37
  # Classes to test managed entries.
38
- class ManagedUCF < UCF::Container
38
+ class ManagedUCF < UCF::File
39
39
 
40
40
  private_class_method :new
41
41
 
42
42
  def initialize(filename)
43
43
  super(filename)
44
- register_managed_entry(ZipContainer::ManagedDirectory.new("src", true))
44
+ register_managed_entry(ZipContainer::ManagedDirectory.new("src",
45
+ :required => true))
45
46
  register_managed_entry(ZipContainer::ManagedDirectory.new("test"))
46
47
  register_managed_entry(ZipContainer::ManagedDirectory.new("lib"))
47
- register_managed_entry(ZipContainer::ManagedFile.new("index.html", true))
48
+ register_managed_entry(ZipContainer::ManagedFile.new("index.html",
49
+ :required => true))
48
50
  end
49
51
 
50
52
  end
51
53
 
52
- class ExampleUCF < UCF::Container
54
+ class ExampleUCF < UCF::File
53
55
 
54
56
  private_class_method :new
55
57
 
56
58
  def initialize(filename)
57
59
  super(filename)
58
- register_managed_entry(ZipContainer::ManagedDirectory.new("dir", true))
59
- register_managed_entry(ZipContainer::ManagedFile.new("greeting.txt", true))
60
+ register_managed_entry(ZipContainer::ManagedDirectory.new("dir",
61
+ :required => true))
62
+ register_managed_entry(ZipContainer::ManagedFile.new("greeting.txt",
63
+ :required => true))
60
64
  end
61
65
 
62
66
  end
63
67
 
64
- class ExampleUCF2 < UCF::Container
68
+ class ExampleUCF2 < UCF::File
65
69
 
66
70
  private_class_method :new
67
71
 
@@ -70,7 +74,7 @@ class ExampleUCF2 < UCF::Container
70
74
 
71
75
  valid = Proc.new { |contents| contents.match(/[Hh]ello/) }
72
76
  register_managed_entry(ZipContainer::ManagedFile.new("greeting.txt",
73
- true, valid))
77
+ :required => true, :validation_proc => valid))
74
78
  end
75
79
 
76
80
  end
@@ -111,7 +115,7 @@ class TestManagedEntries < Test::Unit::TestCase
111
115
  filename = File.join(dir, "test.ucf")
112
116
 
113
117
  assert_nothing_raised do
114
- UCF::Container.create(filename) do |c|
118
+ UCF::File.create(filename) do |c|
115
119
  c.mkdir("META-INF")
116
120
  assert(c.file.exists?("META-INF"))
117
121
 
@@ -124,7 +128,7 @@ class TestManagedEntries < Test::Unit::TestCase
124
128
  end
125
129
 
126
130
  assert_nothing_raised(ZipContainer::MalformedContainerError) do
127
- UCF::Container.verify!(filename)
131
+ UCF::File.verify!(filename)
128
132
  end
129
133
  end
130
134
  end
@@ -176,7 +180,7 @@ class TestManagedEntries < Test::Unit::TestCase
176
180
  Dir.mktmpdir do |dir|
177
181
  filename = File.join(dir, "test.ucf")
178
182
 
179
- assert_nothing_raised do
183
+ #assert_nothing_raised do
180
184
  ExampleUCF2.create(filename) do |c|
181
185
  assert_raises(ZipContainer::MalformedContainerError) do
182
186
  c.verify!
@@ -198,7 +202,7 @@ class TestManagedEntries < Test::Unit::TestCase
198
202
  c.verify!
199
203
  end
200
204
  end
201
- end
205
+ #end
202
206
 
203
207
  assert(ExampleUCF2.verify(filename))
204
208
  assert_nothing_raised(ZipContainer::MalformedContainerError) do
data/test/tc_read.rb CHANGED
@@ -38,46 +38,46 @@ class TestRead < Test::Unit::TestCase
38
38
  # Check that the null file does not verify.
39
39
  def test_verify_null_file
40
40
  assert_raise(Zip::ZipError) do
41
- UCF::Container.verify!($file_null)
41
+ UCF::File.verify!($file_null)
42
42
  end
43
43
 
44
- refute(UCF::Container.verify($file_null))
44
+ refute(UCF::File.verify($file_null))
45
45
  end
46
46
 
47
47
  # Check that the empty ucf file does verify.
48
48
  def test_verify_empty_ucf
49
49
  assert_nothing_raised(ZipContainer::MalformedContainerError, Zip::ZipError) do
50
- UCF::Container.verify!($ucf_empty)
50
+ UCF::File.verify!($ucf_empty)
51
51
  end
52
52
 
53
- assert(UCF::Container.verify($ucf_empty))
53
+ assert(UCF::File.verify($ucf_empty))
54
54
  end
55
55
 
56
56
  # Check that the example ucf file does verify.
57
57
  def test_verify_example_ucf
58
58
  assert_nothing_raised(ZipContainer::MalformedContainerError, Zip::ZipError) do
59
- UCF::Container.verify!($ucf_example)
59
+ UCF::File.verify!($ucf_example)
60
60
  end
61
61
 
62
- assert(UCF::Container.verify($ucf_example))
62
+ assert(UCF::File.verify($ucf_example))
63
63
  end
64
64
 
65
65
  # Check that the empty zip file does not verify.
66
66
  def test_verify_empty_zip
67
67
  assert_raise(ZipContainer::MalformedContainerError) do
68
- UCF::Container.verify!($zip_empty)
68
+ UCF::File.verify!($zip_empty)
69
69
  end
70
70
 
71
- refute(UCF::Container.verify($zip_empty))
71
+ refute(UCF::File.verify($zip_empty))
72
72
  end
73
73
 
74
74
  # Check that a compressed mimetype file is detected.
75
75
  def test_verify_compressed_mimetype
76
76
  assert_raise(ZipContainer::MalformedContainerError) do
77
- UCF::Container.verify!($ucf_compressed_mimetype)
77
+ UCF::File.verify!($ucf_compressed_mimetype)
78
78
  end
79
79
 
80
- refute(UCF::Container.verify($ucf_compressed_mimetype))
80
+ refute(UCF::File.verify($ucf_compressed_mimetype))
81
81
  end
82
82
 
83
83
  # Check the raw mimetype bytes
@@ -92,7 +92,7 @@ class TestRead < Test::Unit::TestCase
92
92
  # Check reading files out of a ucf file and make sure we don't change it.
93
93
  def test_read_files_from_ucf
94
94
  assert_nothing_raised(ZipContainer::MalformedContainerError, Zip::ZipError) do
95
- UCF::Container.open($ucf_example) do |ucf|
95
+ UCF::File.open($ucf_example) do |ucf|
96
96
  assert(ucf.on_disk?)
97
97
  refute(ucf.in_memory?)
98
98
 
@@ -34,7 +34,7 @@ require 'test/unit'
34
34
  require 'ucf'
35
35
 
36
36
  # A class to test the overriding of reserved and managed names.
37
- class NewUCF < UCF::Container
37
+ class NewUCF < UCF::File
38
38
 
39
39
  private_class_method :new
40
40
 
@@ -64,7 +64,7 @@ class TestReservedNames < Test::Unit::TestCase
64
64
  # Check the reserved names stuff all works correctly, baring in mind that
65
65
  # such comparisons for UCF documents should be case sensitive.
66
66
  def test_reserved_names
67
- UCF::Container.open($ucf_example) do |ucf|
67
+ UCF::File.open($ucf_example) do |ucf|
68
68
  assert_equal(1, ucf.reserved_names.length)
69
69
  assert_equal(["mimetype"], ucf.reserved_names)
70
70
  assert_equal(6, ucf.managed_files.length)
@@ -148,7 +148,7 @@ class TestReservedNames < Test::Unit::TestCase
148
148
 
149
149
  # Check that nothing happens when trying to delete the mimetype file.
150
150
  def test_delete_mimetype
151
- UCF::Container.open($ucf_example) do |ucf|
151
+ UCF::File.open($ucf_example) do |ucf|
152
152
  assert(ucf.file.exists?("mimetype"))
153
153
  assert_nil(ucf.remove("mimetype"))
154
154
  assert(ucf.file.exists?("mimetype"))
@@ -157,7 +157,7 @@ class TestReservedNames < Test::Unit::TestCase
157
157
 
158
158
  # Check that nothing happens when trying to rename the mimetype file.
159
159
  def test_rename_mimetype
160
- UCF::Container.open($ucf_example) do |ucf|
160
+ UCF::File.open($ucf_example) do |ucf|
161
161
  assert(ucf.file.exists?("mimetype"))
162
162
  assert_nil(ucf.rename("mimetype", "something-else"))
163
163
  assert(ucf.file.exists?("mimetype"))
@@ -168,7 +168,7 @@ class TestReservedNames < Test::Unit::TestCase
168
168
  # Check that nothing happens when trying to replace the contents of the
169
169
  # mimetype file.
170
170
  def test_replace_mimetype
171
- UCF::Container.open($ucf_example) do |ucf|
171
+ UCF::File.open($ucf_example) do |ucf|
172
172
  assert(ucf.file.exists?("mimetype"))
173
173
  assert_nil(ucf.replace("mimetype", $zip_empty))
174
174
  assert_equal("application/epub+zip", ucf.file.read("mimetype"))
@@ -178,7 +178,7 @@ class TestReservedNames < Test::Unit::TestCase
178
178
  # Check that an exception is raised when trying to add file with a reserved
179
179
  # name.
180
180
  def test_add_reserved
181
- UCF::Container.open($ucf_empty) do |ucf|
181
+ UCF::File.open($ucf_empty) do |ucf|
182
182
  assert_raises(ZipContainer::ReservedNameClashError) do
183
183
  ucf.add("META-INF", $zip_empty)
184
184
  end
@@ -210,7 +210,7 @@ class TestReservedNames < Test::Unit::TestCase
210
210
  # Check that the META-INF directory is detected as non-existent when trying
211
211
  # to delete it.
212
212
  def test_delete_metainf
213
- UCF::Container.open($ucf_example) do |ucf|
213
+ UCF::File.open($ucf_example) do |ucf|
214
214
  assert_raises(Errno::ENOENT) do
215
215
  ucf.remove("META-INF")
216
216
  end
@@ -220,7 +220,7 @@ class TestReservedNames < Test::Unit::TestCase
220
220
  # Check that the META-INF directory is detected as non-existent when trying
221
221
  # to rename it.
222
222
  def test_rename_metainf
223
- UCF::Container.open($ucf_example) do |ucf|
223
+ UCF::File.open($ucf_example) do |ucf|
224
224
  assert_raises(Errno::ENOENT) do
225
225
  ucf.rename("META-INF", "something-else")
226
226
  end
@@ -230,7 +230,7 @@ class TestReservedNames < Test::Unit::TestCase
230
230
  # Check that an exception is raised when trying to create a directory with a
231
231
  # reserved name.
232
232
  def test_mkdir_reserved
233
- UCF::Container.open($ucf_empty) do |ucf|
233
+ UCF::File.open($ucf_empty) do |ucf|
234
234
  assert_raises(ZipContainer::ReservedNameClashError) do
235
235
  ucf.mkdir("mimetype")
236
236
  end
@@ -269,7 +269,7 @@ class TestReservedNames < Test::Unit::TestCase
269
269
 
270
270
  # Check that a file cannot be renamed to one of the reserved names.
271
271
  def test_rename_to_reserved
272
- UCF::Container.open($ucf_example) do |ucf|
272
+ UCF::File.open($ucf_example) do |ucf|
273
273
  assert_raises(ZipContainer::ReservedNameClashError) do
274
274
  ucf.rename("dir/code.rb", "mimetype")
275
275
  end
@@ -293,7 +293,7 @@ class TestReservedNames < Test::Unit::TestCase
293
293
  # Check that the ruby-like File and Dir classes respect reserved and managed
294
294
  # names.
295
295
  def test_file_dir_ops_reserved
296
- UCF::Container.open($ucf_empty) do |ucf|
296
+ UCF::File.open($ucf_empty) do |ucf|
297
297
  assert_raises(ZipContainer::ReservedNameClashError) do
298
298
  ucf.file.open("META-INF", "w") do |f|
299
299
  f.puts "TESTING"
data/test/ts_ucf.rb CHANGED
@@ -30,6 +30,9 @@
30
30
  #
31
31
  # Author: Robert Haines
32
32
 
33
+ require "coveralls"
34
+ Coveralls.wear!
35
+
33
36
  # Example data files.
34
37
  $file_null = "test/data/null.file"
35
38
  $ucf_empty = "test/data/empty.ucf"
data/ucf.gemspec CHANGED
@@ -1,79 +1,65 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # Copyright (c) 2013, 2014 The University of Manchester, UK.
2
+ #
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice,
9
+ # this list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # * Neither the names of The University of Manchester nor the names of its
16
+ # contributors may be used to endorse or promote products derived from this
17
+ # software without specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ # POSSIBILITY OF SUCH DAMAGE.
30
+ #
31
+ # Author: Robert Haines
32
+
33
+ lib = File.expand_path('../lib', __FILE__)
34
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
35
+ require "ucf/version"
5
36
 
6
37
  Gem::Specification.new do |s|
7
38
  s.name = "ucf"
8
- s.version = "0.7.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
39
+ s.version = UCF::Version::STRING
11
40
  s.authors = ["Robert Haines"]
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
41
  s.email = ["support@mygrid.org.uk"]
15
- s.extra_rdoc_files = [
16
- "Changes.rdoc",
17
- "Licence.rdoc",
18
- "ReadMe.rdoc"
19
- ]
20
- s.files = [
21
- "Changes.rdoc",
22
- "Licence.rdoc",
23
- "Rakefile",
24
- "ReadMe.rdoc",
25
- "examples/create-ucf",
26
- "examples/ucfinfo",
27
- "examples/verify-ucf",
28
- "lib/ucf.rb",
29
- "lib/ucf/container.rb",
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",
35
- "test/data/compressed_mimetype.ucf",
36
- "test/data/empty.ucf",
37
- "test/data/empty.zip",
38
- "test/data/example.ucf",
39
- "test/data/null.file",
40
- "test/tc_create.rb",
41
- "test/tc_managed_entries.rb",
42
- "test/tc_read.rb",
43
- "test/tc_reserved_names.rb",
44
- "test/ts_ucf.rb",
45
- "ucf.gemspec",
46
- "version.yml"
47
- ]
48
42
  s.homepage = "http://mygrid.github.io/ruby-ucf/"
49
- s.rdoc_options = ["-N", "--tab-width=2", "--main=ReadMe.rdoc"]
50
- s.require_paths = ["lib"]
51
- s.rubygems_version = "1.8.21"
43
+ s.platform = Gem::Platform::RUBY
52
44
  s.summary = "Universal Container Format (UCF) Ruby Library"
53
- s.test_files = ["test/ts_ucf.rb"]
54
-
55
- if s.respond_to? :specification_version then
56
- s.specification_version = 3
57
-
58
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
- s.add_development_dependency(%q<rake>, ["~> 10.0.4"])
60
- s.add_development_dependency(%q<rdoc>, ["~> 4.0.1"])
61
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
62
- s.add_development_dependency(%q<nokogiri>, ["~> 1.6"])
63
- s.add_runtime_dependency(%q<zip-container>, [">= 0.9.0"])
64
- else
65
- s.add_dependency(%q<rake>, ["~> 10.0.4"])
66
- s.add_dependency(%q<rdoc>, ["~> 4.0.1"])
67
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
68
- s.add_dependency(%q<nokogiri>, ["~> 1.6"])
69
- s.add_dependency(%q<zip-container>, [">= 0.9.0"])
70
- end
71
- else
72
- s.add_dependency(%q<rake>, ["~> 10.0.4"])
73
- s.add_dependency(%q<rdoc>, ["~> 4.0.1"])
74
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
75
- s.add_dependency(%q<nokogiri>, ["~> 1.6"])
76
- s.add_dependency(%q<zip-container>, [">= 0.9.0"])
77
- end
45
+ s.description = "A Ruby library for working with Universal Container "\
46
+ "Format files - a type of EPUB document. See the UCF specification "\
47
+ "(https://learn.adobe.com/wiki/display/PDFNAV/Universal+Container+Format) "\
48
+ "for details. They are very similar, although not as restrictive, as "\
49
+ "the EPUB Open Container Format (OCF) "\
50
+ "(http://www.idpf.org/epub/30/spec/epub30-ocf.html)."
51
+ s.license = "BSD"
52
+ s.require_path = "lib"
53
+ s.files = `git ls-files`.split($/)
54
+ s.test_files = `git ls-files -- test/*`.split($/)
55
+ s.has_rdoc = true
56
+ s.extra_rdoc_files = [ "Changes.rdoc", "Licence.rdoc", "ReadMe.rdoc" ]
57
+ s.rdoc_options = ["-N", "--tab-width=2", "--main=ReadMe.rdoc"]
58
+ s.required_ruby_version = ">= 1.9.3"
59
+ s.add_development_dependency("rake", "~> 10.0.4")
60
+ s.add_development_dependency("bundler", "~> 1.5")
61
+ s.add_development_dependency("rdoc", "~> 4.0.1")
62
+ s.add_development_dependency("coveralls")
63
+ s.add_development_dependency("nokogiri", "~> 1.6")
64
+ s.add_runtime_dependency("zip-container", "~> 2.0")
78
65
  end
79
-
data/version.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :major: 0
3
- :minor: 7
2
+ :major: 1
3
+ :minor: 0
4
4
  :patch: 0
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ucf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Robert Haines
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-01-03 00:00:00.000000000 Z
11
+ date: 2014-08-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,15 +20,27 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
26
  version: 10.0.4
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.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: rdoc
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
45
  - - ~>
36
46
  - !ruby/object:Gem::Version
@@ -38,31 +48,27 @@ dependencies:
38
48
  type: :development
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
52
  - - ~>
44
53
  - !ruby/object:Gem::Version
45
54
  version: 4.0.1
46
55
  - !ruby/object:Gem::Dependency
47
- name: jeweler
56
+ name: coveralls
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ~>
59
+ - - ! '>='
52
60
  - !ruby/object:Gem::Version
53
- version: 1.8.4
61
+ version: '0'
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ~>
66
+ - - ! '>='
60
67
  - !ruby/object:Gem::Version
61
- version: 1.8.4
68
+ version: '0'
62
69
  - !ruby/object:Gem::Dependency
63
70
  name: nokogiri
64
71
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
72
  requirements:
67
73
  - - ~>
68
74
  - !ruby/object:Gem::Version
@@ -70,7 +76,6 @@ dependencies:
70
76
  type: :development
71
77
  prerelease: false
72
78
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
79
  requirements:
75
80
  - - ~>
76
81
  - !ruby/object:Gem::Version
@@ -78,19 +83,17 @@ dependencies:
78
83
  - !ruby/object:Gem::Dependency
79
84
  name: zip-container
80
85
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
86
  requirements:
83
- - - ! '>='
87
+ - - ~>
84
88
  - !ruby/object:Gem::Version
85
- version: 0.9.0
89
+ version: '2.0'
86
90
  type: :runtime
87
91
  prerelease: false
88
92
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
93
  requirements:
91
- - - ! '>='
94
+ - - ~>
92
95
  - !ruby/object:Gem::Version
93
- version: 0.9.0
96
+ version: '2.0'
94
97
  description: A Ruby library for working with Universal Container Format files - a
95
98
  type of EPUB document. See the UCF specification (https://learn.adobe.com/wiki/display/PDFNAV/Universal+Container+Format)
96
99
  for details. They are very similar, although not as restrictive, as the EPUB Open
@@ -104,7 +107,12 @@ extra_rdoc_files:
104
107
  - Licence.rdoc
105
108
  - ReadMe.rdoc
106
109
  files:
110
+ - .gitignore
111
+ - .ruby-gemset
112
+ - .ruby-version
113
+ - .travis.yml
107
114
  - Changes.rdoc
115
+ - Gemfile
108
116
  - Licence.rdoc
109
117
  - Rakefile
110
118
  - ReadMe.rdoc
@@ -112,10 +120,11 @@ files:
112
120
  - examples/ucfinfo
113
121
  - examples/verify-ucf
114
122
  - lib/ucf.rb
115
- - lib/ucf/container.rb
123
+ - lib/ucf/file.rb
116
124
  - lib/ucf/meta-inf.rb
117
125
  - lib/ucf/schema/OpenDocument-manifest-schema-v1.0-os.rng
118
126
  - lib/ucf/schema/container.rng
127
+ - lib/ucf/version.rb
119
128
  - test/data/META-INF/container.xml
120
129
  - test/data/META-INF/manifest.xml
121
130
  - test/data/compressed_mimetype.ucf
@@ -131,7 +140,9 @@ files:
131
140
  - ucf.gemspec
132
141
  - version.yml
133
142
  homepage: http://mygrid.github.io/ruby-ucf/
134
- licenses: []
143
+ licenses:
144
+ - BSD
145
+ metadata: {}
135
146
  post_install_message:
136
147
  rdoc_options:
137
148
  - -N
@@ -140,22 +151,31 @@ rdoc_options:
140
151
  require_paths:
141
152
  - lib
142
153
  required_ruby_version: !ruby/object:Gem::Requirement
143
- none: false
144
154
  requirements:
145
155
  - - ! '>='
146
156
  - !ruby/object:Gem::Version
147
- version: '0'
157
+ version: 1.9.3
148
158
  required_rubygems_version: !ruby/object:Gem::Requirement
149
- none: false
150
159
  requirements:
151
160
  - - ! '>='
152
161
  - !ruby/object:Gem::Version
153
162
  version: '0'
154
163
  requirements: []
155
164
  rubyforge_project:
156
- rubygems_version: 1.8.21
165
+ rubygems_version: 2.2.2
157
166
  signing_key:
158
- specification_version: 3
167
+ specification_version: 4
159
168
  summary: Universal Container Format (UCF) Ruby Library
160
169
  test_files:
170
+ - test/data/META-INF/container.xml
171
+ - test/data/META-INF/manifest.xml
172
+ - test/data/compressed_mimetype.ucf
173
+ - test/data/empty.ucf
174
+ - test/data/empty.zip
175
+ - test/data/example.ucf
176
+ - test/data/null.file
177
+ - test/tc_create.rb
178
+ - test/tc_managed_entries.rb
179
+ - test/tc_read.rb
180
+ - test/tc_reserved_names.rb
161
181
  - test/ts_ucf.rb