Class: Generator
- Inherits:
-
Object
- Object
- Generator
- Includes:
- Thor::Actions, Util
- Defined in:
- lib/generators/generator.rb
Constant Summary
Constants included from Util
Instance Attribute Summary collapse
-
#fs_path ⇒ Object
Returns the value of attribute fs_path.
-
#full ⇒ Object
Returns the value of attribute full.
-
#licence ⇒ Object
Returns the value of attribute licence.
-
#model_name ⇒ Object
Returns the value of attribute model_name.
-
#package ⇒ Object
Returns the value of attribute package.
-
#repository_import ⇒ Object
Returns the value of attribute repository_import.
-
#repository_type ⇒ Object
Returns the value of attribute repository_type.
-
#user_name ⇒ Object
Returns the value of attribute user_name.
Class Method Summary collapse
Instance Method Summary collapse
- #generate(template, target) ⇒ Object
-
#initialize ⇒ Generator
constructor
A new instance of Generator.
Methods included from Util
#config, #content_root, #user_email
Constructor Details
#initialize ⇒ Generator
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_path ⇒ Object
Returns the value of attribute fs_path.
14 15 16 |
# File 'lib/generators/generator.rb', line 14 def fs_path @fs_path end |
#full ⇒ Object
Returns the value of attribute full.
14 15 16 |
# File 'lib/generators/generator.rb', line 14 def full @full end |
#licence ⇒ Object
Returns the value of attribute licence.
14 15 16 |
# File 'lib/generators/generator.rb', line 14 def licence @licence end |
#model_name ⇒ Object
Returns the value of attribute model_name.
14 15 16 |
# File 'lib/generators/generator.rb', line 14 def model_name @model_name end |
#package ⇒ Object
Returns the value of attribute package.
14 15 16 |
# File 'lib/generators/generator.rb', line 14 def package @package end |
#repository_import ⇒ Object
Returns the value of attribute repository_import.
14 15 16 |
# File 'lib/generators/generator.rb', line 14 def repository_import @repository_import end |
#repository_type ⇒ Object
Returns the value of attribute repository_type.
14 15 16 |
# File 'lib/generators/generator.rb', line 14 def repository_type @repository_type end |
#user_name ⇒ Object
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,,&block) instance = Generator.new instance.model_name = model_name instance.full = ['full'] block.call instance end |
.source_root ⇒ Object
27 28 29 |
# File 'lib/generators/generator.rb', line 27 def self.source_root File.('../',__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 |