Class: Metanorma::Cli::GitTemplate
- Inherits:
-
Object
- Object
- Metanorma::Cli::GitTemplate
- Defined in:
- lib/metanorma/cli/git_template.rb
Class Method Summary collapse
-
.download(name, repo:, remote: true) ⇒ Object
Download a template.
-
.find_or_download_by(name) ⇒ Object
Find or Download.
Instance Method Summary collapse
- #download ⇒ Object
- #find_or_download ⇒ Object
-
#initialize(name, options = {}) ⇒ GitTemplate
constructor
A new instance of GitTemplate.
- #remove! ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ GitTemplate
Returns a new instance of GitTemplate.
6 7 8 9 |
# File 'lib/metanorma/cli/git_template.rb', line 6 def initialize(name, = {}) @name = name @options = end |
Class Method Details
.download(name, repo:, remote: true) ⇒ Object
Download a template
This interface expects a name, and remote repository link for a template, then it will download that template and it will return the downloaded path.
By default, downloaded tempaltes will be stored in a sub directoy inside metanorma’s tempaltes directory, but if you don’t want then you can set the ‘remote` to false.
49 50 51 |
# File 'lib/metanorma/cli/git_template.rb', line 49 def self.download(name, repo:, remote: true) new(name, repo: repo, remote: remote).download end |
.find_or_download_by(name) ⇒ Object
Find or Download
This interface expects a name / type, and then it will find that template, or if non exist then it will download and return the downloaded path.
35 36 37 |
# File 'lib/metanorma/cli/git_template.rb', line 35 def self.find_or_download_by(name) new(name).find_or_download end |
Instance Method Details
#download ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/metanorma/cli/git_template.rb', line 16 def download remove! clone_git_template([:repo]) rescue Git::GitExecuteError UI.say("Invalid template reoository!") return nil end |
#find_or_download ⇒ Object
25 26 27 |
# File 'lib/metanorma/cli/git_template.rb', line 25 def find_or_download find_template || download_template end |
#remove! ⇒ Object
11 12 13 14 |
# File 'lib/metanorma/cli/git_template.rb', line 11 def remove! remove_template return true end |