epubinfo 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,13 @@
2
2
 
3
3
  Extracts metadata information from EPUB files. Supports EPUB2 and EPUB3 formats.
4
4
 
5
+ == Usage
6
+
7
+ require 'epubinfo'
8
+ EPUBInfo.get('path/to/epub/file.epub')
9
+
10
+ Which returns a +EPUBInfo::Models::Book+ instance, please refer to the {API documentation}[http://rubydoc.info/gems/epubinfo/frames] from here on
11
+
5
12
  == Contributing to epubinfo
6
13
 
7
14
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ Jeweler::Tasks.new do |gem|
18
18
  gem.homepage = "http://github.com/chdorner/epubinfo"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{Extracts metadata information from EPUB files}
21
- gem.description = %Q{Currently only supports EPUB 3 specification.}
21
+ gem.description = %Q{Supports EPUB2 and EPUB3 formats.}
22
22
  gem.email = "christof@chdorner.com"
23
23
  gem.authors = ["Christof Dorner"]
24
24
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "epubinfo"
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Christof Dorner"]
12
12
  s.date = "2012-04-04"
13
- s.description = "Currently only supports EPUB 3 specification."
13
+ s.description = "Supports EPUB2 and EPUB3 formats."
14
14
  s.email = "christof@chdorner.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
@@ -10,7 +10,7 @@ require 'epubinfo/utils'
10
10
 
11
11
  module EPUBInfo
12
12
  # Parses an epub file and returns a Book instance.
13
- # @return [EPUBInfo::Models::Book] the model
13
+ # @return [EPUBInfo::Models::Book] a model representation of the epub file
14
14
  def self.get(path)
15
15
  parser = EPUBInfo::Parser.parse(path)
16
16
  EPUBInfo::Models::Book.new(parser.metadata_document)
@@ -1,10 +1,41 @@
1
1
  module EPUBInfo
2
2
  module Models
3
3
  class Book
4
- attr_accessor :titles, :creators, :subjects, :description,
5
- :publisher, :contributors, :dates, :identifiers,
6
- :source, :languages, :rights
4
+ # Titles, array of String instances ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.1 EPUB2 reference})
5
+ # @return [Array]
6
+ attr_accessor :titles
7
+ # Creators, array of Person instances ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.2 EPUB2 reference})
8
+ # @return [Array]
9
+ attr_accessor :creators
10
+ # Subjects, array of String instances ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.3 EPUB2 reference})
11
+ # @return [Array]
12
+ attr_accessor :subjects
13
+ # Description ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.4 EPUB2 reference})
14
+ # @return [String]
15
+ attr_accessor :description
16
+ # Publisher ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.5 EPUB2 reference})
17
+ # @return [String]
18
+ attr_accessor :publisher
19
+ # Contributors, array of Person instances ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.6 EPUB2 reference})
20
+ # @return [Array]
21
+ attr_accessor :contributors
22
+ # Dates, array of Date instances ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.7 EPUB2 reference})
23
+ # @return [Array]
24
+ attr_accessor :dates
25
+ # Identifiers, array of Identifier instances ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.10 EPUB2 reference})
26
+ # @return [Array]
27
+ attr_accessor :identifiers
28
+ # Source ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.11 EPUB2 reference})
29
+ # @return [String]
30
+ attr_accessor :source
31
+ # Languages, array of String instances ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.12 EPUB2 reference})
32
+ # @return [Array]
33
+ attr_accessor :languages
34
+ # Rights ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.15 EPUB2 reference})
35
+ # @return [String]
36
+ attr_accessor :rights
7
37
 
38
+ # Should never be called directly, go through EPUBInfo.get
8
39
  def initialize(document)
9
40
  return if document.nil?
10
41
  metadata = document.css('metadata')
@@ -29,6 +60,8 @@ module EPUBInfo
29
60
  def identifiers; @identifiers || []; end
30
61
  def languages; @languages || []; end
31
62
 
63
+ # Returns Hash representation of the book
64
+ # @return [Hash]
32
65
  def to_hash
33
66
  {
34
67
  :titles => @titles,
@@ -3,13 +3,21 @@ require 'time'
3
3
  module EPUBInfo
4
4
  module Models
5
5
  class Date
6
- attr_accessor :time, :event
6
+ # Time ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.7 EPUB2 reference})
7
+ # @return [Time]
8
+ attr_accessor :time
9
+ # Event ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.7 EPUB2 reference})
10
+ # @return [String]
11
+ attr_accessor :event
7
12
 
13
+ # Should never be called directly, go through EPUBInfo.get
8
14
  def initialize(node)
9
15
  self.time = Time.parse(node.content)
10
16
  self.event = node.attribute('event').content rescue nil
11
17
  end
12
18
 
19
+ # Returns Hash representation of a date
20
+ # @return [Hash]
13
21
  def to_hash
14
22
  {
15
23
  :time => @time,
@@ -1,13 +1,21 @@
1
1
  module EPUBInfo
2
2
  module Models
3
3
  class Identifier
4
- attr_accessor :identifier, :scheme
4
+ # Identifier ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.1 EPUB2 reference})
5
+ # @return [String]
6
+ attr_accessor :identifier
7
+ # Scheme ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.1 EPUB2 reference})
8
+ # @return [String]
9
+ attr_accessor :scheme
5
10
 
11
+ # Should never be called directly, go through EPUBInfo.get
6
12
  def initialize(node)
7
13
  self.identifier = node.content
8
14
  self.scheme = node.attribute('scheme').content rescue nil
9
15
  end
10
16
 
17
+ # Returns Hash representation of an identifier
18
+ # @return [Hash]
11
19
  def to_hash
12
20
  {
13
21
  :identifier => @identifier,
@@ -1,14 +1,25 @@
1
1
  module EPUBInfo
2
2
  module Models
3
3
  class Person
4
- attr_accessor :name, :file_as, :role
4
+ # Name ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.6 EPUB2 reference})
5
+ # @return [String]
6
+ attr_accessor :name
7
+ # File as ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.6 EPUB2 reference})
8
+ # @return [String]
9
+ attr_accessor :file_as
10
+ # Role ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.6 EPUB2 reference})
11
+ # @return [String]
12
+ attr_accessor :role
5
13
 
14
+ # Should never be called directly, go through EPUBInfo.get
6
15
  def initialize(node)
7
16
  self.name = node.content
8
17
  self.file_as = node.attribute('file-as').content rescue nil
9
18
  self.role = node.attribute('role').content rescue nil
10
19
  end
11
20
 
21
+ # Returns Hash representation of a person
22
+ # @return [Hash]
12
23
  def to_hash
13
24
  {
14
25
  :name => @name,
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.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubyzip
16
- requirement: &70144976238900 !ruby/object:Gem::Requirement
16
+ requirement: &70317303576920 !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: *70144976238900
24
+ version_requirements: *70317303576920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &70144976237580 !ruby/object:Gem::Requirement
27
+ requirement: &70317303575580 !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: *70144976237580
35
+ version_requirements: *70317303575580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70144976236920 !ruby/object:Gem::Requirement
38
+ requirement: &70317303574960 !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: *70144976236920
46
+ version_requirements: *70317303574960
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard
49
- requirement: &70144976236060 !ruby/object:Gem::Requirement
49
+ requirement: &70317303574080 !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: *70144976236060
57
+ version_requirements: *70317303574080
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70144976235400 !ruby/object:Gem::Requirement
60
+ requirement: &70317303573420 !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: *70144976235400
68
+ version_requirements: *70317303573420
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &70144976234360 !ruby/object:Gem::Requirement
71
+ requirement: &70317303572380 !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: *70144976234360
79
+ version_requirements: *70317303572380
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov
82
- requirement: &70144976233760 !ruby/object:Gem::Requirement
82
+ requirement: &70317303571780 !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: *70144976233760
90
+ version_requirements: *70317303571780
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: guard
93
- requirement: &70144976233080 !ruby/object:Gem::Requirement
93
+ requirement: &70317303571100 !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: *70144976233080
101
+ version_requirements: *70317303571100
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: guard-rspec
104
- requirement: &70144976231960 !ruby/object:Gem::Requirement
104
+ requirement: &70317303569860 !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: *70144976231960
112
+ version_requirements: *70317303569860
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rb-fsevent
115
- requirement: &70144976229800 !ruby/object:Gem::Requirement
115
+ requirement: &70317303567760 !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: *70144976229800
123
+ version_requirements: *70317303567760
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: growl
126
- requirement: &70144976228360 !ruby/object:Gem::Requirement
126
+ requirement: &70317303566320 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,8 +131,8 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70144976228360
135
- description: Currently only supports EPUB 3 specification.
134
+ version_requirements: *70317303566320
135
+ description: Supports EPUB2 and EPUB3 formats.
136
136
  email: christof@chdorner.com
137
137
  executables: []
138
138
  extensions: []
@@ -183,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
183
  version: '0'
184
184
  segments:
185
185
  - 0
186
- hash: 1349912243114699965
186
+ hash: -2345000365980231585
187
187
  required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  none: false
189
189
  requirements: