manbook 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -10
- data/Gemfile.lock +64 -12
- data/README.md +4 -0
- data/Rakefile +1 -2
- data/TODO +1 -1
- data/VERSION +1 -1
- data/bin/manbook +5 -2
- data/bin/mktoc +8 -3
- data/lib/manbook.rb +2 -2
- data/manbook.gemspec +94 -0
- data/templates/about.html.erb +0 -1
- data/templates/manbook.opf.erb +1 -1
- data/test/fixtures/alt-cover.jpg +0 -0
- data/test/helper.rb +7 -3
- data/test/unit/test_manbook.rb +29 -0
- data/test/unit/test_mktoc.rb +35 -17
- metadata +107 -114
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b5f2c9c00d580c00257ea87242c31b510a6fd9e4
|
4
|
+
data.tar.gz: f741230cd8ccd20d1a54f1aa268fae9bb16ff45f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 093fbb8eb2f50b33d333a1405c3fb3c0074d9c5e0ad9a1a160061c6ff77b125809fe6abd5a1d595182e012eca47e89d5300472e9c98ada223bdcd130953d74a9
|
7
|
+
data.tar.gz: 9bd342b49bb3d9e39f5da97098abd1b6e6282b34890a75e2c1ebeffcaadea1c29bc10c8a7d2727d3acc62f65bcb01afc3b398e5571e37b2cd69ed9a424edb31d
|
data/Gemfile
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
gem '
|
6
|
-
gem 'open4'
|
7
|
-
gem 'nokogiri'
|
3
|
+
gem 'activesupport', '~> 4.0'
|
4
|
+
gem 'open4', '~> 1.3'
|
5
|
+
gem 'nokogiri', '~> 1.5'
|
8
6
|
|
9
|
-
# Add dependencies to develop your gem here.
|
10
|
-
# Include everything needed to run rake, tests, features, etc.
|
11
7
|
group :development do
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
8
|
+
gem 'rake', '10.1'
|
9
|
+
gem 'pry'
|
10
|
+
gem 'bundler', '~> 1.0'
|
11
|
+
gem 'jeweler', '~> 1.8'
|
15
12
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,77 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (
|
5
|
-
|
4
|
+
activesupport (4.0.0)
|
5
|
+
i18n (~> 0.6, >= 0.6.4)
|
6
|
+
minitest (~> 4.2)
|
7
|
+
multi_json (~> 1.3)
|
8
|
+
thread_safe (~> 0.1)
|
9
|
+
tzinfo (~> 0.3.37)
|
10
|
+
addressable (2.3.5)
|
11
|
+
atomic (1.1.10)
|
12
|
+
builder (3.2.2)
|
13
|
+
coderay (1.0.9)
|
14
|
+
faraday (0.8.7)
|
15
|
+
multipart-post (~> 1.1)
|
6
16
|
git (1.2.5)
|
7
|
-
|
17
|
+
github_api (0.10.1)
|
18
|
+
addressable
|
19
|
+
faraday (~> 0.8.1)
|
20
|
+
hashie (>= 1.2)
|
21
|
+
multi_json (~> 1.4)
|
22
|
+
nokogiri (~> 1.5.2)
|
23
|
+
oauth2
|
24
|
+
hashie (2.0.5)
|
25
|
+
highline (1.6.19)
|
26
|
+
httpauth (0.2.0)
|
27
|
+
i18n (0.6.4)
|
28
|
+
jeweler (1.8.6)
|
29
|
+
builder
|
8
30
|
bundler (~> 1.0)
|
9
31
|
git (>= 1.2.5)
|
32
|
+
github_api (= 0.10.1)
|
33
|
+
highline (>= 1.6.15)
|
34
|
+
nokogiri (= 1.5.10)
|
10
35
|
rake
|
11
|
-
|
12
|
-
|
36
|
+
rdoc
|
37
|
+
json (1.8.0)
|
38
|
+
jwt (0.1.8)
|
39
|
+
multi_json (>= 1.5)
|
40
|
+
method_source (0.8.1)
|
41
|
+
minitest (4.7.5)
|
42
|
+
multi_json (1.7.7)
|
43
|
+
multi_xml (0.5.4)
|
44
|
+
multipart-post (1.2.0)
|
45
|
+
nokogiri (1.5.10)
|
46
|
+
oauth2 (0.9.2)
|
47
|
+
faraday (~> 0.8)
|
48
|
+
httpauth (~> 0.2)
|
49
|
+
jwt (~> 0.1.4)
|
50
|
+
multi_json (~> 1.0)
|
51
|
+
multi_xml (~> 0.5)
|
52
|
+
rack (~> 1.2)
|
13
53
|
open4 (1.3.0)
|
14
|
-
|
54
|
+
pry (0.9.12.2)
|
55
|
+
coderay (~> 1.0.5)
|
56
|
+
method_source (~> 0.8)
|
57
|
+
slop (~> 3.4)
|
58
|
+
rack (1.5.2)
|
59
|
+
rake (10.1.0)
|
60
|
+
rdoc (4.0.1)
|
61
|
+
json (~> 1.4)
|
62
|
+
slop (3.4.5)
|
63
|
+
thread_safe (0.1.0)
|
64
|
+
atomic
|
65
|
+
tzinfo (0.3.37)
|
15
66
|
|
16
67
|
PLATFORMS
|
17
68
|
ruby
|
18
69
|
|
19
70
|
DEPENDENCIES
|
20
|
-
activesupport
|
21
|
-
bundler (~> 1.0
|
22
|
-
jeweler (~> 1.
|
23
|
-
nokogiri
|
24
|
-
open4
|
25
|
-
|
71
|
+
activesupport (~> 4.0)
|
72
|
+
bundler (~> 1.0)
|
73
|
+
jeweler (~> 1.8)
|
74
|
+
nokogiri (~> 1.5)
|
75
|
+
open4 (~> 1.3)
|
76
|
+
pry
|
77
|
+
rake (= 10.1)
|
data/README.md
CHANGED
@@ -63,6 +63,10 @@ See `manbook --help` to view the options at any time.
|
|
63
63
|
mktoc ./my-favorite-pages/
|
64
64
|
mktoc --title "Kindle and the Fourty Amazons" ./my-favorite-pages/
|
65
65
|
|
66
|
+
## EXIT STATUS
|
67
|
+
|
68
|
+
The `manbook` command returns with exit code other than 0 (zero) if one or more man pages could not be found or converted. If all goes well, the exit code will be 0.
|
69
|
+
|
66
70
|
# HISTORY #
|
67
71
|
After I bought a Kindle, the idea was born to put the man pages of my Mac onto my Kindle. My requirements are:
|
68
72
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
3
|
require 'bundler'
|
5
4
|
begin
|
6
5
|
Bundler.setup(:default, :development)
|
@@ -35,7 +34,7 @@ end
|
|
35
34
|
|
36
35
|
task :default => :test
|
37
36
|
|
38
|
-
require '
|
37
|
+
require 'rdoc/task'
|
39
38
|
Rake::RDocTask.new do |rdoc|
|
40
39
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
40
|
|
data/TODO
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
* Do not overwrite existing files unless --force was given
|
2
|
-
*
|
2
|
+
* Prevent the cover image attribution in about.html if no or a custom cover is used
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/bin/manbook
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
4
|
|
5
|
-
require 'rubygems'
|
6
|
-
|
7
5
|
help = <<HELP
|
8
6
|
The manbook command can be used to produce an eBook from one or more man pages.
|
9
7
|
|
@@ -65,6 +63,8 @@ opts = OptionParser.new do |opts|
|
|
65
63
|
end
|
66
64
|
end
|
67
65
|
|
66
|
+
error_count = 0
|
67
|
+
|
68
68
|
begin
|
69
69
|
opts.parse!
|
70
70
|
|
@@ -79,6 +79,7 @@ begin
|
|
79
79
|
rescue ManBook::ManPageNotFoundError => e
|
80
80
|
ManBook.logger.error e.message
|
81
81
|
ManBook.logger.debug "Backtrace:\n#{e.backtrace.join("\n")}"
|
82
|
+
error_count += 1
|
82
83
|
end
|
83
84
|
}
|
84
85
|
rescue
|
@@ -87,3 +88,5 @@ rescue
|
|
87
88
|
ManBook.logger.info usage
|
88
89
|
exit(1)
|
89
90
|
end
|
91
|
+
|
92
|
+
exit error_count
|
data/bin/mktoc
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
4
|
|
5
|
-
require 'rubygems'
|
6
|
-
|
7
5
|
help = <<HELP
|
8
6
|
Creates table of contents (TOC) files for all HTML files in a directory. This
|
9
7
|
tool was built to prepare HTML pages for the Kindle.
|
@@ -25,6 +23,7 @@ end
|
|
25
23
|
require 'optparse'
|
26
24
|
require 'manbook'
|
27
25
|
require 'erb'
|
26
|
+
require 'fileutils'
|
28
27
|
|
29
28
|
INDEX_HTML = 'index.html'
|
30
29
|
ABOUT_HTML = 'about.html'
|
@@ -36,6 +35,7 @@ GENERATOR = "#{File.basename(__FILE__)} v#{ManBook::VERSION}"
|
|
36
35
|
# defaults
|
37
36
|
@book_title = ManBook::TITLE_DEFAULT
|
38
37
|
@cover_image = ManBook::COVER_IMAGE_DEFAULT
|
38
|
+
@book_author = ManBook::AUTHOR_DEFAULT
|
39
39
|
|
40
40
|
opts = OptionParser.new do |opts|
|
41
41
|
opts.banner = help
|
@@ -62,6 +62,11 @@ opts = OptionParser.new do |opts|
|
|
62
62
|
@book_title = title
|
63
63
|
end
|
64
64
|
|
65
|
+
opts.on("--author STRING", "Use AUTHOR as book author") do |author|
|
66
|
+
ManBook.logger.info "Setting book author to '#{author}'"
|
67
|
+
@book_author = author
|
68
|
+
end
|
69
|
+
|
65
70
|
opts.on("--cover-image FILE", "Reference a cover image") do |cover_image|
|
66
71
|
ManBook.logger.info "Cover image set to #{cover_image}"
|
67
72
|
@cover_image = cover_image
|
@@ -73,7 +78,7 @@ opts = OptionParser.new do |opts|
|
|
73
78
|
end
|
74
79
|
|
75
80
|
def render(template, my_binding = binding)
|
76
|
-
ERB.new(File.new(File.join(File.dirname(__FILE__), '..', 'templates', template)), 0, "%<>").result(my_binding)
|
81
|
+
ERB.new(File.new(File.join(File.dirname(__FILE__), '..', 'templates', template)).read, 0, "%<>").result(my_binding)
|
77
82
|
end
|
78
83
|
|
79
84
|
begin
|
data/lib/manbook.rb
CHANGED
@@ -2,7 +2,6 @@ $:.unshift File.dirname(__FILE__)
|
|
2
2
|
|
3
3
|
require 'bundler/setup'
|
4
4
|
require 'logger'
|
5
|
-
require 'active_support/core_ext/logger'
|
6
5
|
require 'active_support/core_ext/object/blank'
|
7
6
|
require 'active_support/core_ext/module/attribute_accessors'
|
8
7
|
require 'open4'
|
@@ -16,8 +15,9 @@ require 'manbook/errors'
|
|
16
15
|
require 'manbook/log_formatter'
|
17
16
|
|
18
17
|
module ManBook
|
19
|
-
VERSION = File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION]))
|
18
|
+
VERSION = File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION])).chomp
|
20
19
|
TITLE_DEFAULT = "ManBook - a book of selected man pages"
|
20
|
+
AUTHOR_DEFAULT = "Multiple Authors"
|
21
21
|
COVER_IMAGE_DEFAULT = File.join(File.dirname(__FILE__), '..', 'templates', 'library_books.jpg')
|
22
22
|
|
23
23
|
mattr_accessor :logger
|
data/manbook.gemspec
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "manbook"
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Nicholas E. Rabenau"]
|
12
|
+
s.date = "2013-07-22"
|
13
|
+
s.description = "The manbook command can be used to produce an eBook from one or more man pages."
|
14
|
+
s.email = "nerab@gmx.net"
|
15
|
+
s.executables = ["manbook", "mktoc", "manbook"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.md",
|
19
|
+
"TODO"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"TODO",
|
29
|
+
"VERSION",
|
30
|
+
"bin/manbook",
|
31
|
+
"bin/mktoc",
|
32
|
+
"lib/manbook.rb",
|
33
|
+
"lib/manbook/errors.rb",
|
34
|
+
"lib/manbook/formatter.rb",
|
35
|
+
"lib/manbook/html_formatter.rb",
|
36
|
+
"lib/manbook/log_formatter.rb",
|
37
|
+
"lib/manbook/parser.rb",
|
38
|
+
"manbook.gemspec",
|
39
|
+
"templates/_page.html.erb",
|
40
|
+
"templates/about.html.erb",
|
41
|
+
"templates/application.html.erb",
|
42
|
+
"templates/index.html.erb",
|
43
|
+
"templates/library_books.jpg",
|
44
|
+
"templates/manbook.ncx.erb",
|
45
|
+
"templates/manbook.opf.erb",
|
46
|
+
"test/fixtures/alt-cover.jpg",
|
47
|
+
"test/fixtures/bash.html",
|
48
|
+
"test/fixtures/cat.html",
|
49
|
+
"test/fixtures/git.html",
|
50
|
+
"test/fixtures/gunzip.html",
|
51
|
+
"test/fixtures/less.html",
|
52
|
+
"test/fixtures/ls.html",
|
53
|
+
"test/fixtures/man.html",
|
54
|
+
"test/helper.rb",
|
55
|
+
"test/unit/test_manbook.rb",
|
56
|
+
"test/unit/test_mktoc.rb"
|
57
|
+
]
|
58
|
+
s.homepage = "http://github.com/nerab/manbook"
|
59
|
+
s.licenses = ["MIT"]
|
60
|
+
s.require_paths = ["lib"]
|
61
|
+
s.rubygems_version = "2.0.3"
|
62
|
+
s.summary = "Produces an eBook from man pages"
|
63
|
+
|
64
|
+
if s.respond_to? :specification_version then
|
65
|
+
s.specification_version = 4
|
66
|
+
|
67
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
|
+
s.add_runtime_dependency(%q<activesupport>, ["~> 4.0"])
|
69
|
+
s.add_runtime_dependency(%q<open4>, ["~> 1.3"])
|
70
|
+
s.add_runtime_dependency(%q<nokogiri>, ["~> 1.5"])
|
71
|
+
s.add_development_dependency(%q<rake>, ["= 10.1"])
|
72
|
+
s.add_development_dependency(%q<pry>, [">= 0"])
|
73
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
74
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
|
75
|
+
else
|
76
|
+
s.add_dependency(%q<activesupport>, ["~> 4.0"])
|
77
|
+
s.add_dependency(%q<open4>, ["~> 1.3"])
|
78
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.5"])
|
79
|
+
s.add_dependency(%q<rake>, ["= 10.1"])
|
80
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
81
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
82
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
83
|
+
end
|
84
|
+
else
|
85
|
+
s.add_dependency(%q<activesupport>, ["~> 4.0"])
|
86
|
+
s.add_dependency(%q<open4>, ["~> 1.3"])
|
87
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.5"])
|
88
|
+
s.add_dependency(%q<rake>, ["= 10.1"])
|
89
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
90
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
91
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
data/templates/about.html.erb
CHANGED
@@ -3,4 +3,3 @@
|
|
3
3
|
<p>This book was created using the <a href='http://github.com/nerab/manbook'><%= GENERATOR %></a> tool.</p>
|
4
4
|
|
5
5
|
<p>The cover image was published by CCAC North Library under CC BY 2.0. It can be found at <a href='http://www.flickr.com/photos/ccacnorthlib/4131076795/'>flickr</a>.</p>
|
6
|
-
|
data/templates/manbook.opf.erb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<dc:title><%= @book_title %></dc:title>
|
5
5
|
<dc:language>en</dc:language>
|
6
6
|
<dc:identifier id="uid"><%= @book_title %></dc:identifier>
|
7
|
-
<dc:creator opf:role="aut"
|
7
|
+
<dc:creator opf:role="aut"><%= @book_author %></dc:creator>
|
8
8
|
<dc:generator><%= GENERATOR %></dc:generator>
|
9
9
|
<% unless @cover_image.nil? %>
|
10
10
|
<meta name="cover" content="cover-image"/>
|
Binary file
|
data/test/helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'bundler'
|
3
2
|
require 'tmpdir'
|
4
3
|
require 'fileutils'
|
4
|
+
require 'active_support/core_ext/string'
|
5
5
|
|
6
6
|
begin
|
7
7
|
Bundler.setup(:default, :development)
|
@@ -26,11 +26,15 @@ module ManBookTest
|
|
26
26
|
attr_reader :output_dir
|
27
27
|
|
28
28
|
def setup
|
29
|
-
@output_dir = Dir.mktmpdir(
|
29
|
+
@output_dir = Dir.mktmpdir(__name__)
|
30
30
|
end
|
31
31
|
|
32
32
|
def teardown
|
33
|
-
|
33
|
+
if passed?
|
34
|
+
FileUtils.remove_entry_secure(@output_dir)
|
35
|
+
else
|
36
|
+
STDERR.puts " => Check #{@output_dir} for workproducts"
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
40
|
# solves the problem of non-existing test cases
|
data/test/unit/test_manbook.rb
CHANGED
@@ -31,6 +31,35 @@ module ManBookTest
|
|
31
31
|
assert_equal(0, status.exitstatus)
|
32
32
|
end
|
33
33
|
|
34
|
+
def test_nonexisting_page_single
|
35
|
+
status = Open4::popen4("#{app_script} foobar"){|pid, stdin, stdout, stderr|
|
36
|
+
assert_match(/ERROR: No manual entry for foobar/, stderr.read)
|
37
|
+
assert(stdout.read.empty?)
|
38
|
+
}
|
39
|
+
assert_not_equal(0, status.exitstatus)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_existing_and_nonexisting_pages
|
43
|
+
status = Open4::popen4("#{app_script} ls deadbeef"){|pid, stdin, stdout, stderr|
|
44
|
+
assert_match(/ERROR: No manual entry for deadbeef/, stderr.read)
|
45
|
+
assert(stdout.read.empty?)
|
46
|
+
}
|
47
|
+
assert_not_equal(0, status.exitstatus)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_nonexisting_page_multiple
|
51
|
+
pages = %w[foobar deadbeef]
|
52
|
+
status = Open4::popen4("#{app_script} #{pages.join(' ')}"){|pid, stdin, stdout, stderr|
|
53
|
+
catched_messages = pages.size
|
54
|
+
stderr.read.each_line{|line|
|
55
|
+
catched_messages -= 1 if /ERROR: No manual entry for .*/ =~ line
|
56
|
+
}
|
57
|
+
assert_equal(0, catched_messages)
|
58
|
+
assert(stdout.read.empty?)
|
59
|
+
}
|
60
|
+
assert_not_equal(0, status.exitstatus)
|
61
|
+
end
|
62
|
+
|
34
63
|
private
|
35
64
|
def app_script
|
36
65
|
"#{APP_SCRIPT} --output #{output_dir}"
|
data/test/unit/test_mktoc.rb
CHANGED
@@ -11,7 +11,7 @@ module ManBookTest
|
|
11
11
|
#
|
12
12
|
# command under test
|
13
13
|
#
|
14
|
-
APP_SCRIPT = '
|
14
|
+
APP_SCRIPT = 'bin/mktoc'
|
15
15
|
|
16
16
|
#
|
17
17
|
# generator identification
|
@@ -35,10 +35,13 @@ module ManBookTest
|
|
35
35
|
:about => 'test_workproduct_about',
|
36
36
|
:cover => 'test_workproduct_cover'}
|
37
37
|
|
38
|
+
COVER_IMAGE_ALT = File.join(FIXTURES_DIR, 'alt-cover.jpg')
|
39
|
+
|
38
40
|
def setup
|
39
41
|
super
|
40
|
-
|
41
|
-
|
42
|
+
fixtures = Dir.glob(File.join(FIXTURES_DIR, '*.html'))
|
43
|
+
FileUtils.cp_r(fixtures, output_dir)
|
44
|
+
@fixtures = fixtures.map{|f| File.basename(f)}
|
42
45
|
end
|
43
46
|
|
44
47
|
def test_no_args
|
@@ -47,25 +50,38 @@ module ManBookTest
|
|
47
50
|
|
48
51
|
def test_defaults
|
49
52
|
assert_exec("#{app_script} #{output_dir}")
|
50
|
-
test_all_workproducts(ManBook::TITLE_DEFAULT, File.basename(ManBook::COVER_IMAGE_DEFAULT))
|
53
|
+
test_all_workproducts(ManBook::TITLE_DEFAULT, ManBook::AUTHOR_DEFAULT, File.basename(ManBook::COVER_IMAGE_DEFAULT))
|
51
54
|
end
|
52
55
|
|
53
56
|
def test_overridden_title
|
54
57
|
title = "Foo42Bar"
|
55
58
|
assert_exec("#{app_script} #{output_dir} --title \"#{title}\"")
|
56
|
-
test_all_workproducts(title, File.basename(ManBook::COVER_IMAGE_DEFAULT))
|
59
|
+
test_all_workproducts(title, ManBook::AUTHOR_DEFAULT, File.basename(ManBook::COVER_IMAGE_DEFAULT))
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_overridden_author
|
63
|
+
author = "James Born"
|
64
|
+
assert_exec("#{app_script} #{output_dir} --author \"#{author}\"")
|
65
|
+
test_all_workproducts(ManBook::TITLE_DEFAULT, author, File.basename(ManBook::COVER_IMAGE_DEFAULT))
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_overridden_title_and_author
|
69
|
+
title = "Foo42Bar42"
|
70
|
+
author = "James F. Born"
|
71
|
+
assert_exec("#{app_script} #{output_dir} --title \"#{title}\" --author \"#{author}\"")
|
72
|
+
test_all_workproducts(title, author, File.basename(ManBook::COVER_IMAGE_DEFAULT))
|
57
73
|
end
|
58
74
|
|
59
75
|
def test_no_cover_image
|
60
76
|
assert_exec("#{app_script} #{output_dir} --no-cover-image")
|
61
|
-
test_all_workproducts(ManBook::TITLE_DEFAULT, nil)
|
77
|
+
test_all_workproducts(ManBook::TITLE_DEFAULT, ManBook::AUTHOR_DEFAULT, nil)
|
62
78
|
end
|
63
79
|
|
64
80
|
def test_alt_cover_image
|
65
|
-
cover_image =
|
81
|
+
cover_image = COVER_IMAGE_ALT
|
66
82
|
assert(File.exist?(cover_image))
|
67
83
|
assert_exec("#{app_script} #{output_dir} --cover-image #{cover_image}")
|
68
|
-
test_all_workproducts(ManBook::TITLE_DEFAULT, File.basename(cover_image))
|
84
|
+
test_all_workproducts(ManBook::TITLE_DEFAULT, ManBook::AUTHOR_DEFAULT, File.basename(cover_image))
|
69
85
|
end
|
70
86
|
|
71
87
|
def test_alt_cover_image_not_found
|
@@ -75,14 +91,16 @@ module ManBookTest
|
|
75
91
|
end
|
76
92
|
|
77
93
|
private
|
78
|
-
def test_all_workproducts(title, cover_image = nil)
|
94
|
+
def test_all_workproducts(title, author, cover_image = nil)
|
79
95
|
if cover_image.nil?
|
80
96
|
workproducts = WORKPRODUCTS
|
81
97
|
else
|
82
|
-
workproducts = WORKPRODUCTS.merge({:cover =>
|
98
|
+
workproducts = WORKPRODUCTS.merge({:cover => cover_image})
|
83
99
|
end
|
84
100
|
|
85
|
-
|
101
|
+
expected = @fixtures + workproducts.values
|
102
|
+
actual = Dir.glob(File.join(output_dir, '*')).map{|f| File.basename(f)}
|
103
|
+
assert_equal((expected - actual), (actual - expected))
|
86
104
|
|
87
105
|
workproducts.each{|k,v|
|
88
106
|
vf = File.join(output_dir, v)
|
@@ -91,7 +109,7 @@ module ManBookTest
|
|
91
109
|
# dispatch to test that is specific to the work product
|
92
110
|
wp_test = WORK_PRODUCT_TESTS[k]
|
93
111
|
raise "No test defined for work product #{k}" if wp_test.nil?
|
94
|
-
send(wp_test, title, cover_image)
|
112
|
+
send(wp_test, title, author, cover_image)
|
95
113
|
}
|
96
114
|
end
|
97
115
|
|
@@ -125,7 +143,7 @@ module ManBookTest
|
|
125
143
|
"#{APP_SCRIPT}"
|
126
144
|
end
|
127
145
|
|
128
|
-
def test_workproduct_html(title, cover_image = nil)
|
146
|
+
def test_workproduct_html(title, author, cover_image = nil)
|
129
147
|
doc = Nokogiri::HTML(File.read(File.join(output_dir, 'index.html')))
|
130
148
|
assert_workproduct(['about.html'].concat(@fixtures), doc, '/html/body/ul/li', 'a/@href')
|
131
149
|
|
@@ -137,7 +155,7 @@ module ManBookTest
|
|
137
155
|
assert_equal("About this book", doc.xpath('/html/body/ul/li[1]/a/text()').to_s)
|
138
156
|
end
|
139
157
|
|
140
|
-
def test_workproduct_ncx(title, cover_image = nil)
|
158
|
+
def test_workproduct_ncx(title, author, cover_image = nil)
|
141
159
|
doc = Nokogiri::XML(File.read(File.join(output_dir, 'index.ncx')))
|
142
160
|
|
143
161
|
fixtures = ['about.html'].concat(@fixtures)
|
@@ -154,7 +172,7 @@ module ManBookTest
|
|
154
172
|
# @playOrder="0"
|
155
173
|
end
|
156
174
|
|
157
|
-
def test_workproduct_opf(title, cover_image = nil)
|
175
|
+
def test_workproduct_opf(title, author, cover_image = nil)
|
158
176
|
doc = Nokogiri::XML(File.read(File.join(output_dir, 'index.opf')))
|
159
177
|
|
160
178
|
# the opf must include links to index.html and index.ncx
|
@@ -181,11 +199,11 @@ module ManBookTest
|
|
181
199
|
end
|
182
200
|
end
|
183
201
|
|
184
|
-
def test_workproduct_about(title, cover_image = nil)
|
202
|
+
def test_workproduct_about(title, author, cover_image = nil)
|
185
203
|
# no further tests
|
186
204
|
end
|
187
205
|
|
188
|
-
def test_workproduct_cover(title, cover_image = nil)
|
206
|
+
def test_workproduct_cover(title, author, cover_image = nil)
|
189
207
|
# no further tests
|
190
208
|
end
|
191
209
|
|
metadata
CHANGED
@@ -1,124 +1,125 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: manbook
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Nicholas E. Rabenau
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-07-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: activesupport
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
hash: 3
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
31
20
|
type: :runtime
|
32
|
-
requirement: *id001
|
33
21
|
prerelease: false
|
34
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
35
28
|
name: open4
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
hash: 3
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
version: "0"
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
45
34
|
type: :runtime
|
46
|
-
requirement: *id002
|
47
35
|
prerelease: false
|
48
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
49
42
|
name: nokogiri
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
hash: 3
|
56
|
-
segments:
|
57
|
-
- 0
|
58
|
-
version: "0"
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
59
48
|
type: :runtime
|
60
|
-
requirement: *id003
|
61
49
|
prerelease: false
|
62
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
63
56
|
name: rake
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
hash: 49
|
70
|
-
segments:
|
71
|
-
- 0
|
72
|
-
- 8
|
73
|
-
- 7
|
74
|
-
version: 0.8.7
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.1'
|
75
62
|
type: :development
|
76
|
-
requirement: *id004
|
77
63
|
prerelease: false
|
78
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
79
84
|
name: bundler
|
80
|
-
|
81
|
-
|
82
|
-
requirements:
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
83
87
|
- - ~>
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
segments:
|
87
|
-
- 1
|
88
|
-
- 0
|
89
|
-
- 0
|
90
|
-
version: 1.0.0
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
91
90
|
type: :development
|
92
|
-
requirement: *id005
|
93
91
|
prerelease: false
|
94
|
-
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
95
98
|
name: jeweler
|
96
|
-
|
97
|
-
|
98
|
-
requirements:
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
99
101
|
- - ~>
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
segments:
|
103
|
-
- 1
|
104
|
-
- 6
|
105
|
-
- 4
|
106
|
-
version: 1.6.4
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.8'
|
107
104
|
type: :development
|
108
|
-
requirement: *id006
|
109
105
|
prerelease: false
|
110
|
-
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.8'
|
111
|
+
description: The manbook command can be used to produce an eBook from one or more
|
112
|
+
man pages.
|
111
113
|
email: nerab@gmx.net
|
112
|
-
executables:
|
113
|
-
- mktoc
|
114
|
+
executables:
|
114
115
|
- manbook
|
116
|
+
- mktoc
|
115
117
|
extensions: []
|
116
|
-
|
117
|
-
extra_rdoc_files:
|
118
|
+
extra_rdoc_files:
|
118
119
|
- LICENSE.txt
|
119
120
|
- README.md
|
120
121
|
- TODO
|
121
|
-
files:
|
122
|
+
files:
|
122
123
|
- .document
|
123
124
|
- Gemfile
|
124
125
|
- Gemfile.lock
|
@@ -135,6 +136,7 @@ files:
|
|
135
136
|
- lib/manbook/html_formatter.rb
|
136
137
|
- lib/manbook/log_formatter.rb
|
137
138
|
- lib/manbook/parser.rb
|
139
|
+
- manbook.gemspec
|
138
140
|
- templates/_page.html.erb
|
139
141
|
- templates/about.html.erb
|
140
142
|
- templates/application.html.erb
|
@@ -142,6 +144,7 @@ files:
|
|
142
144
|
- templates/library_books.jpg
|
143
145
|
- templates/manbook.ncx.erb
|
144
146
|
- templates/manbook.opf.erb
|
147
|
+
- test/fixtures/alt-cover.jpg
|
145
148
|
- test/fixtures/bash.html
|
146
149
|
- test/fixtures/cat.html
|
147
150
|
- test/fixtures/git.html
|
@@ -153,37 +156,27 @@ files:
|
|
153
156
|
- test/unit/test_manbook.rb
|
154
157
|
- test/unit/test_mktoc.rb
|
155
158
|
homepage: http://github.com/nerab/manbook
|
156
|
-
licenses:
|
159
|
+
licenses:
|
157
160
|
- MIT
|
161
|
+
metadata: {}
|
158
162
|
post_install_message:
|
159
163
|
rdoc_options: []
|
160
|
-
|
161
|
-
require_paths:
|
164
|
+
require_paths:
|
162
165
|
- lib
|
163
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
none: false
|
174
|
-
requirements:
|
175
|
-
- - ">="
|
176
|
-
- !ruby/object:Gem::Version
|
177
|
-
hash: 3
|
178
|
-
segments:
|
179
|
-
- 0
|
180
|
-
version: "0"
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - '>='
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - '>='
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
181
176
|
requirements: []
|
182
|
-
|
183
177
|
rubyforge_project:
|
184
|
-
rubygems_version:
|
178
|
+
rubygems_version: 2.0.3
|
185
179
|
signing_key:
|
186
|
-
specification_version:
|
180
|
+
specification_version: 4
|
187
181
|
summary: Produces an eBook from man pages
|
188
182
|
test_files: []
|
189
|
-
|