Class: Monograph::CLI
- Inherits:
-
Object
- Object
- Monograph::CLI
- Defined in:
- lib/monograph/cli.rb
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
-
#build(destination = nil, source = nil) ⇒ Object
Export a book, assuming we’re in the root of it.
-
#init(path = nil) ⇒ Object
Initialize a new book in the given path.
Instance Method Details
#build(destination = nil, source = nil) ⇒ Object
Export a book, assuming we’re in the root of it
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/monograph/cli.rb', line 17 def build(destination = nil, source = nil) source = Dir.pwd if source.nil? destination = File.join(source, 'build') if destination.nil? raise Error, "You are not currently within a Monograph root" unless File.exist?(File.join(source, 'config.yml')) FileUtils.rm_rf(destination) book = Book.new(source) book.export.save(destination) puts puts " Saved build to #{destination}." puts " Open your cover page at file://#{File.(destination)}/index.html" puts book end |
#init(path = nil) ⇒ Object
Initialize a new book in the given path
7 8 9 10 11 12 13 14 |
# File 'lib/monograph/cli.rb', line 7 def init(path = nil) raise Error, "You must specify a path to create your new book in" if path.nil? raise Error, "File already exists at #{path}" if File.exist?(path) FileUtils.mkdir_p(path) FileUtils.cp_r(File.join(Monograph.root, 'test', 'fixtures', 'book1', '.'), path) puts "Initialized new monograph book at #{path}" Book.new(path) end |