Class: Bookwatch::Commands::Generate

Inherits:
Object
  • Object
show all
Defined in:
lib/bookwatch/commands/generate.rb

Instance Method Summary collapse

Constructor Details

#initialize(fs, sheller, context_dir, streams) ⇒ Generate

Returns a new instance of Generate.



6
7
8
9
10
11
# File 'lib/bookwatch/commands/generate.rb', line 6

def initialize(fs, sheller, context_dir, streams)
  @fs = fs
  @sheller = sheller
  @context_dir = context_dir
  @streams = streams
end

Instance Method Details

#run(name, special_bookwatch_gem_args = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bookwatch/commands/generate.rb', line 13

def run(name, special_bookwatch_gem_args={})
  path = context_dir.join(name)
  streams[:out].puts "Generating book at #{path}..."
  if fs.file_exist?(path)
    streams[:err].puts "Cannot generate book: directory already exists"
    1
  elsif install(path, special_bookwatch_gem_args).success?
    streams[:success].puts "Successfully generated book at #{path}"
    0
  else
    1
  end
end