epubinfo 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
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.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubyzip
16
- requirement: &70304125144560 !ruby/object:Gem::Requirement
16
+ requirement: &70286173152020 !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: *70304125144560
24
+ version_requirements: *70286173152020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &70304125143040 !ruby/object:Gem::Requirement
27
+ requirement: &70286173151080 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.4.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70304125143040
35
+ version_requirements: *70286173151080
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70304125141680 !ruby/object:Gem::Requirement
38
+ requirement: &70286173150320 !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: *70304125141680
46
+ version_requirements: *70286173150320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard
49
- requirement: &70304125140740 !ruby/object:Gem::Requirement
49
+ requirement: &70286173148500 !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: *70304125140740
57
+ version_requirements: *70286173148500
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70304125139680 !ruby/object:Gem::Requirement
60
+ requirement: &70286173144900 !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: *70304125139680
68
+ version_requirements: *70286173144900
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &70304125138600 !ruby/object:Gem::Requirement
71
+ requirement: &70286173141440 !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: *70304125138600
79
+ version_requirements: *70286173141440
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov
82
- requirement: &70304125137740 !ruby/object:Gem::Requirement
82
+ requirement: &70286173136300 !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: *70304125137740
90
+ version_requirements: *70286173136300
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: guard
93
- requirement: &70304125136420 !ruby/object:Gem::Requirement
93
+ requirement: &70286173134520 !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: *70304125136420
101
+ version_requirements: *70286173134520
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: guard-rspec
104
- requirement: &70304125135240 !ruby/object:Gem::Requirement
104
+ requirement: &70286173131700 !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: *70304125135240
112
+ version_requirements: *70286173131700
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rb-fsevent
115
- requirement: &70304125133980 !ruby/object:Gem::Requirement
115
+ requirement: &70286173129220 !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: *70304125133980
123
+ version_requirements: *70286173129220
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: growl
126
- requirement: &70304125133220 !ruby/object:Gem::Requirement
126
+ requirement: &70286173127640 !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: *70304125133220
134
+ version_requirements: *70286173127640
135
135
  description: Supports EPUB2 and EPUB3 formats.
136
136
  email: christof@chdorner.com
137
137
  executables: []
@@ -140,16 +140,6 @@ extra_rdoc_files:
140
140
  - LICENSE.txt
141
141
  - README.rdoc
142
142
  files:
143
- - .document
144
- - .travis.yml
145
- - Gemfile
146
- - Gemfile.lock
147
- - Guardfile
148
- - LICENSE.txt
149
- - README.rdoc
150
- - Rakefile
151
- - VERSION
152
- - epubinfo.gemspec
153
143
  - lib/epubinfo.rb
154
144
  - lib/epubinfo/models/book.rb
155
145
  - lib/epubinfo/models/date.rb
@@ -157,18 +147,8 @@ files:
157
147
  - lib/epubinfo/models/person.rb
158
148
  - lib/epubinfo/parser.rb
159
149
  - lib/epubinfo/utils.rb
160
- - spec/lib/epubinfo/models/book_spec.rb
161
- - spec/lib/epubinfo/models/date_spec.rb
162
- - spec/lib/epubinfo/models/identifier_spec.rb
163
- - spec/lib/epubinfo/models/person_spec.rb
164
- - spec/lib/epubinfo/parser_spec.rb
165
- - spec/lib/epubinfo_spec.rb
166
- - spec/spec_helper.rb
167
- - spec/support/binary/metamorphosis_epub2.epub
168
- - spec/support/binary/metamorphosis_epub2_drm.epub
169
- - spec/support/binary/wasteland_epub3.epub
170
- - spec/support/xml/metamorphosis_metadata_epub2.opf
171
- - spec/support/xml/wasteland_metadata_epub3.opf
150
+ - LICENSE.txt
151
+ - README.rdoc
172
152
  homepage: http://github.com/chdorner/epubinfo
173
153
  licenses:
