Class: Carta::CLI::Base

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/carta/cli.rb

Overview

The class from which it all begins

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ASSET_PATHObject (readonly)

Returns the value of attribute ASSET_PATH.



9
10
11
# File 'lib/carta/cli.rb', line 9

def ASSET_PATH
  @ASSET_PATH
end

#BUILD_PATHObject (readonly)

Returns the value of attribute BUILD_PATH.



9
10
11
# File 'lib/carta/cli.rb', line 9

def BUILD_PATH
  @BUILD_PATH
end

#LAYOUT_PATHObject (readonly)

Returns the value of attribute LAYOUT_PATH.



9
10
11
# File 'lib/carta/cli.rb', line 9

def LAYOUT_PATH
  @LAYOUT_PATH
end

#MANU_PATHObject (readonly)

Returns the value of attribute MANU_PATH.



9
10
11
# File 'lib/carta/cli.rb', line 9

def MANU_PATH
  @MANU_PATH
end

#metaObject (readonly)

Returns the value of attribute meta.



9
10
11
# File 'lib/carta/cli.rb', line 9

def meta
  @meta
end

Class Method Details

.source_rootObject

def initialize(*args)

@BUILD_PATH  = 'build'
@LAYOUT_PATH = 'layouts'
@MANU_PATH   = 'manuscript'
@ASSET_PATH  = 'assets'

end



22
23
24
# File 'lib/carta/cli.rb', line 22

def self.source_root
  File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end

Instance Method Details

#book(*name) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/carta/cli.rb', line 28

def book(*name)
  name = name.empty? ? '' : name.join(' ')

  say("\nThis utility will walk you through creating an ebook project.")
  say("\nPress ^C at any time to quit.")

  require 'carta/cli/book'

  default_name   = name.empty? ? '' : "(#{name})"

  ask_title    = ask "Title:#{default_name}"
  ask_license  = ask 'License: (MIT)'
  ask_lang     = ask 'Language: (en-US)'
  ask_author   = ask 'Author(s): (Anonymous)'
  ask_uuid     = ask 'uuid:'

  @meta = {
    title:    ask_title.empty? ? name : ask_title,
    subtitle: ask('Subtitle: (blank)'),
    authors:  ask_author.empty? ? 'Anonymous' : ask_author,
    language: ask_lang.empty? ? 'en-US' : ask_lang,
    license:  ask_license.empty? ? 'MIT' : ask_license,
    uid:      ask_uuid.empty? ? UUID.new.generate : ask_uuid
  }
  Carta::CLI::Book.new(self, meta).run
end

#chapter(number, *name) ⇒ Object



57
58
59
60
61
# File 'lib/carta/cli.rb', line 57

def chapter(number, *name)
  number, name = '00', [number].concat(name) unless /\d+/.match number
  require 'carta/cli/chapter'
  Carta::CLI::Chapter.new(self, number, name).run
end

#compileObject



64
65
66
67
# File 'lib/carta/cli.rb', line 64

def compile
  require 'carta/cli/compile'
  Carta::CLI::Compile.new(self).run
end