Class: Greg::Generator
- Inherits:
-
Object
- Object
- Greg::Generator
- Defined in:
- lib/greg/generator.rb
Instance Attribute Summary collapse
-
#current_dir ⇒ Object
readonly
Returns the value of attribute current_dir.
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#generator ⇒ Object
readonly
Returns the value of attribute generator.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output_directory ⇒ Object
readonly
Returns the value of attribute output_directory.
-
#template_name ⇒ Object
readonly
Returns the value of attribute template_name.
-
#template_path ⇒ Object
readonly
Returns the value of attribute template_path.
Instance Method Summary collapse
- #files ⇒ Object
-
#initialize(name:, template_name:, output_directory: ".", force: false) ⇒ Generator
constructor
A new instance of Generator.
- #inside_dir(&block) ⇒ Object
- #run ⇒ Object
- #template_dir ⇒ Object
Constructor Details
#initialize(name:, template_name:, output_directory: ".", force: false) ⇒ Generator
Returns a new instance of Generator.
11 12 13 14 15 16 17 18 |
# File 'lib/greg/generator.rb', line 11 def initialize(name:, template_name: , output_directory: ".", force: false) @name = name @template_name = template_name @output_directory = Pathname(output_directory + "/" + name). @current_dir = Pathname("."). @force = force end |
Instance Attribute Details
#current_dir ⇒ Object (readonly)
Returns the value of attribute current_dir.
7 8 9 |
# File 'lib/greg/generator.rb', line 7 def current_dir @current_dir end |
#force ⇒ Object (readonly)
Returns the value of attribute force.
8 9 10 |
# File 'lib/greg/generator.rb', line 8 def force @force end |
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
9 10 11 |
# File 'lib/greg/generator.rb', line 9 def generator @generator end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/greg/generator.rb', line 3 def name @name end |
#output_directory ⇒ Object (readonly)
Returns the value of attribute output_directory.
6 7 8 |
# File 'lib/greg/generator.rb', line 6 def output_directory @output_directory end |
#template_name ⇒ Object (readonly)
Returns the value of attribute template_name.
4 5 6 |
# File 'lib/greg/generator.rb', line 4 def template_name @template_name end |
#template_path ⇒ Object (readonly)
Returns the value of attribute template_path.
5 6 7 |
# File 'lib/greg/generator.rb', line 5 def template_path @template_path end |
Instance Method Details
#files ⇒ Object
26 27 28 |
# File 'lib/greg/generator.rb', line 26 def files [] end |
#inside_dir(&block) ⇒ Object
30 31 32 |
# File 'lib/greg/generator.rb', line 30 def inside_dir(&block) Dir.chdir(output_directory, &block) end |
#run ⇒ Object
20 21 22 23 24 |
# File 'lib/greg/generator.rb', line 20 def run create_directory create_files self end |
#template_dir ⇒ Object
34 35 36 |
# File 'lib/greg/generator.rb', line 34 def template_dir Pathname(Greg.templates_dir + "/" + template_name)..to_s end |