Class: Foobara::Generators::CommandGenerator::Generators::CommandGenerator

Inherits:
FilesGenerator
  • Object
show all
Defined in:
foobara-command-generator-0.1.0/src/command_generator.rb

Direct Known Subclasses

CommandSpecGenerator

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary

Attributes inherited from FilesGenerator

#belongs_to_dependency_group, #relevant_manifest

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FilesGenerator

#==, #absolute_template_path, #applicable?, #dependencies, #dependencies_to_generate, #eql?, #erb_template, #generate, generator_for, #generator_for, generators_for, #generators_for, #hash, #initialize, #method_missing, #path_to_root, #respond_to_missing?, #target_dir, #template_string

Methods included from FilesGenerator::BundlerActions

#bundle_install

Methods included from TruncatedInspect

#inspect, truncating

Constructor Details

This class inherits a constructor from Foobara::FilesGenerator

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Foobara::FilesGenerator

Class Method Details

.manifest_to_generator_classes(manifest) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'src/command_generator.rb', line 7

def manifest_to_generator_classes(manifest)
  case manifest
  when CommandConfig
    [
      Generators::CommandGenerator,
      Generators::CommandSpecGenerator
    ]
  else
    # :nocov:
    raise "Not sure how build a generator for a #{manifest}"
    # :nocov:
  end
end

Instance Method Details

#target_path ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'src/command_generator.rb', line 26

def target_path
  *path, file = module_path.map { |part| Util.underscore(part) }

  file = "#{file}.rb"

  if top_level
    ["src", file]
  else
    ["src", *path, file]
  end
end

#template_path ⇒ Object



22
23
24
# File 'src/command_generator.rb', line 22

def template_path
  ["src", "command.rb.erb"]
end

#templates_dir ⇒ Object



40
41
42
# File 'src/command_generator.rb', line 40

def templates_dir
  "#{__dir__}/../templates"
end