Class: BitClust::Subcommands::EPUBCommand

Inherits:
BitClust::Subcommand show all
Defined in:
lib/bitclust/subcommands/epub_command.rb

Instance Method Summary collapse

Methods inherited from BitClust::Subcommand

#align_progress_bar_title, #error, #help, #option_error, #parse, #srcdir_root

Constructor Details

#initializeEPUBCommand

Returns a new instance of EPUBCommand.



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
# File 'lib/bitclust/subcommands/epub_command.rb', line 12

def initialize
  super
  @verbose = true
  @catalogdir = nil
  @templatedir = srcdir_root + "data/bitclust/template.epub"
  @themedir = srcdir_root + "theme/default"
  @filename = "rurema-#{Date.today}.epub"
  @keep = false
  @parser.banner = "Usage: #{File.basename($0, '.*')} epub [options]"
  @parser.on('-o', '--outputdir=PATH', 'Output directory') do |path|
    begin
      @outputdir = Pathname.new(path).realpath
    rescue Errno::ENOENT
      FileUtils.mkdir_p(path, :verbose => @verbose)
      retry
    end
  end
  @parser.on('-f', '--filename=FILENAME',
             "Filename of generated EPUB file [#{@filename}]") do |filename|
    @filename = filename
  end
  @parser.on('--[no-]keep', 'Keep all generated files (for debug) [false]') do |keep|
    @keep = keep
  end
  @parser.on('--catalog=PATH', 'Catalog directory') do |path|
    @catalogdir = Pathname.new(path).realpath
  end
  @parser.on('--templatedir=PATH', 'Template directory') do |path|
    @templatedir = Pathname.new(path).realpath
  end
  @parser.on('--themedir=PATH', 'Theme directory') do |path|
    @themedir = Pathname.new(path).realpath
  end
  @parser.on('--fs-casesensitive', 'Filesystem is case-sensitive') do
    @fs_casesensitive = true
  end
  @parser.on('--[no-]quiet', 'Be quiet') do |quiet|
    @verbose = !quiet
  end
end

Instance Method Details

#exec(argv, options) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/bitclust/subcommands/epub_command.rb', line 53

def exec(argv, options)
  generator = BitClust::Generators::EPUB.new(:prefix           => options[:prefix],
                                             :capi             => options[:capi],
                                             :outputdir        => @outputdir,
                                             :catalog          => @catalog,
                                             :templatedir      => @templatedir,
                                             :themedir         => @themedir,
                                             :fs_casesensitive => @fs_casesensitive,
                                             :verbose          => @verbose,
                                             :keep             => @keep,
                                             :filename         => @filename)
  generator.generate
end