Class: OrigenAppGenerators::Base

Inherits:
Origen::CodeGenerators::Base
  • Object
show all
Includes:
Origen::Utility::InputCapture
Defined in:
lib/origen_app_generators/base.rb

Overview

This is the base generator used by all generators in this application

Direct Known Subclasses

Application, New

Instance Method Summary collapse

Instance Method Details

#get_common_user_inputObject



35
36
37
# File 'lib/origen_app_generators/base.rb', line 35

def get_common_user_input
  get_name_and_namespace
end

#get_lastest_origen_versionObject



39
40
41
# File 'lib/origen_app_generators/base.rb', line 39

def get_lastest_origen_version
  @latest_origen_version = (Gems.info 'origen')['version']
end

#set_source_pathsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/origen_app_generators/base.rb', line 8

def set_source_paths
  # The base Origen generator puts the Origen core directory on the source path, in retrospect this
  # was a bad idea and makes for hard to debug errors if an app generator resolves a template from
  # outside of this app.
  # So to keep things sane remove any inherited source paths.
  self.class.source_paths.pop until self.class.source_paths.empty?
  klass = self.class

  until klass == OrigenAppGenerators::Base
    names = klass.to_s.split('::')
    names.shift
    dir = names.map(&:underscore).join('/')
    if OrigenAppGenerators.template_dirs[klass]
      dir = File.expand_path("#{OrigenAppGenerators.template_dirs[klass]}/#{dir}", __FILE__)
    else
      dir = File.expand_path("#{Origen.root!}/templates/app_generators/#{dir}", __FILE__)
    end
    self.class.source_paths << dir if File.exist?(dir) && !self.class.source_paths.include?(dir)
    klass = klass.superclass
  end
end

#set_typeObject

Just makes the type (:plugin or :application) available to all templates



31
32
33
# File 'lib/origen_app_generators/base.rb', line 31

def set_type
  @type = type
end