Class: Mygen::Generator
- Inherits:
-
Object
- Object
- Mygen::Generator
- Defined in:
- lib/mygen/generator.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dest_dir ⇒ Object
Returns the value of attribute dest_dir.
-
#dry_run ⇒ Object
Returns the value of attribute dry_run.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#template_source_dir ⇒ Object
Returns the value of attribute template_source_dir.
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
- #fileutils ⇒ Object
- #generator_name ⇒ Object
-
#initialize ⇒ Generator
constructor
A new instance of Generator.
- #parent_dirs_dont_exist?(path) ⇒ Boolean
Methods included from Templates
#make_template_tree, #make_template_tree_in_current_dir, #parse, #parse_templates
Methods included from Files
#directory_exists?, #file_destination, #internal_template_files, #internal_template_source_dir, #move_file_in_place, #template_dirs, #template_files
Methods included from Naming
#camel_case, #cc_name, #d_name, #dash_case, #method_name, #no_case, #s_name, #snake_case
Constructor Details
#initialize ⇒ Generator
Returns a new instance of Generator.
14 15 16 |
# File 'lib/mygen/generator.rb', line 14 def initialize @template_source_dir = File.join(ENV['HOME'], ".mygen", "plugins", generator_name, "templates").tr('\\', '/') end |
Instance Attribute Details
#dest_dir ⇒ Object
Returns the value of attribute dest_dir.
12 13 14 |
# File 'lib/mygen/generator.rb', line 12 def dest_dir @dest_dir end |
#dry_run ⇒ Object
Returns the value of attribute dry_run.
12 13 14 |
# File 'lib/mygen/generator.rb', line 12 def dry_run @dry_run end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/mygen/generator.rb', line 12 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/mygen/generator.rb', line 12 def @options end |
#template_source_dir ⇒ Object
Returns the value of attribute template_source_dir.
12 13 14 |
# File 'lib/mygen/generator.rb', line 12 def template_source_dir @template_source_dir end |
Class Method Details
.descendants ⇒ Object
18 19 20 |
# File 'lib/mygen/generator.rb', line 18 def self.descendants ObjectSpace.each_object(Class).select { |klass| klass < self } end |
Instance Method Details
#description ⇒ Object
22 23 24 |
# File 'lib/mygen/generator.rb', line 22 def description "Plugin has no description" end |
#fileutils ⇒ Object
30 31 32 |
# File 'lib/mygen/generator.rb', line 30 def fileutils dry_run ? FileUtils::DryRun : FileUtils::Verbose end |
#generator_name ⇒ Object
26 27 28 |
# File 'lib/mygen/generator.rb', line 26 def generator_name snake_case(self.class.name) end |
#parent_dirs_dont_exist?(path) ⇒ Boolean
34 35 36 37 38 |
# File 'lib/mygen/generator.rb', line 34 def parent_dirs_dont_exist?(path) parent_dir = File.("..", path) return false if path.include?('__') return !File.exist?(path) end |