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 Base
Instance Method Summary collapse
-
#initialize(template_url, options) ⇒ Git
constructor
A new instance of Git.
- #local_directory ⇒ Object
Methods inherited from Base
#close, #place_config, #place_files
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, = 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 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
#local_directory ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/stevenson/templates/git.rb', line 12 def local_directory @_local_directory ||= 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 rescue ::Git::GitExecuteError # If the given repo URL is not valid, raise an exception raise InvalidTemplateException.new('Failed to clone the repository') end |