Class: SleepingKingStudios::Docs::Commands::Generators::Base

Inherits:
Cuprum::Command
  • Object
show all
Includes:
Cuprum::ExceptionHandling
Defined in:
lib/sleeping_king_studios/docs/commands/generators/base.rb

Overview

Abstract base class for writing generator classes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(docs_path:, **options) ⇒ Base

Returns a new instance of Base.

Parameters:

  • docs_path (String)

    the directory path for generating the documentation files.

  • options (Hash)

    the configured options for the generator.

Options Hash (**options):

  • dry_run (Boolean)

    if true, does not make any changes to the filesystem.

  • force (Boolean)

    if true, overwrites any existing files.

  • version (String)

    the code version for the generated documentation.

  • verbose (Boolean)

    if true, prints status messages to STDOUT.



25
26
27
28
29
30
# File 'lib/sleeping_king_studios/docs/commands/generators/base.rb', line 25

def initialize(docs_path:, **options)
  super()

  @docs_path = docs_path
  @options   = default_options.merge(options)
end

Instance Attribute Details

#docs_pathString (readonly)

Returns the directory path for generating the documentation files.

Returns:

  • (String)

    the directory path for generating the documentation files.



34
35
36
# File 'lib/sleeping_king_studios/docs/commands/generators/base.rb', line 34

def docs_path
  @docs_path
end

#optionsHash (readonly)

Returns the configured options for the generator.

Returns:

  • (Hash)

    the configured options for the generator.



37
38
39
# File 'lib/sleeping_king_studios/docs/commands/generators/base.rb', line 37

def options
  @options
end

Instance Method Details

#dry_run?Boolean

Returns if true, does not make any changes to the filesystem.

Returns:

  • (Boolean)

    if true, does not make any changes to the filesystem.



40
41
42
# File 'lib/sleeping_king_studios/docs/commands/generators/base.rb', line 40

def dry_run?
  @options[:dry_run]
end

#force?Boolean

Returns if true, overwrites any existing files.

Returns:

  • (Boolean)

    if true, overwrites any existing files.



45
46
47
# File 'lib/sleeping_king_studios/docs/commands/generators/base.rb', line 45

def force?
  @options[:force]
end

#template_pathString

Returns the relative path to the Jekyll templates for each data type.

Returns:

  • (String)

    the relative path to the Jekyll templates for each data type.



51
52
53
# File 'lib/sleeping_king_studios/docs/commands/generators/base.rb', line 51

def template_path
  @options.fetch(:template_path, 'reference')
end

#verbose?Boolean

Returns if true, prints status messages to STDOUT.

Returns:

  • (Boolean)

    if true, prints status messages to STDOUT.



56
57
58
# File 'lib/sleeping_king_studios/docs/commands/generators/base.rb', line 56

def verbose?
  @options[:verbose]
end

#versionString

Returns the code version for the generated documentation.

Returns:

  • (String)

    the code version for the generated documentation.



61
62
63
# File 'lib/sleeping_king_studios/docs/commands/generators/base.rb', line 61

def version
  @options[:version]
end