Class: Origen::CodeGenerators::Klass

Inherits:
Base
  • Object
show all
Defined in:
lib/origen/code_generators/klass.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inherited, name, namespace

Methods included from Actions

#add_acronyms, #add_autoload, #add_config, #add_source, #camelcase, #comment_config, #config, #environment, #gem, #gem_group, #generate, #git, #initialize, #lib, #rakefile, #readme, #underscored_app_namespace

Methods included from Actions::Helpers

#add_type_to_namespaces, #class_name_to_blocks_dir, #class_name_to_lib_file, #internal_depth, #resource_path, #resource_path_to_blocks_dir, #resource_path_to_class, #resource_path_to_lib_file, #unless_has_method, #unless_valid_underscored_identifier, #validate_resource_path

Class Method Details



4
5
6
# File 'lib/origen/code_generators/klass.rb', line 4

def self.banner
  'origen new class NAME'
end

Instance Method Details

#create_class_fileObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/origen/code_generators/klass.rb', line 29

def create_class_file
  @resource_path = args.first
  klass = resource_path_to_class(args.first)
  @namespaces = klass.split('::').map(&:underscore)
  @name = @namespaces.pop
  @namespaces = add_type_to_namespaces(@namespaces)
  @root_class = true
  file = class_name_to_lib_file(klass)
  template 'templates/code_generators/class.rb', file
end

#validate_argsObject



19
20
21
22
23
24
25
26
27
# File 'lib/origen/code_generators/klass.rb', line 19

def validate_args
  if args.size > 1 || args.size == 0
    msg = args.size > 1 ? 'Only one' : 'One'
    msg << " argument is expected by the class generator, e.g. 'origen new class counter', 'origen new class helpers/counter'"
    puts msg
    exit 1
  end
  validate_resource_name(args.first)
end