Class: Metanorma::Cli::Generator
- Inherits:
-
Object
- Object
- Metanorma::Cli::Generator
- Defined in:
- lib/metanorma/cli/generator.rb
Class Method Summary collapse
-
.run(name, type:, doctype:, **options) ⇒ Object
Generator.run.
Instance Method Summary collapse
-
#initialize(name, type:, doctype:, **options) ⇒ Generator
constructor
A new instance of Generator.
- #run ⇒ Object
Constructor Details
#initialize(name, type:, doctype:, **options) ⇒ Generator
Returns a new instance of Generator.
9 10 11 12 13 14 15 |
# File 'lib/metanorma/cli/generator.rb', line 9 def initialize(name, type:, doctype:, **) @name = name @type = type @doctype = doctype @options = @template = .fetch(:template, nil) end |
Class Method Details
.run(name, type:, doctype:, **options) ⇒ Object
Generator.run
This interface find / downloads the specified template and then run the generator to create a new metanorma document.
By default it usages the default templates but user can also provide a remote git teplate repo using –template ooption, and in that case it will use that template.
41 42 43 |
# File 'lib/metanorma/cli/generator.rb', line 41 def self.run(name, type:, doctype:, **) new(name, **.merge(type: type, doctype: doctype)).run end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/metanorma/cli/generator.rb', line 17 def run if Cli.writable_templates_path? if name && document_path.exist? return unless overwrite?(document_path) document_path.rmtree end end rescue Errno::EACCES end |