-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheb_epub
73 lines (60 loc) · 2.24 KB
/
heb_epub
1
2
3
4
5
6
7
8
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'optparse'
require 'ostruct'
# Process the script parameters.
options = OpenStruct.new
options.layout = "fixepub"
option_parser = OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename(__FILE__)} [-l fixepub|flowepub] [task] [hebdir]"
opts.on('-l', '--layout [fixepub|flowepub]', 'EPUB Layout') do |layout|
raise "Invalid layout #{layout}" unless ["fixepub", "flowepub"].include?(layout)
options.layout = layout
end
opts.on_tail('-h', '--help', 'Print this help message') do
puts opts
exit 0
end
end
option_parser.parse!(ARGV)
# Determine the root directory of the code base.
script_dir = File.expand_path(File.dirname(__FILE__))
root_dir = File.dirname(script_dir)
require_relative File.join(root_dir, 'config', 'application')
require 'rake'
task = ARGV[0]
if task == nil or task.strip.empty?
task = "bundle"
end
if task != "clobber"
task = "winterberry:" + task
end
heb_dir_list = ARGV.count > 1 ? ARGV[1..-1] : [ Dir.pwd ]
# Set JAVA_HOME as Java is used for XSLT 2.0 transformations.
# Explicitly set for my laptop (Windows) or tang (Linux).
if Gem.win_platform?
java_home = File.join(ENV['SYSTEMDRIVE'], "Program Files", "Java", "jre1.8.0_172")
#hebrootdir = File.expand_path(File.join("~", "Documents", "winterberry_hebepub"))
hebrootdir = File.expand_path(File.join("~", "Documents", "hebproduction"))
else
java_home = File.join(File::SEPARATOR, "usr", "lib", "jvm", "java-8-openjdk-amd64")
hebrootdir = File.join(File::SEPARATOR, "quod-prep", "prep", "a", "acls", "hebepub")
end
ENV['JAVA_HOME'] = java_home
ENV['HEBROOTDIR'] = hebrootdir
ENV['PATH'] = File.join(java_home, "bin") + Gem.path_separator + ENV['PATH']
ENV['LAYOUT'] = options.layout
Rails.application.load_tasks
# Traversing a list, but currently this only works for the first item.
heb_dir_list.each do |heb_dir|
heb_dir = File.expand_path(heb_dir)
puts File.basename(heb_dir)
STDOUT.flush
ENV['HEBDIR'] = File.expand_path(heb_dir)
Dir.glob(File.join(root_dir, "lib", "hebdevel", "tasks", "*.rake")).each do |r|
Rake.load_rakefile r
end
#Rake.load_rakefile File.join(root_dir, "lib", "hebdevel", "tasks", "hebdevel.rake")
Rake::Task[task].invoke
Rake::Task[task].reenable
end