epubber 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -13
- data/epubber.gemspec +1 -0
- data/lib/epubber/models/concerns/has_chapters.rb +3 -2
- data/lib/epubber/models/concerns/has_endnotes.rb +2 -2
- data/lib/epubber/models/concerns/has_introduction.rb +1 -1
- data/lib/epubber/services/persistance.rb +1 -1
- data/lib/epubber/version.rb +1 -1
- data/lib/epubber.rb +2 -2
- data/test/test_epubber.rb +13 -13
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 054611e5caa73165a0033e77320b5f3382226fec
|
4
|
+
data.tar.gz: f5daa10b8e040f4904c28c6eae772b7c59c90957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0561c9a2afdbaf26ff71b83875361f7908b5a7a9398d75f97dff0dcda3de3d6753d52fb575bea3ae891d54dd4c23db30a5fac374df8dd87cd0ef2c1ca98c7cc
|
7
|
+
data.tar.gz: ba7fadf75790e51e1756ba2abd74b40a8b54caae84b82b976807f69ab0bd76dcdc72c633912069da361bfebcac2b58443fbef6495e04f9e444ce16142d9e1708
|
data/README.md
CHANGED
@@ -20,20 +20,24 @@ Or install it yourself as:
|
|
20
20
|
Epubber's DSL is rather simple:
|
21
21
|
|
22
22
|
```ruby
|
23
|
-
path = Epubber.generate do
|
24
|
-
title 'My First EPUB book'
|
25
|
-
author 'Ramirez, Federico'
|
26
|
-
description 'This is an example EPUB'
|
27
|
-
url 'http://my-url.com'
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
content '<p>This is some content!</p>'
|
23
|
+
path = Epubber.generate do |b|
|
24
|
+
b.title 'My First EPUB book'
|
25
|
+
b.author 'Ramirez, Federico'
|
26
|
+
b.description 'This is an example EPUB'
|
27
|
+
b.url 'http://my-url.com'
|
28
|
+
|
29
|
+
b.introduction do |i|
|
30
|
+
i.content '<p>This is an introduction.</p>'
|
32
31
|
end
|
33
32
|
|
34
|
-
chapter do
|
35
|
-
title 'Chapter
|
36
|
-
content '<p>
|
33
|
+
b.chapter do |c|
|
34
|
+
c.title 'Chapter 1'
|
35
|
+
c.content '<p>This is some content!</p>'
|
36
|
+
end
|
37
|
+
|
38
|
+
b.chapter do |c|
|
39
|
+
c.title 'Chapter 2'
|
40
|
+
c.content '<p>Some more content this is.</p>'
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
@@ -44,7 +48,7 @@ end
|
|
44
48
|
You can configure the generator
|
45
49
|
|
46
50
|
```ruby
|
47
|
-
path = Epubber.generate filename: 'some-file.epub', workspace: '/tmp' do
|
51
|
+
path = Epubber.generate filename: 'some-file.epub', workspace: '/tmp' do |b|
|
48
52
|
# Ebook code here...
|
49
53
|
end
|
50
54
|
```
|
data/epubber.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest"
|
23
24
|
|
24
25
|
spec.add_runtime_dependency "liquid", "~> 3.0"
|
25
26
|
spec.add_runtime_dependency "rubyzip", ">= 1.0.0"
|
@@ -7,9 +7,10 @@ module Epubber::Models::Concerns
|
|
7
7
|
end
|
8
8
|
|
9
9
|
# Add chapter
|
10
|
-
def chapter
|
10
|
+
def chapter
|
11
|
+
raise 'No block given' unless block_given?
|
11
12
|
chapter = Epubber::Models::Chapter.new
|
12
|
-
chapter
|
13
|
+
yield chapter
|
13
14
|
chapter.id(chapters.count + 1)
|
14
15
|
chapters << chapter
|
15
16
|
end
|
@@ -2,11 +2,11 @@ require 'epubber/models/endnotes'
|
|
2
2
|
|
3
3
|
module Epubber::Models::Concerns
|
4
4
|
module HasEndnotes
|
5
|
-
def endnotes
|
5
|
+
def endnotes
|
6
6
|
@endnotes ||= nil
|
7
7
|
return @endnotes unless block_given?
|
8
8
|
@endnotes = Epubber::Models::Endnotes.new
|
9
|
-
@endnotes
|
9
|
+
yield @endnotes
|
10
10
|
end
|
11
11
|
|
12
12
|
def contextified_endnotes
|
@@ -7,7 +7,7 @@ module Epubber::Services
|
|
7
7
|
|
8
8
|
# Persist a file into the working directory with the spcified contents.
|
9
9
|
# The file argument is the relative path to the new file, eg: test/chapters/file.xhtml
|
10
|
-
def persist(file
|
10
|
+
def persist(file:, content:)
|
11
11
|
create_path_for file
|
12
12
|
write file, content
|
13
13
|
end
|
data/lib/epubber/version.rb
CHANGED
data/lib/epubber.rb
CHANGED
@@ -3,9 +3,9 @@ require "epubber/models/book"
|
|
3
3
|
require "epubber/generator"
|
4
4
|
|
5
5
|
module Epubber
|
6
|
-
def self.generate(filename: filename = nil, working_dir: working_dir = nil
|
6
|
+
def self.generate(filename: filename = nil, working_dir: working_dir = nil)
|
7
7
|
book = Epubber::Models::Book.new
|
8
|
-
book
|
8
|
+
yield book
|
9
9
|
generator = Epubber::Generator.new book: book, working_dir: working_dir, filename: filename
|
10
10
|
generator.generate
|
11
11
|
end
|
data/test/test_epubber.rb
CHANGED
@@ -3,26 +3,26 @@ require 'epubber'
|
|
3
3
|
|
4
4
|
class EpubberTest < Minitest::Test
|
5
5
|
def test_dsl
|
6
|
-
result = Epubber.generate do
|
7
|
-
title 'My First EPUB book'
|
8
|
-
author 'Ramirez, Federico'
|
6
|
+
result = Epubber.generate do |b|
|
7
|
+
b.title 'My First EPUB book'
|
8
|
+
b.author 'Ramirez, Federico'
|
9
9
|
|
10
|
-
introduction do
|
11
|
-
content "<p>This is the introduction, and it's optional. What is this book about?</p>"
|
10
|
+
b.introduction do |i|
|
11
|
+
i.content "<p>This is the introduction, and it's optional. What is this book about?</p>"
|
12
12
|
end
|
13
13
|
|
14
|
-
chapter do
|
15
|
-
title 'Chapter 1'
|
16
|
-
content '<p>This is some content!</p>'
|
14
|
+
b.chapter do |c|
|
15
|
+
c.title 'Chapter 1'
|
16
|
+
c.content '<p>This is some content!</p>'
|
17
17
|
end
|
18
18
|
|
19
|
-
chapter do
|
20
|
-
title 'Chapter 2'
|
21
|
-
content '<p>Some more content this is.</p>'
|
19
|
+
b.chapter do |c|
|
20
|
+
c.title 'Chapter 2'
|
21
|
+
c.content '<p>Some more content this is.</p>'
|
22
22
|
end
|
23
23
|
|
24
|
-
endnotes do
|
25
|
-
content '<p>This was a fun book. Thanks for reading!</p>'
|
24
|
+
b.endnotes do |e|
|
25
|
+
e.content '<p>This was a fun book. Thanks for reading!</p>'
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epubber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Federico Ramirez
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: liquid
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|