Class: BPM::Generator

Inherits:
Object
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/bpm/generator.rb

Overview

Knows how to generate items out of the local templates directory

Direct Known Subclasses

InitGenerator, ProjectGenerator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(thor, name, root, template_path = nil, package = nil) ⇒ Generator

Returns a new instance of Generator.



34
35
36
37
38
# File 'lib/bpm/generator.rb', line 34

def initialize(thor, name, root, template_path=nil, package=nil)
  @thor, @name, @template_path, @package = thor, name, template_path, package

  self.destination_root = root
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &blk) ⇒ Object (private)



70
71
72
# File 'lib/bpm/generator.rb', line 70

def method_missing(name, *args, &blk)
  @thor.send(name, *args, &blk)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



32
33
34
# File 'lib/bpm/generator.rb', line 32

def name
  @name
end

#packageObject (readonly)

Returns the value of attribute package.



32
33
34
# File 'lib/bpm/generator.rb', line 32

def package
  @package
end

Instance Method Details

#dir_nameObject



40
41
42
# File 'lib/bpm/generator.rb', line 40

def dir_name
  File.basename destination_root
end

#say(*args) ⇒ Object



52
53
54
# File 'lib/bpm/generator.rb', line 52

def say(*args)
  shell.say *args
end

#shellObject



48
49
50
# File 'lib/bpm/generator.rb', line 48

def shell
  @shell ||= Thor::Base.shell.new
end

#source_pathsObject



44
45
46
# File 'lib/bpm/generator.rb', line 44

def source_paths
  [@template_path, self.class.source_root].compact
end