epubinfo 0.1.0 → 0.2.0
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.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/epubinfo.gemspec +97 -0
- data/lib/epubinfo.rb +3 -0
- data/lib/epubinfo/models/book.rb +11 -11
- data/lib/epubinfo/utils.rb +6 -0
- data/spec/lib/epubinfo/identifier_spec.rb +11 -3
- data/spec/lib/epubinfo/models/book_spec.rb +86 -38
- data/spec/lib/epubinfo/models/date_spec.rb +1 -1
- data/spec/lib/epubinfo/models/person_spec.rb +2 -2
- data/spec/lib/epubinfo/parser_spec.rb +1 -1
- data/spec/lib/epubinfo_spec.rb +1 -1
- data/spec/support/binary/{metamorphosis.epub → metamorphosis_epub2.epub} +0 -0
- data/spec/support/binary/wasteland_epub3.epub +0 -0
- data/spec/support/xml/{metamorphosis_metadata.opf → metamorphosis_metadata_epub2.opf} +0 -0
- data/spec/support/xml/wasteland_metadata_epub3.opf +36 -0
- metadata +31 -27
    
        data/README.rdoc
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            = epubinfo {<img src="https://secure.travis-ci.org/chdorner/epubinfo.png?branch=master" alt="Continuous Integration" />}[http://travis-ci.org/chdorner/epubinfo] {<img src="https://gemnasium.com/chdorner/epubinfo.png" alt="Dependencies" />}[http://gemnasium.com/chdorner/epubinfo]
         | 
| 2 2 |  | 
| 3 | 
            -
            Extracts metadata information from EPUB files.  | 
| 3 | 
            +
            Extracts metadata information from EPUB files. Supports EPUB2 and EPUB3 formats.
         | 
| 4 4 |  | 
| 5 5 | 
             
            == Contributing to epubinfo
         | 
| 6 6 |  | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0. | 
| 1 | 
            +
            0.2.0
         | 
    
        data/epubinfo.gemspec
    ADDED
    
    | @@ -0,0 +1,97 @@ | |
| 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 -*-
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |s|
         | 
| 7 | 
            +
              s.name = "epubinfo"
         | 
| 8 | 
            +
              s.version = "0.2.0"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 | 
            +
              s.authors = ["Christof Dorner"]
         | 
| 12 | 
            +
              s.date = "2012-04-01"
         | 
| 13 | 
            +
              s.description = "Currently only supports EPUB 3 specification."
         | 
| 14 | 
            +
              s.email = "christof@chdorner.com"
         | 
| 15 | 
            +
              s.extra_rdoc_files = [
         | 
| 16 | 
            +
                "LICENSE.txt",
         | 
| 17 | 
            +
                "README.rdoc"
         | 
| 18 | 
            +
              ]
         | 
| 19 | 
            +
              s.files = [
         | 
| 20 | 
            +
                ".document",
         | 
| 21 | 
            +
                ".travis.yml",
         | 
| 22 | 
            +
                "Gemfile",
         | 
| 23 | 
            +
                "Gemfile.lock",
         | 
| 24 | 
            +
                "Guardfile",
         | 
| 25 | 
            +
                "LICENSE.txt",
         | 
| 26 | 
            +
                "README.rdoc",
         | 
| 27 | 
            +
                "Rakefile",
         | 
| 28 | 
            +
                "VERSION",
         | 
| 29 | 
            +
                "epubinfo.gemspec",
         | 
| 30 | 
            +
                "lib/epubinfo.rb",
         | 
| 31 | 
            +
                "lib/epubinfo/models/book.rb",
         | 
| 32 | 
            +
                "lib/epubinfo/models/date.rb",
         | 
| 33 | 
            +
                "lib/epubinfo/models/identifier.rb",
         | 
| 34 | 
            +
                "lib/epubinfo/models/person.rb",
         | 
| 35 | 
            +
                "lib/epubinfo/parser.rb",
         | 
| 36 | 
            +
                "lib/epubinfo/utils.rb",
         | 
| 37 | 
            +
                "spec/lib/epubinfo/identifier_spec.rb",
         | 
| 38 | 
            +
                "spec/lib/epubinfo/models/book_spec.rb",
         | 
| 39 | 
            +
                "spec/lib/epubinfo/models/date_spec.rb",
         | 
| 40 | 
            +
                "spec/lib/epubinfo/models/person_spec.rb",
         | 
| 41 | 
            +
                "spec/lib/epubinfo/parser_spec.rb",
         | 
| 42 | 
            +
                "spec/lib/epubinfo_spec.rb",
         | 
| 43 | 
            +
                "spec/spec_helper.rb",
         | 
| 44 | 
            +
                "spec/support/binary/metamorphosis_epub2.epub",
         | 
| 45 | 
            +
                "spec/support/binary/wasteland_epub3.epub",
         | 
| 46 | 
            +
                "spec/support/xml/metamorphosis_metadata_epub2.opf",
         | 
| 47 | 
            +
                "spec/support/xml/wasteland_metadata_epub3.opf"
         | 
| 48 | 
            +
              ]
         | 
| 49 | 
            +
              s.homepage = "http://github.com/chdorner/epubinfo"
         | 
| 50 | 
            +
              s.licenses = ["MIT"]
         | 
| 51 | 
            +
              s.require_paths = ["lib"]
         | 
| 52 | 
            +
              s.rubygems_version = "1.8.11"
         | 
| 53 | 
            +
              s.summary = "Extracts metadata information from EPUB files"
         | 
| 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_runtime_dependency(%q<rubyzip>, ["~> 0.9.6"])
         | 
| 60 | 
            +
                  s.add_runtime_dependency(%q<nokogiri>, ["~> 1.5.2"])
         | 
| 61 | 
            +
                  s.add_development_dependency(%q<rspec>, ["~> 2.9.0"])
         | 
| 62 | 
            +
                  s.add_development_dependency(%q<yard>, ["~> 0.7.5"])
         | 
| 63 | 
            +
                  s.add_development_dependency(%q<bundler>, ["~> 1.1.3"])
         | 
| 64 | 
            +
                  s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
         | 
| 65 | 
            +
                  s.add_development_dependency(%q<simplecov>, [">= 0"])
         | 
| 66 | 
            +
                  s.add_development_dependency(%q<guard>, [">= 0"])
         | 
| 67 | 
            +
                  s.add_development_dependency(%q<guard-rspec>, [">= 0"])
         | 
| 68 | 
            +
                  s.add_development_dependency(%q<rb-fsevent>, [">= 0"])
         | 
| 69 | 
            +
                  s.add_development_dependency(%q<growl>, [">= 0"])
         | 
| 70 | 
            +
                else
         | 
| 71 | 
            +
                  s.add_dependency(%q<rubyzip>, ["~> 0.9.6"])
         | 
| 72 | 
            +
                  s.add_dependency(%q<nokogiri>, ["~> 1.5.2"])
         | 
| 73 | 
            +
                  s.add_dependency(%q<rspec>, ["~> 2.9.0"])
         | 
| 74 | 
            +
                  s.add_dependency(%q<yard>, ["~> 0.7.5"])
         | 
| 75 | 
            +
                  s.add_dependency(%q<bundler>, ["~> 1.1.3"])
         | 
| 76 | 
            +
                  s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
         | 
| 77 | 
            +
                  s.add_dependency(%q<simplecov>, [">= 0"])
         | 
| 78 | 
            +
                  s.add_dependency(%q<guard>, [">= 0"])
         | 
| 79 | 
            +
                  s.add_dependency(%q<guard-rspec>, [">= 0"])
         | 
| 80 | 
            +
                  s.add_dependency(%q<rb-fsevent>, [">= 0"])
         | 
| 81 | 
            +
                  s.add_dependency(%q<growl>, [">= 0"])
         | 
| 82 | 
            +
                end
         | 
| 83 | 
            +
              else
         | 
| 84 | 
            +
                s.add_dependency(%q<rubyzip>, ["~> 0.9.6"])
         | 
| 85 | 
            +
                s.add_dependency(%q<nokogiri>, ["~> 1.5.2"])
         | 
| 86 | 
            +
                s.add_dependency(%q<rspec>, ["~> 2.9.0"])
         | 
| 87 | 
            +
                s.add_dependency(%q<yard>, ["~> 0.7.5"])
         | 
| 88 | 
            +
                s.add_dependency(%q<bundler>, ["~> 1.1.3"])
         | 
| 89 | 
            +
                s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
         | 
| 90 | 
            +
                s.add_dependency(%q<simplecov>, [">= 0"])
         | 
| 91 | 
            +
                s.add_dependency(%q<guard>, [">= 0"])
         | 
| 92 | 
            +
                s.add_dependency(%q<guard-rspec>, [">= 0"])
         | 
| 93 | 
            +
                s.add_dependency(%q<rb-fsevent>, [">= 0"])
         | 
| 94 | 
            +
                s.add_dependency(%q<growl>, [">= 0"])
         | 
| 95 | 
            +
              end
         | 
| 96 | 
            +
            end
         | 
| 97 | 
            +
             | 
    
        data/lib/epubinfo.rb
    CHANGED
    
    | @@ -6,8 +6,11 @@ require 'epubinfo/models/book' | |
| 6 6 | 
             
            require 'epubinfo/models/person'
         | 
| 7 7 | 
             
            require 'epubinfo/models/date'
         | 
| 8 8 | 
             
            require 'epubinfo/models/identifier'
         | 
| 9 | 
            +
            require 'epubinfo/utils'
         | 
| 9 10 |  | 
| 10 11 | 
             
            module EPUBInfo
         | 
| 12 | 
            +
              # Parses an epub file and returns a Book instance.
         | 
| 13 | 
            +
              # @return [EPUBInfo::Models::Book] the model
         | 
| 11 14 | 
             
              def self.get(path)
         | 
| 12 15 | 
             
                parser = EPUBInfo::Parser.parse(path)
         | 
| 13 16 | 
             
              end
         | 
    
        data/lib/epubinfo/models/book.rb
    CHANGED
    
    | @@ -7,17 +7,17 @@ module EPUBInfo | |
| 7 7 |  | 
| 8 8 | 
             
                  def initialize(document)
         | 
| 9 9 | 
             
                    metadata = document.css('metadata')
         | 
| 10 | 
            -
                    self.titles = metadata.xpath('.//dc:title').map(&:content)
         | 
| 11 | 
            -
                    self.creators = metadata.xpath('.//dc:creator').map {|c| EPUBInfo::Models::Person.new(c) }
         | 
| 12 | 
            -
                    self.subjects = metadata.xpath('.//dc:subject').map(&:content)
         | 
| 13 | 
            -
                    self.description = metadata.xpath('.//dc:description').first.content rescue nil
         | 
| 14 | 
            -
                    self.publisher = metadata.xpath('.//dc:publisher').first.content rescue nil
         | 
| 15 | 
            -
                    self.contributors = metadata.xpath('.//dc:contributor').map {|c| EPUBInfo::Models::Person.new(c) }
         | 
| 16 | 
            -
                    self.dates = metadata.xpath('.//dc:date').map { |d| EPUBInfo::Models::Date.new(d) }
         | 
| 17 | 
            -
                    self.identifiers = metadata.xpath('.//dc:identifier').map { |i| EPUBInfo::Models::Identifier.new(i) }
         | 
| 18 | 
            -
                    self.source = metadata.xpath('.//dc:source').first.content rescue nil
         | 
| 19 | 
            -
                    self.languages = metadata.xpath('.//dc:language').map(&:content)
         | 
| 20 | 
            -
                    self.rights = metadata.xpath('.//dc:rights').first.content rescue nil
         | 
| 10 | 
            +
                    self.titles = metadata.xpath('.//dc:title', EPUBInfo::Utils::DC_NAMESPACE).map(&:content)
         | 
| 11 | 
            +
                    self.creators = metadata.xpath('.//dc:creator', EPUBInfo::Utils::DC_NAMESPACE).map {|c| EPUBInfo::Models::Person.new(c) }
         | 
| 12 | 
            +
                    self.subjects = metadata.xpath('.//dc:subject', EPUBInfo::Utils::DC_NAMESPACE).map(&:content)
         | 
| 13 | 
            +
                    self.description = metadata.xpath('.//dc:description', EPUBInfo::Utils::DC_NAMESPACE).first.content rescue nil
         | 
| 14 | 
            +
                    self.publisher = metadata.xpath('.//dc:publisher', EPUBInfo::Utils::DC_NAMESPACE).first.content rescue nil
         | 
| 15 | 
            +
                    self.contributors = metadata.xpath('.//dc:contributor', EPUBInfo::Utils::DC_NAMESPACE).map {|c| EPUBInfo::Models::Person.new(c) }
         | 
| 16 | 
            +
                    self.dates = metadata.xpath('.//dc:date', EPUBInfo::Utils::DC_NAMESPACE).map { |d| EPUBInfo::Models::Date.new(d) }
         | 
| 17 | 
            +
                    self.identifiers = metadata.xpath('.//dc:identifier', EPUBInfo::Utils::DC_NAMESPACE).map { |i| EPUBInfo::Models::Identifier.new(i) }
         | 
| 18 | 
            +
                    self.source = metadata.xpath('.//dc:source', EPUBInfo::Utils::DC_NAMESPACE).first.content rescue nil
         | 
| 19 | 
            +
                    self.languages = metadata.xpath('.//dc:language', EPUBInfo::Utils::DC_NAMESPACE).map(&:content)
         | 
| 20 | 
            +
                    self.rights = metadata.xpath('.//dc:rights', EPUBInfo::Utils::DC_NAMESPACE).first.content rescue nil
         | 
| 21 21 | 
             
                  end
         | 
| 22 22 |  | 
| 23 23 | 
             
                  def titles; @titles || []; end
         | 
| @@ -1,9 +1,17 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe EPUBInfo::Models::Identifier do
         | 
| 4 | 
            -
               | 
| 4 | 
            +
              context 'EPUB2' do
         | 
| 5 | 
            +
                subject { EPUBInfo::Models::Identifier.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf')).css('metadata').xpath('.//dc:identifier', EPUBInfo::Utils::DC_NAMESPACE).first) }
         | 
| 5 6 |  | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 7 | 
            +
                its(:identifier) { should == 'http://www.gutenberg.org/ebooks/5200' }
         | 
| 8 | 
            +
                its(:scheme) { should == 'URI' }
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              context 'EPUB3' do
         | 
| 12 | 
            +
                subject { EPUBInfo::Models::Identifier.new(Nokogiri::XML(File.new('spec/support/xml/wasteland_metadata_epub3.opf')).css('metadata').xpath('.//dc:identifier', EPUBInfo::Utils::DC_NAMESPACE).first) }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                its(:identifier) { should == 'code.google.com.epub-samples.wasteland-basic' }
         | 
| 15 | 
            +
              end
         | 
| 8 16 | 
             
            end
         | 
| 9 17 |  | 
| @@ -1,62 +1,110 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe EPUBInfo::Models::Book do
         | 
| 4 | 
            -
               | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
                   | 
| 4 | 
            +
              context 'EPUB2' do
         | 
| 5 | 
            +
                subject { EPUBInfo::Models::Book.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf'))) }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                its(:titles) { should == ['Metamorphosis'] }
         | 
| 8 | 
            +
                its(:subjects) { should == ['Psychological fiction', 'Metamorphosis -- Fiction'] }
         | 
| 9 | 
            +
                its(:description) { should == 'Classic story of self-discovery, told in a unique manner by Kafka.' }
         | 
| 10 | 
            +
                its(:publisher) { should == 'Random House' }
         | 
| 11 | 
            +
                its(:source) { should == 'http://www.gutenberg.org/files/5200/5200-h/5200-h.htm' }
         | 
| 12 | 
            +
                its(:languages) { should == ['en'] }
         | 
| 13 | 
            +
                its(:rights) { should == 'Copyrighted. Read the copyright notice inside this book for details.' }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                context 'creators' do
         | 
| 16 | 
            +
                  it 'count should be 1' do
         | 
| 17 | 
            +
                    subject.creators.count.should == 1
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  it 'values should be of type Person' do
         | 
| 21 | 
            +
                    subject.creators.each do |creator|
         | 
| 22 | 
            +
                      creator.should be_kind_of EPUBInfo::Models::Person
         | 
| 23 | 
            +
                    end
         | 
| 24 | 
            +
                  end
         | 
| 19 25 | 
             
                end
         | 
| 20 26 |  | 
| 21 | 
            -
                 | 
| 22 | 
            -
                   | 
| 23 | 
            -
                     | 
| 27 | 
            +
                context 'contributors' do
         | 
| 28 | 
            +
                  it 'count should be 1' do
         | 
| 29 | 
            +
                    subject.contributors.count.should == 1
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  it 'values should be of type Person' do
         | 
| 33 | 
            +
                    subject.contributors.each do |contributor|
         | 
| 34 | 
            +
                      contributor.should be_kind_of EPUBInfo::Models::Person
         | 
| 35 | 
            +
                    end
         | 
| 24 36 | 
             
                  end
         | 
| 25 37 | 
             
                end
         | 
| 26 | 
            -
              end
         | 
| 27 38 |  | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 39 | 
            +
                context 'dates' do
         | 
| 40 | 
            +
                  it 'count should be 1' do
         | 
| 41 | 
            +
                    subject.dates.count.should == 2
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  it 'values should be of type Date' do
         | 
| 45 | 
            +
                    subject.dates.each do |date|
         | 
| 46 | 
            +
                      date.should be_kind_of EPUBInfo::Models::Date
         | 
| 47 | 
            +
                    end
         | 
| 48 | 
            +
                  end
         | 
| 31 49 | 
             
                end
         | 
| 32 50 |  | 
| 33 | 
            -
                 | 
| 34 | 
            -
                   | 
| 35 | 
            -
                     | 
| 51 | 
            +
                context 'identifiers' do
         | 
| 52 | 
            +
                  it 'count should be 1' do
         | 
| 53 | 
            +
                    subject.identifiers.count.should == 1
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  it 'values should be of type Identifier' do
         | 
| 57 | 
            +
                    subject.identifiers.each do |identifier|
         | 
| 58 | 
            +
                      identifier.should be_kind_of EPUBInfo::Models::Identifier
         | 
| 59 | 
            +
                    end
         | 
| 36 60 | 
             
                  end
         | 
| 37 61 | 
             
                end
         | 
| 38 62 | 
             
              end
         | 
| 39 63 |  | 
| 40 | 
            -
              context ' | 
| 41 | 
            -
                 | 
| 42 | 
            -
             | 
| 64 | 
            +
              context 'EPUB3' do
         | 
| 65 | 
            +
                subject { EPUBInfo::Models::Book.new(Nokogiri::XML(File.new('spec/support/xml/wasteland_metadata_epub3.opf'))) }
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                its(:titles) { should == ['The Waste Land'] }
         | 
| 68 | 
            +
                its(:subjects) { should == ['Fiction'] }
         | 
| 69 | 
            +
                its(:description) { should == 'Each facsimile page of the original manuscript is accompanied here by a typeset transcript on the facing page' }
         | 
| 70 | 
            +
                its(:publisher) { should == 'Some Publisher' }
         | 
| 71 | 
            +
                its(:source) { should == 'http://code.google.com/p/epub-samples/downloads/detail?name=wasteland-20120118.epub' }
         | 
| 72 | 
            +
                its(:languages) { should == ['en-US'] }
         | 
| 73 | 
            +
                its(:rights) { should == 'This work is shared with the public using the Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.' }
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                context 'creators' do
         | 
| 76 | 
            +
                  it 'count should be 1' do
         | 
| 77 | 
            +
                    subject.creators.count.should == 1
         | 
| 78 | 
            +
                  end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                  it 'values should be of type Person' do
         | 
| 81 | 
            +
                    subject.creators.each do |creator|
         | 
| 82 | 
            +
                      creator.should be_kind_of EPUBInfo::Models::Person
         | 
| 83 | 
            +
                    end
         | 
| 84 | 
            +
                  end
         | 
| 43 85 | 
             
                end
         | 
| 44 86 |  | 
| 45 | 
            -
                 | 
| 46 | 
            -
                   | 
| 47 | 
            -
                     | 
| 87 | 
            +
                context 'contributors' do
         | 
| 88 | 
            +
                  it 'count should be 0' do
         | 
| 89 | 
            +
                    subject.contributors.count.should == 0
         | 
| 48 90 | 
             
                  end
         | 
| 49 91 | 
             
                end
         | 
| 50 | 
            -
              end
         | 
| 51 92 |  | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 93 | 
            +
                context 'dates' do
         | 
| 94 | 
            +
                  it 'count should be 1' do
         | 
| 95 | 
            +
                    subject.dates.count.should == 1
         | 
| 96 | 
            +
                  end
         | 
| 55 97 | 
             
                end
         | 
| 56 98 |  | 
| 57 | 
            -
                 | 
| 58 | 
            -
                   | 
| 59 | 
            -
                     | 
| 99 | 
            +
                context 'identifiers' do
         | 
| 100 | 
            +
                  it 'count should be 1' do
         | 
| 101 | 
            +
                    subject.identifiers.count.should == 1
         | 
| 102 | 
            +
                  end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                  it 'values should be of type Identifier' do
         | 
| 105 | 
            +
                    subject.identifiers.each do |identifier|
         | 
| 106 | 
            +
                      identifier.should be_kind_of EPUBInfo::Models::Identifier
         | 
| 107 | 
            +
                    end
         | 
| 60 108 | 
             
                  end
         | 
| 61 109 | 
             
                end
         | 
| 62 110 | 
             
              end
         | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe EPUBInfo::Models::Date do
         | 
| 4 | 
            -
              subject { EPUBInfo::Models::Date.new(Nokogiri::XML(File.new('spec/support/xml/ | 
| 4 | 
            +
              subject { EPUBInfo::Models::Date.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf')).css('metadata').xpath('.//dc:date').first) }
         | 
| 5 5 |  | 
| 6 6 | 
             
              its(:time) { should == Time.parse('2005-08-17') }
         | 
| 7 7 | 
             
              its(:event) { should == 'publication' }
         | 
| @@ -2,7 +2,7 @@ require 'spec_helper' | |
| 2 2 |  | 
| 3 3 | 
             
            describe EPUBInfo::Models::Person do
         | 
| 4 4 | 
             
              context 'creator' do
         | 
| 5 | 
            -
                subject { EPUBInfo::Models::Person.new(Nokogiri::XML(File.new('spec/support/xml/ | 
| 5 | 
            +
                subject { EPUBInfo::Models::Person.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf')).css('metadata').xpath('.//dc:creator').first) }
         | 
| 6 6 |  | 
| 7 7 | 
             
                its(:name) { should == 'Franz Kafka' }
         | 
| 8 8 | 
             
                its(:file_as) { should == 'Kafka, Franz' }
         | 
| @@ -10,7 +10,7 @@ describe EPUBInfo::Models::Person do | |
| 10 10 | 
             
              end
         | 
| 11 11 |  | 
| 12 12 | 
             
              context 'contributor' do
         | 
| 13 | 
            -
                subject { EPUBInfo::Models::Person.new(Nokogiri::XML(File.new('spec/support/xml/ | 
| 13 | 
            +
                subject { EPUBInfo::Models::Person.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf')).css('metadata').xpath('.//dc:contributor').first) }
         | 
| 14 14 |  | 
| 15 15 | 
             
                its(:name) { should == 'David Wyllie' }
         | 
| 16 16 | 
             
                its(:file_as) { should == 'Wyllie, David' }
         | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe EPUBInfo::Parser do
         | 
| 4 | 
            -
              let(:epub_path) { File.expand_path('spec/support/binary/ | 
| 4 | 
            +
              let(:epub_path) { File.expand_path('spec/support/binary/metamorphosis_epub2.epub') }
         | 
| 5 5 | 
             
              let(:parser) { EPUBInfo::Parser.parse(epub_path) }
         | 
| 6 6 |  | 
| 7 7 | 
             
              describe '#parse' do
         | 
    
        data/spec/lib/epubinfo_spec.rb
    CHANGED
    
    
| 
            File without changes
         | 
| Binary file | 
| 
            File without changes
         | 
| @@ -0,0 +1,36 @@ | |
| 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 | 
            +
                    <dc:subject>Fiction</dc:subject>
         | 
| 10 | 
            +
                    <dc:description>Each facsimile page of the original manuscript is accompanied here by a typeset transcript on the facing page</dc:description>
         | 
| 11 | 
            +
                    <dc:publisher>Some Publisher</dc:publisher>
         | 
| 12 | 
            +
                    <dc:source>http://code.google.com/p/epub-samples/downloads/detail?name=wasteland-20120118.epub</dc:source>
         | 
| 13 | 
            +
                    <meta property="dcterms:modified">2012-01-18T12:47:00Z</meta>
         | 
| 14 | 
            +
                    <!-- rights expressions for the work as a whole -->
         | 
| 15 | 
            +
                    <dc:rights>This work is shared with the public using the Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.</dc:rights>        
         | 
| 16 | 
            +
                    <link rel="cc:license" href="http://creativecommons.org/licenses/by-sa/3.0/"/>
         | 
| 17 | 
            +
                    <meta property="cc:attributionURL">http://code.google.com/p/epub-samples/</meta>
         | 
| 18 | 
            +
                    <!-- rights expression for the cover image -->       
         | 
| 19 | 
            +
                    <link rel="cc:license" refines="#cover" href="http://creativecommons.org/licenses/by-sa/3.0/" />
         | 
| 20 | 
            +
                    <link rel="cc:attributionURL" refines="#cover" href="http://en.wikipedia.org/wiki/Simon_Fieldhouse" />        
         | 
| 21 | 
            +
                    <!-- cover meta element included for 2.0 reading system compatibility: -->
         | 
| 22 | 
            +
                    <meta name="cover" content="cover"/>
         | 
| 23 | 
            +
                </metadata> 
         | 
| 24 | 
            +
                <manifest>
         | 
| 25 | 
            +
                    <item id="t1" href="wasteland-content.xhtml" media-type="application/xhtml+xml" />
         | 
| 26 | 
            +
                    <item id="nav" href="wasteland-nav.xhtml" properties="nav" media-type="application/xhtml+xml" />
         | 
| 27 | 
            +
                    <item id="cover" href="wasteland-cover.jpg" media-type="image/jpeg" properties="cover-image" />
         | 
| 28 | 
            +
                    <item id="css" href="wasteland.css" media-type="text/css" />
         | 
| 29 | 
            +
                    <item id="css-night" href="wasteland-night.css" media-type="text/css" />
         | 
| 30 | 
            +
                    <!-- ncx included for 2.0 reading system compatibility: -->
         | 
| 31 | 
            +
                    <item id="ncx" href="wasteland.ncx" media-type="application/x-dtbncx+xml" />
         | 
| 32 | 
            +
                </manifest>
         | 
| 33 | 
            +
                <spine toc="ncx">
         | 
| 34 | 
            +
                    <itemref idref="t1" />        
         | 
| 35 | 
            +
                </spine>    
         | 
| 36 | 
            +
            </package>
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: epubinfo
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,11 +9,11 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2012- | 
| 12 | 
            +
            date: 2012-04-01 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: rubyzip
         | 
| 16 | 
            -
              requirement: & | 
| 16 | 
            +
              requirement: &70111953893280 !ruby/object:Gem::Requirement
         | 
| 17 17 | 
             
                none: false
         | 
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ~>
         | 
| @@ -21,10 +21,10 @@ dependencies: | |
| 21 21 | 
             
                    version: 0.9.6
         | 
| 22 22 | 
             
              type: :runtime
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements: * | 
| 24 | 
            +
              version_requirements: *70111953893280
         | 
| 25 25 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 26 26 | 
             
              name: nokogiri
         | 
| 27 | 
            -
              requirement: & | 
| 27 | 
            +
              requirement: &70111953891860 !ruby/object:Gem::Requirement
         | 
| 28 28 | 
             
                none: false
         | 
| 29 29 | 
             
                requirements:
         | 
| 30 30 | 
             
                - - ~>
         | 
| @@ -32,10 +32,10 @@ dependencies: | |
| 32 32 | 
             
                    version: 1.5.2
         | 
| 33 33 | 
             
              type: :runtime
         | 
| 34 34 | 
             
              prerelease: false
         | 
| 35 | 
            -
              version_requirements: * | 
| 35 | 
            +
              version_requirements: *70111953891860
         | 
| 36 36 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 37 | 
             
              name: rspec
         | 
| 38 | 
            -
              requirement: & | 
| 38 | 
            +
              requirement: &70111953890520 !ruby/object:Gem::Requirement
         | 
| 39 39 | 
             
                none: false
         | 
| 40 40 | 
             
                requirements:
         | 
| 41 41 | 
             
                - - ~>
         | 
| @@ -43,10 +43,10 @@ dependencies: | |
| 43 43 | 
             
                    version: 2.9.0
         | 
| 44 44 | 
             
              type: :development
         | 
| 45 45 | 
             
              prerelease: false
         | 
| 46 | 
            -
              version_requirements: * | 
| 46 | 
            +
              version_requirements: *70111953890520
         | 
| 47 47 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 48 48 | 
             
              name: yard
         | 
| 49 | 
            -
              requirement: & | 
| 49 | 
            +
              requirement: &70111953889200 !ruby/object:Gem::Requirement
         | 
| 50 50 | 
             
                none: false
         | 
| 51 51 | 
             
                requirements:
         | 
| 52 52 | 
             
                - - ~>
         | 
| @@ -54,10 +54,10 @@ dependencies: | |
| 54 54 | 
             
                    version: 0.7.5
         | 
| 55 55 | 
             
              type: :development
         | 
| 56 56 | 
             
              prerelease: false
         | 
| 57 | 
            -
              version_requirements: * | 
| 57 | 
            +
              version_requirements: *70111953889200
         | 
| 58 58 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 59 59 | 
             
              name: bundler
         | 
| 60 | 
            -
              requirement: & | 
| 60 | 
            +
              requirement: &70111953903960 !ruby/object:Gem::Requirement
         | 
| 61 61 | 
             
                none: false
         | 
| 62 62 | 
             
                requirements:
         | 
| 63 63 | 
             
                - - ~>
         | 
| @@ -65,10 +65,10 @@ dependencies: | |
| 65 65 | 
             
                    version: 1.1.3
         | 
| 66 66 | 
             
              type: :development
         | 
| 67 67 | 
             
              prerelease: false
         | 
| 68 | 
            -
              version_requirements: * | 
| 68 | 
            +
              version_requirements: *70111953903960
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 70 | 
             
              name: jeweler
         | 
| 71 | 
            -
              requirement: & | 
| 71 | 
            +
              requirement: &70111953903160 !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                none: false
         | 
| 73 73 | 
             
                requirements:
         | 
| 74 74 | 
             
                - - ~>
         | 
| @@ -76,10 +76,10 @@ dependencies: | |
| 76 76 | 
             
                    version: 1.8.3
         | 
| 77 77 | 
             
              type: :development
         | 
| 78 78 | 
             
              prerelease: false
         | 
| 79 | 
            -
              version_requirements: * | 
| 79 | 
            +
              version_requirements: *70111953903160
         | 
| 80 80 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 81 81 | 
             
              name: simplecov
         | 
| 82 | 
            -
              requirement: & | 
| 82 | 
            +
              requirement: &70111953901360 !ruby/object:Gem::Requirement
         | 
| 83 83 | 
             
                none: false
         | 
| 84 84 | 
             
                requirements:
         | 
| 85 85 | 
             
                - - ! '>='
         | 
| @@ -87,10 +87,10 @@ dependencies: | |
| 87 87 | 
             
                    version: '0'
         | 
| 88 88 | 
             
              type: :development
         | 
| 89 89 | 
             
              prerelease: false
         | 
| 90 | 
            -
              version_requirements: * | 
| 90 | 
            +
              version_requirements: *70111953901360
         | 
| 91 91 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 92 92 | 
             
              name: guard
         | 
| 93 | 
            -
              requirement: & | 
| 93 | 
            +
              requirement: &70111953900620 !ruby/object:Gem::Requirement
         | 
| 94 94 | 
             
                none: false
         | 
| 95 95 | 
             
                requirements:
         | 
| 96 96 | 
             
                - - ! '>='
         | 
| @@ -98,10 +98,10 @@ dependencies: | |
| 98 98 | 
             
                    version: '0'
         | 
| 99 99 | 
             
              type: :development
         | 
| 100 100 | 
             
              prerelease: false
         | 
| 101 | 
            -
              version_requirements: * | 
| 101 | 
            +
              version_requirements: *70111953900620
         | 
| 102 102 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 103 103 | 
             
              name: guard-rspec
         | 
| 104 | 
            -
              requirement: & | 
| 104 | 
            +
              requirement: &70111953899380 !ruby/object:Gem::Requirement
         | 
| 105 105 | 
             
                none: false
         | 
| 106 106 | 
             
                requirements:
         | 
| 107 107 | 
             
                - - ! '>='
         | 
| @@ -109,10 +109,10 @@ dependencies: | |
| 109 109 | 
             
                    version: '0'
         | 
| 110 110 | 
             
              type: :development
         | 
| 111 111 | 
             
              prerelease: false
         | 
| 112 | 
            -
              version_requirements: * | 
| 112 | 
            +
              version_requirements: *70111953899380
         | 
| 113 113 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 114 114 | 
             
              name: rb-fsevent
         | 
| 115 | 
            -
              requirement: & | 
| 115 | 
            +
              requirement: &70111953898540 !ruby/object:Gem::Requirement
         | 
| 116 116 | 
             
                none: false
         | 
| 117 117 | 
             
                requirements:
         | 
| 118 118 | 
             
                - - ! '>='
         | 
| @@ -120,10 +120,10 @@ dependencies: | |
| 120 120 | 
             
                    version: '0'
         | 
| 121 121 | 
             
              type: :development
         | 
| 122 122 | 
             
              prerelease: false
         | 
| 123 | 
            -
              version_requirements: * | 
| 123 | 
            +
              version_requirements: *70111953898540
         | 
| 124 124 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 125 125 | 
             
              name: growl
         | 
| 126 | 
            -
              requirement: & | 
| 126 | 
            +
              requirement: &70111953897380 !ruby/object:Gem::Requirement
         | 
| 127 127 | 
             
                none: false
         | 
| 128 128 | 
             
                requirements:
         | 
| 129 129 | 
             
                - - ! '>='
         | 
| @@ -131,7 +131,7 @@ dependencies: | |
| 131 131 | 
             
                    version: '0'
         | 
| 132 132 | 
             
              type: :development
         | 
| 133 133 | 
             
              prerelease: false
         | 
| 134 | 
            -
              version_requirements: * | 
| 134 | 
            +
              version_requirements: *70111953897380
         | 
| 135 135 | 
             
            description: Currently only supports EPUB 3 specification.
         | 
| 136 136 | 
             
            email: christof@chdorner.com
         | 
| 137 137 | 
             
            executables: []
         | 
| @@ -149,12 +149,14 @@ files: | |
| 149 149 | 
             
            - README.rdoc
         | 
| 150 150 | 
             
            - Rakefile
         | 
| 151 151 | 
             
            - VERSION
         | 
| 152 | 
            +
            - epubinfo.gemspec
         | 
| 152 153 | 
             
            - lib/epubinfo.rb
         | 
| 153 154 | 
             
            - lib/epubinfo/models/book.rb
         | 
| 154 155 | 
             
            - lib/epubinfo/models/date.rb
         | 
| 155 156 | 
             
            - lib/epubinfo/models/identifier.rb
         | 
| 156 157 | 
             
            - lib/epubinfo/models/person.rb
         | 
| 157 158 | 
             
            - lib/epubinfo/parser.rb
         | 
| 159 | 
            +
            - lib/epubinfo/utils.rb
         | 
| 158 160 | 
             
            - spec/lib/epubinfo/identifier_spec.rb
         | 
| 159 161 | 
             
            - spec/lib/epubinfo/models/book_spec.rb
         | 
| 160 162 | 
             
            - spec/lib/epubinfo/models/date_spec.rb
         | 
| @@ -162,8 +164,10 @@ files: | |
| 162 164 | 
             
            - spec/lib/epubinfo/parser_spec.rb
         | 
| 163 165 | 
             
            - spec/lib/epubinfo_spec.rb
         | 
| 164 166 | 
             
            - spec/spec_helper.rb
         | 
| 165 | 
            -
            - spec/support/binary/ | 
| 166 | 
            -
            - spec/support/ | 
| 167 | 
            +
            - spec/support/binary/metamorphosis_epub2.epub
         | 
| 168 | 
            +
            - spec/support/binary/wasteland_epub3.epub
         | 
| 169 | 
            +
            - spec/support/xml/metamorphosis_metadata_epub2.opf
         | 
| 170 | 
            +
            - spec/support/xml/wasteland_metadata_epub3.opf
         | 
| 167 171 | 
             
            homepage: http://github.com/chdorner/epubinfo
         | 
| 168 172 | 
             
            licenses:
         | 
| 169 173 | 
             
            - MIT
         | 
| @@ -179,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 179 183 | 
             
                  version: '0'
         | 
| 180 184 | 
             
                  segments:
         | 
| 181 185 | 
             
                  - 0
         | 
| 182 | 
            -
                  hash: - | 
| 186 | 
            +
                  hash: -147532084777726718
         | 
| 183 187 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 184 188 | 
             
              none: false
         | 
| 185 189 | 
             
              requirements:
         |