Module: Softcover::Commands::Check
- Extended by:
- Check, Utils
- Included in:
- Check
- Defined in:
- lib/softcover/commands/check.rb
Constant Summary
Constants included
from Utils
Utils::UNITS
Instance Method Summary
collapse
Methods included from Utils
add_highlight_class!, article?, as_size, book_file_lines, chapter_label, commands, current_book, dependency_filename, digest, executable, execute, filename_or_default, first_path, get_filename, html_extension, in_book_directory?, language_labels, linux?, logged_in?, master_content, master_filename, master_latex_header, mkdir, non_comment_lines, os_x?, path, polytexnic_html, raw_lines, reset_current_book!, rm, rm_r, silence, silence_stream, source, template_dir, tmpify, unpublish_slug, write_master_latex_file, write_pygments_file
Instance Method Details
#check_dependencies! ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/softcover/commands/check.rb', line 9
def check_dependencies!
puts "Checking Softcover dependencies..."
simulate_work(1)
missing_dependencies = []
dependencies.each do |label, name|
printf "%-30s", "Checking for #{name}..."
simulate_work(0.15)
if present?(label)
puts "Found"
else
missing_dependencies << label
puts "Missing"
end
simulate_work(0.1)
end
simulate_work(0.25)
if missing_dependencies.empty?
puts "All dependencies satisfied."
else
puts "Missing dependencies:"
missing_dependencies.each do |dependency|
puts " • " + missing_dependency_message(dependency)
end
end
end
|
#dependencies ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/softcover/commands/check.rb', line 35
def dependencies
[[:latex, 'LaTeX'],
[:ghostscript, 'GhostScript'],
[:convert, 'ImageMagick'],
[:node, 'Node.js'],
[:phantomjs, 'PhantomJS'],
[:inkscape, 'Inkscape'],
[:calibre, 'Calibre'],
[:kindlegen, 'KindleGen'],
[:java, 'Java'],
[:zip, 'zip'],
[:epubcheck, 'EpubCheck'],
[:python2, 'Python 2']
]
end
|
#dependency_labels ⇒ Object
51
52
53
|
# File 'lib/softcover/commands/check.rb', line 51
def dependency_labels
dependencies.map(&:first)
end
|
#dependency_names ⇒ Object
55
56
57
|
# File 'lib/softcover/commands/check.rb', line 55
def dependency_names
dependencies.map { |e| e[1] }
end
|
#missing_dependency_message(label) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/softcover/commands/check.rb', line 59
def missing_dependency_message(label)
case label
when :latex
message = "LaTeX (http://latex-project.org/ftp.html)\n"
message += " ∟ Huge download—start it now!"
when :ghostscript
message = "GhostScript (should come with LaTeX)\n"
when :convert
"ImageMagick (https://www.imagemagick.org/script/download.php)"
when :node
"NodeJS (http://nodejs.org/)"
when :phantomjs
message = "PhantomJS (http://phantomjs.org/)\n"
message += " ∟ Put bin/phantomjs version 2 somewhere on your path,"
message += " e.g., in /usr/local/bin"
when :kindlegen
url = 'http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211'
message = "KindleGen (#{url})\n"
message += " ∟ Put the kindlegen executable on your path,"
message += " e.g., in /usr/local/bin"
when :calibre
url = 'http://calibre-ebook.com/'
message = "Calibre (#{url})\n"
message += " ∟ Enable Calibre command-line tools"
message += " (http://manual.calibre-ebook.com/generated/en/cli-index.html)"
when :java
url = 'http://www.java.com/en/download/help/index_installing.xml'
"Java (#{url})"
when :zip
"Install zip (e.g., apt-get install zip)"
when :epubcheck
url = 'https://github.com/IDPF/epubcheck/releases/download/v4.0.2/epubcheck-4.0.2.zip'
message = "EpubCheck 4.0.2 (#{url})\n"
message += " ∟ Unzip and place epubcheck-4.0.2/ in a directory on your path"
when :inkscape
message = "Inkscape (http://inkscape.org/)"
when :python2
message = "Configure your shell so that `python` runs Python 2"
else
raise "Unknown label #{label}"
end
end
|
#present?(label) ⇒ Boolean
102
103
104
|
# File 'lib/softcover/commands/check.rb', line 102
def present?(label)
File.exist?(dependency_filename(label))
end
|
#simulate_work(time) ⇒ Object
Simulate working for given time. ‘softcover check` is more satisfying if it looks like it’s doing work.
108
109
110
111
|
# File 'lib/softcover/commands/check.rb', line 108
def simulate_work(time)
return
sleep time unless Softcover::test?
end
|