-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cf15393
Showing
11 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.gem | ||
.bundle | ||
Gemfile.lock | ||
pkg/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--format nested |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source "http://rubygems.org" | ||
|
||
gemspec | ||
|
||
group :development, :test do | ||
gem "rspec" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'bundler/gem_tasks' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "epub-reader/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "epub-reader" | ||
s.version = Epub::Reader::VERSION | ||
s.authors = ["Fernando Almeida"] | ||
s.email = ["fernando@fernandoalmeida.net"] | ||
s.homepage = "http://bitbucket.com/fernandoalmeida/epub-reader" | ||
s.summary = "A library for accessing the content of EPUB files" | ||
s.description = "The epub-reader library implements a EPUB parser conforming as much as possible to the EPUB 3 specification from IDPF" | ||
|
||
s.rubyforge_project = "epub-reader" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
|
||
s.add_dependency('rubyzip') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require "epub-reader/version" | ||
require "epub-reader/reader" | ||
|
||
module Epub | ||
class FileNotFoundError < StandardError; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'zip/zipfilesystem' | ||
|
||
module Epub | ||
class Reader | ||
|
||
attr_reader :filename, :file | ||
|
||
def initialize(file) | ||
raise FileNotFoundError unless File.exists?(file) | ||
@filename = file | ||
@file = Zip::ZipFile.open(file) | ||
end | ||
|
||
def Reader.open(file) | ||
reader = Reader.new(file) | ||
if block_given? | ||
yield reader | ||
else | ||
reader | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Epub | ||
class Reader | ||
VERSION = "0.0.1" | ||
end | ||
end |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'spec_helper' | ||
|
||
describe Epub::Reader do | ||
|
||
before(:all) do | ||
@epub = Epub::Reader.open('spec/data/valid.epub') | ||
end | ||
|
||
it 'should open a epub file' do | ||
@epub.should_not be_nil | ||
end | ||
|
||
it 'should raise exception if file not found' do | ||
lambda { Epub::Reader.open('not_found.epub') }.should raise_error | ||
end | ||
|
||
it 'should have the epub file to handle' do | ||
@epub.file.should_not be_nil | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
$: << File.join(File.dirname(__FILE__), "/../lib") | ||
|
||
require "rspec" | ||
require "epub-reader" | ||
|
||
RSpec.configure do |c| | ||
c.mock_with :rspec | ||
end |