Class: Generator

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

Constant Summary

Constants included from Util

Util::CONFIG_DIR

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

#config, #content_root, #user_email

Constructor Details

#initializeGenerator

Returns a new instance of Generator.



17
18
19
20
21
22
23
24
25
# File 'lib/generators/generator.rb', line 17

def initialize
  @licence = licence
  @user_name = user_name
  @package = config.group_id.split('.').each {|part| part.gsub!(/\W/,'')}.join('.')
  @fs_path = @package.gsub('.','/')
  @repository_import = Generator.repository_configuration(config.repository_technique).const_get :REPOSITORY_IMPORT
  @repository_type = Generator.repository_configuration(config.repository_technique).const_get :REPOSITORY_TYPE
  @destination_stack = [self.class.source_root]
end

Instance Attribute Details

#fs_pathObject

Returns the value of attribute fs_path.



14
15
16
# File 'lib/generators/generator.rb', line 14

def fs_path
  @fs_path
end

#fullObject

Returns the value of attribute full.



14
15
16
# File 'lib/generators/generator.rb', line 14

def full
  @full
end

#licenceObject

Returns the value of attribute licence.



14
15
16
# File 'lib/generators/generator.rb', line 14

def licence
  @licence
end

#model_nameObject

Returns the value of attribute model_name.



14
15
16
# File 'lib/generators/generator.rb', line 14

def model_name
  @model_name
end

#packageObject

Returns the value of attribute package.



14
15
16
# File 'lib/generators/generator.rb', line 14

def package
  @package
end

#repository_importObject

Returns the value of attribute repository_import.



14
15
16
# File 'lib/generators/generator.rb', line 14

def repository_import
  @repository_import
end

#repository_typeObject

Returns the value of attribute repository_type.



14
15
16
# File 'lib/generators/generator.rb', line 14

def repository_type
  @repository_type
end

#user_nameObject

Returns the value of attribute user_name.



14
15
16
# File 'lib/generators/generator.rb', line 14

def user_name
  @user_name
end

Class Method Details

.for_model(model_name, options, &block) ⇒ Object



37
38
39
40
41
42
# File 'lib/generators/generator.rb', line 37

def self.for_model(model_name,options,&block)
  instance = Generator.new
  instance.model_name = model_name
  instance.full = options['full']
  block.call instance
end

.source_rootObject



27
28
29
# File 'lib/generators/generator.rb', line 27

def self.source_root
  File.expand_path('../',__dir__)
end

Instance Method Details

#generate(template, target) ⇒ Object



31
32
33
34
35
# File 'lib/generators/generator.rb', line 31

def generate(template,target)
  puts "take the template #{template}"
  puts "and put it here: #{target}"
  template(template,target)
end