Class: Verkilo::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/verkilo/cli.rb

Instance Method Summary collapse

Instance Method Details

#compileObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/verkilo/cli.rb', line 17

def compile
  is_verkilo_project!
  shelf  = Verkilo::Shelf.new(root_dir)
  say "Compiling #{shelf}"
  shelf.books.each do |book|
    fork do
      book.compile
    end
  end
  Process.waitall
end

#mergeObject



31
32
33
34
# File 'lib/verkilo/cli.rb', line 31

def merge
  is_verkilo_project!
  say "Merging #{root_dir}"
end

#versionObject



76
77
78
# File 'lib/verkilo/cli.rb', line 76

def version
  say "Verkilo v#{Verkilo::VERSION}"
end

#wordcountObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/verkilo/cli.rb', line 59

def wordcount
  is_verkilo_project!
  log = options["log"] || false
  offset = options["offset"] || nil
  delta = options["delta"] || false
  shelf  = Verkilo::Shelf.new(root_dir)
  say "Wordcount for #{shelf}: #{shelf.wordcount.to_yaml}"
  if log
    wc_log = Verkilo::Log.new('wordcount',root_dir, offset)
    wc_log.data = shelf.wordcount
    wc_log.delta! unless delta.nil?
    wc_log.write
    say "Written to #{wc_log.filename}"
  end
end