Class: Stevenson::Template::Git
- Defined in:
- lib/stevenson/templates/git.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#template_url ⇒ Object
readonly
Returns the value of attribute template_url.
Attributes inherited from Local
Attributes inherited from Base
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(template_url, options) ⇒ Git
constructor
A new instance of Git.
- #local_directory ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(template_url, options) ⇒ Git
Returns a new instance of Git.
8 9 10 |
# File 'lib/stevenson/templates/git.rb', line 8 def initialize(template_url, ) @template_url, @options = template_url, end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/stevenson/templates/git.rb', line 6 def @options end |
#template_url ⇒ Object (readonly)
Returns the value of attribute template_url.
6 7 8 |
# File 'lib/stevenson/templates/git.rb', line 6 def template_url @template_url end |
Instance Method Details
#close ⇒ Object
29 30 31 32 |
# File 'lib/stevenson/templates/git.rb', line 29 def close FileUtils.rm_rf template_path if template_path super end |
#local_directory ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/stevenson/templates/git.rb', line 12 def local_directory @_local_directory ||= begin @template_path ||= Dir.mktmpdir.tap do |dir| # Clone the repo to a temporary directory for later use ::Git.clone(template_url, dir).tap do |repo| # Switch_branch if set repo.checkout([:branch]) if .has_key?(:branch) end end super end rescue ::Git::GitExecuteError # If the given repo URL is not valid, raise an exception raise InvalidTemplateException.new('Failed to clone the repository and/or branch') end |