Class: Bookbinder::Commands::Generate
- Inherits:
-
Object
- Object
- Bookbinder::Commands::Generate
- Includes:
- Naming
- Defined in:
- lib/bookbinder/commands/generate.rb
Instance Method Summary collapse
- #command_for?(name) ⇒ Boolean
-
#initialize(fs, sheller, context_dir, streams) ⇒ Generate
constructor
A new instance of Generate.
- #run(name) ⇒ Object
- #usage ⇒ Object
Methods included from Naming
Constructor Details
#initialize(fs, sheller, context_dir, streams) ⇒ Generate
Returns a new instance of Generate.
8 9 10 11 12 13 |
# File 'lib/bookbinder/commands/generate.rb', line 8 def initialize(fs, sheller, context_dir, streams) @fs = fs @sheller = sheller @context_dir = context_dir @streams = streams end |
Instance Method Details
#command_for?(name) ⇒ Boolean
15 16 17 |
# File 'lib/bookbinder/commands/generate.rb', line 15 def command_for?(name) name == 'generate' end |
#run(name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bookbinder/commands/generate.rb', line 24 def run((name)) 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).success? streams[:success].puts "Successfully generated book at #{path}" 0 else 1 end end |
#usage ⇒ Object
19 20 21 22 |
# File 'lib/bookbinder/commands/generate.rb', line 19 def usage ["generate <book-name>", "Generate a skeleton book that can be bound with 'bookbinder bind'"] end |