epubinfo 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- # epubinfo [![Continuous Integration](https://secure.travis-ci.org/chdorner/epubinfo.png?branch=master)](http://travis-ci.org/chdorner/epubinfo) [![Dependencies](https://gemnasium.com/chdorner/epubinfo.png)](http://gemnasium.com/chdorner/epubinfo)
2
-
1
+ # epubinfo [![Continuous Integration](https://secure.travis-ci.org/chdorner/epubinfo.png?branch=master)](http://travis-ci.org/chdorner/epubinfo)
3
2
  Extracts metadata information from EPUB files. Supports EPUB2 and EPUB3 formats.
4
3
 
5
4
  ## Usage
@@ -13,6 +12,11 @@ Which returns a `EPUBInfo::Models::Book` instance, please refer to the [API docu
13
12
 
14
13
  ## Changelog
15
14
 
15
+ **0.4.1** *February 15, 2013*
16
+
17
+ * Added Book#version to get EPUB version of the file
18
+ * Added support for modified_date in Book#dates
19
+
16
20
  **0.4.0** *July 31, 2012*
17
21
 
18
22
  * Added Book#cover method for extracting covers from epubs
@@ -62,12 +62,17 @@ module EPUBInfo
62
62
  # @return [Cover]
63
63
  attr_accessor :cover
64
64
 
65
+ # EPUB Version ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section1.4.1.2})
66
+ # @return [String]
67
+ attr_accessor :version
68
+
65
69
  # Should never be called directly, go through EPUBInfo.get
66
70
  def initialize(parser)
67
71
  document = parser.metadata_document
68
72
  return if document.nil?
69
73
  document.remove_namespaces!
70
74
  metadata = document.css('metadata')
75
+ self.version = document.css('package')[0]['version']
71
76
  self.titles = metadata.xpath('.//title').map(&:content)
72
77
  self.creators = metadata.xpath('.//creator').map {|c| EPUBInfo::Models::Person.new(c) }
73
78
  self.subjects = metadata.xpath('.//subject').map(&:content)
@@ -75,6 +80,12 @@ module EPUBInfo
75
80
  self.publisher = metadata.xpath('.//publisher').first.content rescue nil
76
81
  self.contributors = metadata.xpath('.//contributor').map {|c| EPUBInfo::Models::Person.new(c) }
77
82
  self.dates = metadata.xpath('.//date').map { |d| EPUBInfo::Models::Date.new(d) }
83
+ modified_date = metadata.xpath(".//meta[@property='dcterms:modified']").map do |d|
84
+ date = EPUBInfo::Models::Date.new(d)
85
+ date.event = 'modification'
86
+ date
87
+ end
88
+ self.dates += modified_date;
78
89
  self.identifiers = metadata.xpath('.//identifier').map { |i| EPUBInfo::Models::Identifier.new(i) }
79
90
  self.source = metadata.xpath('.//source').first.content rescue nil
80
91
  self.languages = metadata.xpath('.//language').map(&:content)
@@ -28,7 +28,6 @@ module EPUBInfo
28
28
  # Content type of cover file
29
29
  # @return [String]
30
30
  attr_accessor :content_type
31
- def content_type; @content_type; end
32
31
 
33
32
  # Cover exists?
34
33
  # @return [Boolean]
@@ -41,6 +40,7 @@ module EPUBInfo
41
40
  # @return [File]
42
41
  # Tempfile is used to enable access to cover file
43
42
  # If block is passed, the tempfile is passed to it
43
+ # and closed after the block is executed
44
44
  # cover.file do { |f| puts f.size }
45
45
  # Otherwise user is responsible to unlink and close tempfile
46
46
  # file = book.cover.file
@@ -75,7 +75,7 @@ module EPUBInfo
75
75
  def epub_cover_item
76
76
  @epub_cover_item ||= begin
77
77
  metadata = @parser.metadata_document.css('metadata')
78
- cover_id = metadata.css('meta [name=cover]').attr('content').value rescue nil || 'cover-image'
78
+ cover_id = (metadata.css('meta [name=cover]').attr('content').value rescue nil) || 'cover-image'
79
79
 
80
80
  manifest = @parser.metadata_document.css('manifest')
81
81
 
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.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-31 00:00:00.000000000 Z
12
+ date: 2013-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubyzip
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 1.1.3
85
+ version: 1.2.4
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 1.1.3
93
+ version: 1.2.4
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: jeweler
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -203,6 +203,22 @@ dependencies:
203
203
  - - ! '>='
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: redcarpet
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
206
222
  description: Supports EPUB2 and EPUB3 formats.
207
223
  email: christof@chdorner.com
208
224
  executables: []
@@ -236,7 +252,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
236
252
  version: '0'
237
253
  segments:
238
254
  - 0
239
- hash: 425566557774208517
255
+ hash: -351582616179957298
240
256
  required_rubygems_version: !ruby/object:Gem::Requirement
241
257
  none: false
242
258
  requirements:
@@ -245,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
261
  version: '0'
246
262
  requirements: []
247
263
  rubyforge_project:
248
- rubygems_version: 1.8.24
264
+ rubygems_version: 1.8.23
249
265
  signing_key:
250
266
  specification_version: 3
251
267
  summary: Extracts metadata information from EPUB files