mobi 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +16 -3
- data/Gemfile +2 -2
- data/Gemfile.lock +11 -11
- data/{README.rdoc → README.md} +48 -23
- data/VERSION +1 -1
- data/mobi.gemspec +11 -11
- data/spec/lib/mobi/metadata_spec.rb +8 -5
- metadata +10 -10
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
## 1.0.0
|
4
4
|
|
5
|
-
*
|
5
|
+
* No implementation changes. Bumping to 1.0 because there have been no issues raised for over a year, and just because I can!
|
6
|
+
* Update RSpec.
|
7
|
+
* Update Bundler.
|
8
|
+
|
9
|
+
## 0.2.0
|
10
|
+
|
11
|
+
* Extract EXTH header data into it's own class.
|
12
|
+
* Parse Mobi header data.
|
13
|
+
* Parse PalmDOC header data.
|
14
|
+
* Large internals refactoring, and now with added tests!
|
15
|
+
|
16
|
+
## 0.1.2
|
17
|
+
|
18
|
+
* Trying to instantiate Mobi::Metadata with an invalid mobi file now raises an InvalidMobi exception
|
data/Gemfile
CHANGED
@@ -6,8 +6,8 @@ source "http://rubygems.org"
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
8
|
group :development do
|
9
|
-
gem 'rspec', '~> 2.
|
9
|
+
gem 'rspec', '~> 2.14.0'
|
10
10
|
gem 'rr', '~> 1.0.4'
|
11
|
-
gem 'bundler', '~> 1.
|
11
|
+
gem 'bundler', '~> 1.3.0'
|
12
12
|
gem 'jeweler', '~> 1.8.0'
|
13
13
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
diff-lcs (1.
|
4
|
+
diff-lcs (1.2.4)
|
5
5
|
git (1.2.5)
|
6
6
|
jeweler (1.8.3)
|
7
7
|
bundler (~> 1.0)
|
@@ -13,20 +13,20 @@ GEM
|
|
13
13
|
rdoc (3.12)
|
14
14
|
json (~> 1.4)
|
15
15
|
rr (1.0.4)
|
16
|
-
rspec (2.
|
17
|
-
rspec-core (~> 2.
|
18
|
-
rspec-expectations (~> 2.
|
19
|
-
rspec-mocks (~> 2.
|
20
|
-
rspec-core (2.
|
21
|
-
rspec-expectations (2.
|
22
|
-
diff-lcs (
|
23
|
-
rspec-mocks (2.
|
16
|
+
rspec (2.14.1)
|
17
|
+
rspec-core (~> 2.14.0)
|
18
|
+
rspec-expectations (~> 2.14.0)
|
19
|
+
rspec-mocks (~> 2.14.0)
|
20
|
+
rspec-core (2.14.5)
|
21
|
+
rspec-expectations (2.14.3)
|
22
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
23
|
+
rspec-mocks (2.14.3)
|
24
24
|
|
25
25
|
PLATFORMS
|
26
26
|
ruby
|
27
27
|
|
28
28
|
DEPENDENCIES
|
29
|
-
bundler (~> 1.
|
29
|
+
bundler (~> 1.3.0)
|
30
30
|
jeweler (~> 1.8.0)
|
31
31
|
rr (~> 1.0.4)
|
32
|
-
rspec (~> 2.
|
32
|
+
rspec (~> 2.14.0)
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,34 +1,40 @@
|
|
1
|
-
|
1
|
+
# mobi
|
2
2
|
|
3
3
|
A Ruby Gem that reads MOBI metadata.
|
4
4
|
|
5
|
-
|
5
|
+
## Ruby
|
6
6
|
|
7
|
-
|
7
|
+
Compatible up to ruby 2.0.0p0.
|
8
8
|
|
9
|
-
|
9
|
+
I haven't tested beyond that version, but it should work.
|
10
10
|
|
11
|
-
|
11
|
+
## Installation
|
12
12
|
|
13
|
-
|
13
|
+
`gem install mobi`
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
== Usage
|
15
|
+
## Usage
|
18
16
|
|
19
17
|
Creating a Mobi::Metadata object
|
20
18
|
|
21
|
-
|
22
|
-
|
19
|
+
```ruby
|
20
|
+
Mobi::Metadata.new(File.open('/path/to/file.mobi'))
|
21
|
+
```
|
22
|
+
|
23
23
|
A handy convenience method to do the exact same thing
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
```ruby
|
26
|
+
Mobi.metadata File.open('/path/to/file.mobi')
|
27
|
+
```
|
28
|
+
|
27
29
|
Getting metadata information is as simple as:
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
```ruby
|
32
|
+
metadata = Mobi.metadata File.open('/path/to/fellowship_of_the_ring.mobi')
|
33
|
+
#=> #<Mobi::Metadata>
|
34
|
+
metadata.author
|
35
|
+
#=> "J.R.R. Tolkien"
|
36
|
+
```
|
37
|
+
|
32
38
|
Supported metadata options are:
|
33
39
|
|
34
40
|
* author
|
@@ -47,12 +53,32 @@ Supported metadata options are:
|
|
47
53
|
* asin
|
48
54
|
* version
|
49
55
|
|
50
|
-
|
56
|
+
You can also drill down and get the PalmDOC and MOBI header details:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
palm_doc_header = metadata.palm_doc_header
|
60
|
+
#=> #<Mobi::Header::PalmDocHeader>
|
61
|
+
palm_doc_header.raw_compression_type
|
62
|
+
#=> 2
|
63
|
+
palm_doc_header.compression_type
|
64
|
+
#=> "PalmDOC"
|
65
|
+
|
66
|
+
mobi_header = metadata.mobi_header
|
67
|
+
#=> #<Mobi::Header::MobiHeader>
|
68
|
+
mobi_header.raw_mobi_type
|
69
|
+
#=> 2
|
70
|
+
mobi_header.mobi_type
|
71
|
+
#=> "MOBIpocket Book"
|
72
|
+
```
|
73
|
+
|
74
|
+
See the source for more methods.
|
75
|
+
|
76
|
+
## Thanks
|
77
|
+
|
78
|
+
* Calibre open source project. I ripped off the idea of a Stream Slicer and got a better understanding of MOBI files from their code base. Check them out at http://calibre-ebook.com
|
51
79
|
|
52
|
-
|
80
|
+
## Contributing to mobi
|
53
81
|
|
54
|
-
== Contributing to mobi
|
55
|
-
|
56
82
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
57
83
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
58
84
|
* Fork the project
|
@@ -61,8 +87,7 @@ Supported metadata options are:
|
|
61
87
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
62
88
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
63
89
|
|
64
|
-
|
90
|
+
## Copyright
|
65
91
|
|
66
|
-
Copyright (c) 2011 jkongie. See LICENSE.txt for
|
67
|
-
further details.
|
92
|
+
Copyright (c) 2011 jkongie. See LICENSE.txt for further details.
|
68
93
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/mobi.gemspec
CHANGED
@@ -5,16 +5,16 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "mobi"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["jkongie"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-10-04"
|
13
13
|
s.description = "Mobi is a Rubygem that allows you to easily read MOBI e-book format metadata."
|
14
14
|
s.email = "jkongie@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
|
-
"README.
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
"Gemfile",
|
24
24
|
"Gemfile.lock",
|
25
25
|
"LICENSE.txt",
|
26
|
-
"README.
|
26
|
+
"README.md",
|
27
27
|
"Rakefile",
|
28
28
|
"VERSION",
|
29
29
|
"lib/mobi.rb",
|
@@ -46,27 +46,27 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.homepage = "http://github.com/jkongie/mobi"
|
47
47
|
s.licenses = ["MIT"]
|
48
48
|
s.require_paths = ["lib"]
|
49
|
-
s.rubygems_version = "1.8.
|
49
|
+
s.rubygems_version = "1.8.23"
|
50
50
|
s.summary = "A Rubygem that inspects MOBI metadata."
|
51
51
|
|
52
52
|
if s.respond_to? :specification_version then
|
53
53
|
s.specification_version = 3
|
54
54
|
|
55
55
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
56
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.
|
56
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.14.0"])
|
57
57
|
s.add_development_dependency(%q<rr>, ["~> 1.0.4"])
|
58
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.
|
58
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.3.0"])
|
59
59
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.0"])
|
60
60
|
else
|
61
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
61
|
+
s.add_dependency(%q<rspec>, ["~> 2.14.0"])
|
62
62
|
s.add_dependency(%q<rr>, ["~> 1.0.4"])
|
63
|
-
s.add_dependency(%q<bundler>, ["~> 1.
|
63
|
+
s.add_dependency(%q<bundler>, ["~> 1.3.0"])
|
64
64
|
s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
|
65
65
|
end
|
66
66
|
else
|
67
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
67
|
+
s.add_dependency(%q<rspec>, ["~> 2.14.0"])
|
68
68
|
s.add_dependency(%q<rr>, ["~> 1.0.4"])
|
69
|
-
s.add_dependency(%q<bundler>, ["~> 1.
|
69
|
+
s.add_dependency(%q<bundler>, ["~> 1.3.0"])
|
70
70
|
s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
|
71
71
|
end
|
72
72
|
end
|
@@ -3,11 +3,14 @@ require 'spec_helper'
|
|
3
3
|
require 'mobi'
|
4
4
|
|
5
5
|
describe Mobi::Metadata do
|
6
|
-
|
6
|
+
before :all do
|
7
|
+
@file = File.open('spec/fixtures/sherlock.mobi')
|
8
|
+
end
|
9
|
+
|
7
10
|
|
8
11
|
context 'initialization' do
|
9
12
|
it 'should instantiate a StreamSlicer from the file' do
|
10
|
-
metadata = Mobi::Metadata.new(file)
|
13
|
+
metadata = Mobi::Metadata.new(@file)
|
11
14
|
|
12
15
|
metadata.data.should be_instance_of(Mobi::StreamSlicer)
|
13
16
|
end
|
@@ -17,12 +20,12 @@ describe Mobi::Metadata do
|
|
17
20
|
mock(m).bookmobi? { false }
|
18
21
|
end
|
19
22
|
|
20
|
-
lambda{ Mobi::Metadata.new(file) }.should raise_exception(Mobi::Metadata::InvalidMobi)
|
23
|
+
lambda{ Mobi::Metadata.new(@file) }.should raise_exception(Mobi::Metadata::InvalidMobi)
|
21
24
|
end
|
22
25
|
|
23
26
|
context 'instantiating headers' do
|
24
27
|
before :all do
|
25
|
-
@metadata = Mobi::Metadata.new(file)
|
28
|
+
@metadata = Mobi::Metadata.new(@file)
|
26
29
|
end
|
27
30
|
|
28
31
|
it 'should instantiate a palm doc header' do
|
@@ -41,7 +44,7 @@ describe Mobi::Metadata do
|
|
41
44
|
|
42
45
|
context 'instance' do
|
43
46
|
before :all do
|
44
|
-
@metadata = Mobi::Metadata.new(file)
|
47
|
+
@metadata = Mobi::Metadata.new(@file)
|
45
48
|
end
|
46
49
|
|
47
50
|
it 'gets the the title of the book' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
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:
|
12
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
21
|
+
version: 2.14.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.
|
29
|
+
version: 2.14.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rr
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.
|
53
|
+
version: 1.3.0
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.3.0
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: jeweler
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ executables: []
|
|
81
81
|
extensions: []
|
82
82
|
extra_rdoc_files:
|
83
83
|
- LICENSE.txt
|
84
|
-
- README.
|
84
|
+
- README.md
|
85
85
|
files:
|
86
86
|
- .document
|
87
87
|
- .rspec
|
@@ -89,7 +89,7 @@ files:
|
|
89
89
|
- Gemfile
|
90
90
|
- Gemfile.lock
|
91
91
|
- LICENSE.txt
|
92
|
-
- README.
|
92
|
+
- README.md
|
93
93
|
- Rakefile
|
94
94
|
- VERSION
|
95
95
|
- lib/mobi.rb
|
@@ -123,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
segments:
|
125
125
|
- 0
|
126
|
-
hash: -
|
126
|
+
hash: -833991204484823128
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 1.8.
|
135
|
+
rubygems_version: 1.8.23
|
136
136
|
signing_key:
|
137
137
|
specification_version: 3
|
138
138
|
summary: A Rubygem that inspects MOBI metadata.
|