Class: RubiGen::Commands::Base

Inherits:
Base show all
Defined in:
lib/rubigen/commands.rb

Overview

Generator commands delegate RubiGen::Base and implement a standard set of actions. Their behavior is defined by the way they respond to these actions: Create brings life; Destroy brings death; List passively observes.

Commands are invoked by replaying (or rewinding) the generator’s manifest of actions. See RubiGen::Manifest and RubiGen::Base#manifest method that generator subclasses are required to override.

Commands allows generators to “plug in” invocation behavior, which corresponds to the GoF Strategy pattern.

Direct Known Subclasses

Create, List, RewindBase

Instance Attribute Summary

Attributes inherited from Base

#args, #destination_root, #source_root, #stdout

Attributes included from Options

#options

Instance Method Summary collapse

Methods inherited from Base

#after_generate, #base_name, #destination_path, #initialize, #manifest, #source_path

Methods included from Options

included

Constructor Details

This class inherits a constructor from RubiGen::Base

Instance Method Details

#class_collisions(*class_names) ⇒ Object

Does nothing for all commands except Create.



52
53
# File 'lib/rubigen/commands.rb', line 52

def class_collisions(*class_names)
end

#dependency(generator_name, args, runtime_options = {}) ⇒ Object



45
46
47
48
49
# File 'lib/rubigen/commands.rb', line 45

def dependency(generator_name, args, runtime_options = {})
  logger.dependency(generator_name) do
    self.class.new(instance(generator_name, args, full_options(runtime_options))).invoke!
  end
end

#invoke!Object

Replay action manifest. RewindBase subclass rewinds manifest.



40
41
42
43
# File 'lib/rubigen/commands.rb', line 40

def invoke!
  manifest.replay(self)
  after_generate
end

#readme(*args) ⇒ Object

Does nothing for all commands except Create.



56
57
# File 'lib/rubigen/commands.rb', line 56

def readme(*args)
end

#write_manifestObject

Does nothing for all commands except Create.



60
61
# File 'lib/rubigen/commands.rb', line 60

def write_manifest
end