174
154
  - MIT
@@ -184,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
164
  version: '0'
185
165
  segments:
186
166
  - 0
187
- hash: -524926705083524689
167
+ hash: 2332854872450822049
188
168
  required_rubygems_version: !ruby/object:Gem::Requirement
189
169
  none: false
190
170
  requirements:
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- # ----------------------------------------------------------------
2
- # Configuration file for http://travis-ci.org/#!/chdorner/epubinfo
3
- # ----------------------------------------------------------------
4
-
5
- language: ruby
6
- script: "bundle exec rake spec"
7
- rvm:
8
- - 1.9.2
9
- - 1.9.3
10
- - ruby-head
11
-
12
- before_install:
13
- - gem install bundler
14
-
data/Gemfile DELETED
@@ -1,22 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem "rubyzip", "~> 0.9.6"
4
- gem "nokogiri", ">= 1.4.2"
5
-
6
- # Add dependencies required to use your gem here.
7
- # Example:
8
- # gem "activesupport", ">= 2.3.5"
9
-
10
- # Add dependencies to develop your gem here.
11
- # Include everything needed to run rake, tests, features, etc.
12
- group :development do
13
- gem "rspec", "~> 2.9.0"
14
- gem "yard", "~> 0.7.5"
15
- gem "bundler", "~> 1.1.3"
16
- gem "jeweler", "~> 1.8.3"
17
- gem "simplecov", ">= 0"
18
- gem "guard"
19
- gem "guard-rspec"
20
- gem "rb-fsevent"
21
- gem "growl"
22
- end
data/Gemfile.lock DELETED
@@ -1,53 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- diff-lcs (1.1.3)
5
- git (1.2.5)
6
- growl (1.0.3)
7
- guard (0.8.8)
8
- thor (~> 0.14.6)
9
- guard-rspec (0.5.2)
10
- guard (>= 0.8.4)
11
- jeweler (1.8.3)
12
- bundler (~> 1.0)
13
- git (>= 1.2.5)
14
- rake
15
- rdoc
16
- json (1.6.6)
17
- multi_json (1.2.0)
18
- nokogiri (1.5.2)
19
- rake (0.9.2.2)
20
- rb-fsevent (0.9.0)
21
- rdoc (3.12)
22
- json (~> 1.4)
23
- rspec (2.9.0)
24
- rspec-core (~> 2.9.0)
25
- rspec-expectations (~> 2.9.0)
26
- rspec-mocks (~> 2.9.0)
27
- rspec-core (2.9.0)
28
- rspec-expectations (2.9.0)
29
- diff-lcs (~> 1.1.3)
30
- rspec-mocks (2.9.0)
31
- rubyzip (0.9.6.1)
32
- simplecov (0.6.1)
33
- multi_json (~> 1.0)
34
- simplecov-html (~> 0.5.3)
35
- simplecov-html (0.5.3)
36
- thor (0.14.6)
37
- yard (0.7.5)
38
-
39
- PLATFORMS
40
- ruby
41
-
42
- DEPENDENCIES
43
- bundler (~> 1.1.3)
44
- growl
45
- guard
46
- guard-rspec
47
- jeweler (~> 1.8.3)
48
- nokogiri (>= 1.4.2)
49
- rb-fsevent
50
- rspec (~> 2.9.0)
51
- rubyzip (~> 0.9.6)
52
- simplecov
53
- yard (~> 0.7.5)
data/Guardfile DELETED
@@ -1,6 +0,0 @@
1
- guard 'rspec', :version => 2 do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { "spec" }
5
- end
6
-
data/Rakefile DELETED
@@ -1,38 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "epubinfo"
18
- gem.homepage = "http://github.com/chdorner/epubinfo"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Extracts metadata information from EPUB files}
21
- gem.description = %Q{Supports EPUB2 and EPUB3 formats.}
22
- gem.email = "christof@chdorner.com"
23
- gem.authors = ["Christof Dorner"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
- require 'rspec/core/rake_task'
29
- RSpec::Core::RakeTask.new(:spec)
30
-
31
- task :default => :spec
32
-
33
- require 'yard'
34
- YARD::Rake::YardocTask.new do |t|
35
- t.files = ['lib/**/*.rb', 'epubinfo.rb', '-', 'REAMDE.rdoc']
36
- #t.options = ['--any', '--extra', '--opts']
37
- end
38
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.0
data/epubinfo.gemspec DELETED
@@ -1,98 +0,0 @@
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.3.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-13"
13
- s.description = "Supports EPUB2 and EPUB3 formats."
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/models/book_spec.rb",
38
- "spec/lib/epubinfo/models/date_spec.rb",
39
- "spec/lib/epubinfo/models/identifier_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/metamorphosis_epub2_drm.epub",
46
- "spec/support/binary/wasteland_epub3.epub",
47
- "spec/support/xml/metamorphosis_metadata_epub2.opf",
48
- "spec/support/xml/wasteland_metadata_epub3.opf"
49
- ]
50
- s.homepage = "http://github.com/chdorner/epubinfo"
51
- s.licenses = ["MIT"]
52
- s.require_paths = ["lib"]
53
- s.rubygems_version = "1.8.11"
54
- s.summary = "Extracts metadata information from EPUB files"
55
-
56
- if s.respond_to? :specification_version then
57
- s.specification_version = 3
58
-
59
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
60
- s.add_runtime_dependency(%q<rubyzip>, ["~> 0.9.6"])
61
- s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.2"])
62
- s.add_development_dependency(%q<rspec>, ["~> 2.9.0"])
63
- s.add_development_dependency(%q<yard>, ["~> 0.7.5"])
64
- s.add_development_dependency(%q<bundler>, ["~> 1.1.3"])
65
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
66
- s.add_development_dependency(%q<simplecov>, [">= 0"])
67
- s.add_development_dependency(%q<guard>, [">= 0"])
68
- s.add_development_dependency(%q<guard-rspec>, [">= 0"])
69
- s.add_development_dependency(%q<rb-fsevent>, [">= 0"])
70
- s.add_development_dependency(%q<growl>, [">= 0"])
71
- else
72
- s.add_dependency(%q<rubyzip>, ["~> 0.9.6"])
73
- s.add_dependency(%q<nokogiri>, [">= 1.4.2"])
74
- s.add_dependency(%q<rspec>, ["~> 2.9.0"])
75
- s.add_dependency(%q<yard>, ["~> 0.7.5"])
76
- s.add_dependency(%q<bundler>, ["~> 1.1.3"])
77
- s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
78
- s.add_dependency(%q<simplecov>, [">= 0"])
79
- s.add_dependency(%q<guard>, [">= 0"])
80
- s.add_dependency(%q<guard-rspec>, [">= 0"])
81
- s.add_dependency(%q<rb-fsevent>, [">= 0"])
82
- s.add_dependency(%q<growl>, [">= 0"])
83
- end
84
- else
85
- s.add_dependency(%q<rubyzip>, ["~> 0.9.6"])
86
- s.add_dependency(%q<nokogiri>, [">= 1.4.2"])
87
- s.add_dependency(%q<rspec>, ["~> 2.9.0"])
88
- s.add_dependency(%q<yard>, ["~> 0.7.5"])
89
- s.add_dependency(%q<bundler>, ["~> 1.1.3"])
90
- s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
91
- s.add_dependency(%q<simplecov>, [">= 0"])
92
- s.add_dependency(%q<guard>, [">= 0"])
93
- s.add_dependency(%q<guard-rspec>, [">= 0"])
94
- s.add_dependency(%q<rb-fsevent>, [">= 0"])
95
- s.add_dependency(%q<growl>, [">= 0"])
96
- end
97
- end
98
-
@@ -1,144 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe EPUBInfo::Models::Book do
4
- describe '#initialize' do
5
- context 'EPUB2' do
6
- subject { EPUBInfo::Models::Book.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf'))) }
7
-
8
- its(:titles) { should == ['Metamorphosis'] }
9
- its(:subjects) { should == ['Psychological fiction', 'Metamorphosis -- Fiction'] }
10
- its(:description) { should == 'Classic story of self-discovery, told in a unique manner by Kafka.' }
11
- its(:publisher) { should == 'Random House' }
12
- its(:source) { should == 'http://www.gutenberg.org/files/5200/5200-h/5200-h.htm' }
13
- its(:languages) { should == ['en'] }
14
- its(:rights) { should == 'Copyrighted. Read the copyright notice inside this book for details.' }
15
- its(:drm_protected?) { should be_false }
16
-
17
- context 'creators' do
18
- it 'count should be 1' do
19
- subject.creators.count.should == 1
20
- end
21
-
22
- it 'values should be of type Person' do
23
- subject.creators.each do |creator|
24
- creator.should be_kind_of EPUBInfo::Models::Person
25
- end
26
- end
27
- end
28
-
29
- context 'contributors' do
30
- it 'count should be 1' do
31
- subject.contributors.count.should == 1
32
- end
33
-
34
- it 'values should be of type Person' do
35
- subject.contributors.each do |contributor|
36
- contributor.should be_kind_of EPUBInfo::Models::Person
37
- end
38
- end
39
- end
40
-
41
- context 'dates' do
42
- it 'count should be 1' do
43
- subject.dates.count.should == 2
44
- end
45
-
46
- it 'values should be of type Date' do
47
- subject.dates.each do |date|
48
- date.should be_kind_of EPUBInfo::Models::Date
49
- end
50
- end
51
- end
52
-
53
- context 'identifiers' do
54
- it 'count should be 1' do
55
- subject.identifiers.count.should == 1
56
- end
57
-
58
- it 'values should be of type Identifier' do
59
- subject.identifiers.each do |identifier|
60
- identifier.should be_kind_of EPUBInfo::Models::Identifier
61
- end
62
- end
63
- end
64
- end
65
-
66
- context 'EPUB3' do
67
- subject { EPUBInfo::Models::Book.new(Nokogiri::XML(File.new('spec/support/xml/wasteland_metadata_epub3.opf'))) }
68
-
69
- its(:titles) { should == ['The Waste Land'] }
70
- its(:subjects) { should == ['Fiction'] }
71
- its(:description) { should == 'Each facsimile page of the original manuscript is accompanied here by a typeset transcript on the facing page' }
72
- its(:publisher) { should == 'Some Publisher' }
73
- its(:source) { should == 'http://code.google.com/p/epub-samples/downloads/detail?name=wasteland-20120118.epub' }
74
- its(:languages) { should == ['en-US'] }
75
- its(:rights) { should == 'This work is shared with the public using the Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.' }
76
-
77
- context 'creators' do
78
- it 'count should be 1' do
79
- subject.creators.count.should == 1
80
- end
81
-
82
- it 'values should be of type Person' do
83
- subject.creators.each do |creator|
84
- creator.should be_kind_of EPUBInfo::Models::Person
85
- end
86
- end
87
- end
88
-
89
- context 'contributors' do
90
- it 'count should be 0' do
91
- subject.contributors.count.should == 0
92
- end
93
- end
94
-
95
- context 'dates' do
96
- it 'count should be 1' do
97
- subject.dates.count.should == 1
98
- end
99
- end
100
-
101
- context 'identifiers' do
102
- it 'count should be 1' do
103
- subject.identifiers.count.should == 1
104
- end
105
-
106
- it 'values should be of type Identifier' do
107
- subject.identifiers.each do |identifier|
108
- identifier.should be_kind_of EPUBInfo::Models::Identifier
109
- end
110
- end
111
- end
112
- end
113
- end
114
-
115
- context 'default values' do
116
- subject { EPUBInfo::Models::Book.new(Nokogiri::XML::Document.new) }
117
-
118
- its(:titles) { should == [] }
119
- its(:creators) { should == [] }
120
- its(:subjects) { should == [] }
121
- its(:contributors) { should == [] }
122
- its(:dates) { should == [] }
123
- its(:identifiers) { should == [] }
124
- its(:languages) { should == [] }
125
- end
126
-
127
- describe '#to_hash' do
128
- context 'keys' do
129
- subject { EPUBInfo::Models::Book.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf'))).to_hash.keys }
130
- it { should include :titles }
131
- it { should include :creators }
132
- it { should include :subjects }
133
- it { should include :description }
134
- it { should include :publisher }
135
- it { should include :contributors }
136
- it { should include :dates }
137
- it { should include :identifiers }
138
- it { should include :source }
139
- it { should include :languages }
140
- it { should include :rights }
141
- end
142
- end
143
- end
144
-
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe EPUBInfo::Models::Date do
4
- describe '#initialize' do
5
- subject { EPUBInfo::Models::Date.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf')).css('metadata').xpath('.//dc:date').first) }
6
-
7
- its(:time) { should == Time.parse('2005-08-17') }
8
- its(:event) { should == 'publication' }
9
- end
10
-
11
- describe '#to_hash' do
12
- context 'keys' do
13
- subject { EPUBInfo::Models::Date.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf')).css('metadata').xpath('.//dc:date').first).to_hash.keys }
14
- it { should include :time }
15
- it { should include :event }
16
- end
17
- end
18
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe EPUBInfo::Models::Identifier do
4
- describe '#initialize' do
5
- context 'EPUB2' do
6
- 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) }
7
-
8
- its(:identifier) { should == 'http://www.gutenberg.org/ebooks/5200' }
9
- its(:scheme) { should == 'URI' }
10
- end
11
-
12
- context 'EPUB3' do
13
- 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) }
14
-
15
- its(:identifier) { should == 'code.google.com.epub-samples.wasteland-basic' }
16
- end
17
- end
18
-
19
- describe '#to_hash' do
20
- context 'keys' do
21
- 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).to_hash.keys }
22
- it { should include :identifier }
23
- it { should include :scheme }
24
- end
25
- end
26
- end
27
-
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe EPUBInfo::Models::Person do
4
- describe '#initialize' do
5
- context 'creator' do
6
- subject { EPUBInfo::Models::Person.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf')).css('metadata').xpath('.//dc:creator').first) }
7
-
8
- its(:name) { should == 'Franz Kafka' }
9
- its(:file_as) { should == 'Kafka, Franz' }
10
- its(:role) { should be_nil }
11
- end
12
-
13
- context 'contributor' do
14
- subject { EPUBInfo::Models::Person.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf')).css('metadata').xpath('.//dc:contributor').first) }
15
-
16
- its(:name) { should == 'David Wyllie' }
17
- its(:file_as) { should == 'Wyllie, David' }
18
- its(:role) { should == 'trl' }
19
- end
20
- end
21
-
22
- describe '#initialize' do
23
- context 'keys' do
24
- subject { EPUBInfo::Models::Person.new(Nokogiri::XML(File.new('spec/support/xml/metamorphosis_metadata_epub2.opf')).css('metadata').xpath('.//dc:creator').first).to_hash.keys }
25
- it { should include :name }
26
- it { should include :file_as }
27
- it { should include :role }
28
- end
29
- end
30
- end
31
-
@@ -1,111 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe EPUBInfo::Parser do
4
- let(:epub_path) { File.expand_path('spec/support/binary/metamorphosis_epub2.epub') }
5
- let(:parser) { EPUBInfo::Parser.parse(epub_path) }
6
-
7
- describe '#parse' do
8
- it 'should assign path to @path' do
9
- parser # preload to avoid infinite loop
10
- EPUBInfo::Parser.stub(:new) { parser }
11
- EPUBInfo::Parser.parse(epub_path)
12
- parser.path.should == epub_path
13
- end
14
- end
15
-
16
- describe '#load_epub' do
17
- it 'assigns zipfile to @zipfile' do
18
- parser.send(:load_epub)
19
- parser.instance_variable_get(:@zipfile).should be_kind_of Zip::ZipFile
20
- end
21
- end
22
-
23
- describe '#load_root_file' do
24
- it 'should assign nokogiri document to @root_document' do
25
- parser.send(:load_epub)
26
- parser.send(:load_root_file)
27
- parser.instance_variable_get(:@root_document).should be_kind_of Nokogiri::XML::Document
28
- end
29
-
30
- it 'should call load_epub if @zipfile is nil' do
31
- zipfile = Zip::ZipFile.new(epub_path)
32
- zipfile.stub(:read) { '' }
33
- parser.should_receive(:load_epub) { parser.instance_variable_set(:@zipfile, zipfile); nil }
34
- parser.send(:load_root_file)
35
- end
36
- end
37
-
38
- describe '#metadata_path' do
39
- it 'should return path to metadata file' do
40
- parser.send(:metadata_path).should == '5200/content.opf'
41
- end
42
-
43
- it 'should call load_root_file if @root_document is nil' do
44
- xml_document = Nokogiri::XML::Document.new
45
- xml_document.stub_chain(:css, :attribute, :content)
46
- parser.should_receive(:load_root_file) { parser.instance_variable_set(:@root_document, xml_document); nil }
47
- parser.send(:metadata_path)
48
- end
49
- end
50
-
51
- describe '#metadata_document' do
52
- it 'should call load_metadata_file and assign to @metadata_document' do
53
- parser.should_receive(:load_metadata_file) { 'loaded' }
54
- parser.metadata_document
55
- parser.instance_variable_get(:@metadata_document).should == 'loaded'
56
- end
57
-
58
- it 'should not call load_metadata_file if @metadata_document is not nil' do
59
- parser.instance_variable_set(:@metadata_document, 'loaded')
60
- parser.should_not_receive(:load_metadata_file)
61
- parser.metadata_document
62
- end
63
- end
64
-
65
- describe '#drm_protected?' do
66
- it 'should call load_epub if nil' do
67
- zipfile_mock = mock(:find_entry => true)
68
- parser.should_receive(:load_epub) { parser.instance_variable_set(:@zipfile, zipfile_mock); nil }
69
- parser.drm_protected?
70
- parser.instance_variable_get(:@zipfile).should == zipfile_mock
71
- end
72
-
73
- context 'drm' do
74
- let(:epub_path) { File.expand_path('spec/support/binary/metamorphosis_epub2_drm.epub') }
75
-
76
- it 'should return true if rights.xml exists' do
77
- parser = EPUBInfo::Parser.parse(epub_path)
78
- parser.drm_protected?.should be_true
79
- end
80
- end
81
-
82
- context 'no drm' do
83
- let(:epub_path) { File.expand_path('spec/support/binary/metamorphosis_epub2.epub') }
84
-
85
- it 'should return false if rights.xml does not exist' do
86
- parser = EPUBInfo::Parser.parse(epub_path)
87
- parser.drm_protected?.should be_false
88
- end
89
- end
90
- end
91
-
92
- describe '#load_metadata_file' do
93
- it 'should return xml document' do
94
- parser.send(:load_root_file)
95
- parser.send(:load_metadata_file).should be_kind_of Nokogiri::XML::Document
96
- end
97
-
98
- it 'should call load_epub if @zipfile is nil' do
99
- zipfile = Zip::ZipFile.new(epub_path)
100
- zipfile.stub(:read) { '' }
101
- parser.should_receive(:load_epub) { parser.instance_variable_set(:@zipfile, zipfile); nil }
102
-
103
- xml_document = Nokogiri::XML::Document.new
104
- xml_document.stub_chain(:css, :attribute, :content)
105
- parser.should_receive(:load_root_file) { parser.instance_variable_set(:@root_document, xml_document); nil }
106
-
107
- parser.send(:load_metadata_file)
108
- end
109
- end
110
- end
111
-
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe EPUBInfo do
4
- let(:epub_path) { File.expand_path('spec/support/binary/metamorphosis_epub2.epub') }
5
-
6
- describe '#get' do
7
- it 'calls parser' do
8
- document = EPUBInfo::Parser.parse(epub_path).metadata_document
9
- parser = mock
10
- parser.stub(:metadata_document)
11
- parser.stub(:drm_protected?)
12
- EPUBInfo::Parser.should_receive(:parse) { parser }
13
- EPUBInfo.get(epub_path)
14
- end
15
-
16
- it 'instanstiates a book model and returns it' do
17
- book_mock = mock
18
- EPUBInfo::Models::Book.should_receive(:new) { book_mock }
19
- EPUBInfo.get(epub_path).should == book_mock
20
- end
21
- end
22
- end
23
-
data/spec/spec_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- require 'bundler'
2
- begin
3
- Bundler.setup(:default, :development)
4
- rescue Bundler::BundlerError => e
5
- $stderr.puts e.message
6
- $stderr.puts 'Run `bundle install` to install missing gems'
7
- exit e.status_code
8
- end
9
-
10
- require 'simplecov'
11
- SimpleCov.start do
12
- add_filter 'spec'
13
- end
14
-
15
- require 'epubinfo'
16
-
17
- RSpec.configure do |config|
18
- config.filter_run :focus => true
19
- config.run_all_when_everything_filtered = true
20
- config.treat_symbols_as_metadata_keys_with_true_values = true
21
- end
22
-
@@ -1,32 +0,0 @@
1
- <?xml version='1.0' encoding='UTF-8'?>
2
-
3
- <package xmlns:opf="http://www.idpf.org/2007/opf" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="id">
4
- <metadata>
5
- <dc:rights>Copyrighted. Read the copyright notice inside this book for details.</dc:rights>
6
- <dc:identifier id="id" opf:scheme="URI">http://www.gutenberg.org/ebooks/5200</dc:identifier>
7
- <dc:contributor opf:file-as="Wyllie, David" opf:role="trl">David Wyllie</dc:contributor>
8
- <dc:creator opf:file-as="Kafka, Franz">Franz Kafka</dc:creator>
9
- <dc:title>Metamorphosis</dc:title>
10
- <dc:language xsi:type="dcterms:RFC4646">en</dc:language>
11
- <dc:subject>Psychological fiction</dc:subject>
12
- <dc:subject>Metamorphosis -- Fiction</dc:subject>
13
- <dc:date opf:event="publication">2005-08-17</dc:date>
14
- <dc:date opf:event="conversion">2010-02-15T04:42:48.107119+00:00</dc:date>
15
- <dc:source>http://www.gutenberg.org/files/5200/5200-h/5200-h.htm</dc:source>
16
- <dc:description>Classic story of self-discovery, told in a unique manner by Kafka.</dc:description>
17
- <dc:publisher>Random House</dc:publisher>
18
- <meta content="item3" name="cover"/>
19
- </metadata>
20
- <manifest>
21
- <item href="pgepub.css" id="item1" media-type="text/css"/>
22
- <item href="www.gutenberg.org@files@5200@5200-h@5200-h-0.htm" id="item2" media-type="application/xhtml+xml"/>
23
- <item href="cover.jpg" id="item3" media-type="image/jpeg"/>
24
- <item href="toc.ncx" id="ncx" media-type="application/x-dtbncx+xml"/>
25
- </manifest>
26
- <spine toc="ncx">
27
- <itemref idref="item2" linear="yes"/>
28
- </spine>
29
- <guide>
30
- <reference href="cover.jpg" type="cover" title="Cover Image"/>
31
- </guide>
32
- </package>
@@ -1,36 +0,0 @@
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>