Class: Imagen::Clone
- Inherits:
-
Object
- Object
- Imagen::Clone
- Defined in:
- lib/imagen/clone.rb
Overview
Responsible for cloning a Git repository into a given tempdir
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#repo_url ⇒ Object
readonly
Returns the value of attribute repo_url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(repo_url, dirname) ⇒ Clone
constructor
A new instance of Clone.
- #perform ⇒ Object
Constructor Details
#initialize(repo_url, dirname) ⇒ Clone
Returns a new instance of Clone.
17 18 19 20 21 22 23 24 |
# File 'lib/imagen/clone.rb', line 17 def initialize(repo_url, dirname) unless repo_url.match?(/^https:\/\//) raise ArgumentError, 'repo_url must start with https://' end @repo_url = repo_url @dir = dirname end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
15 16 17 |
# File 'lib/imagen/clone.rb', line 15 def dir @dir end |
#repo_url ⇒ Object (readonly)
Returns the value of attribute repo_url.
15 16 17 |
# File 'lib/imagen/clone.rb', line 15 def repo_url @repo_url end |
Class Method Details
.perform(repo_url, dir) ⇒ Object
11 12 13 |
# File 'lib/imagen/clone.rb', line 11 def self.perform(repo_url, dir) new(repo_url, dir).perform end |
Instance Method Details
#perform ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/imagen/clone.rb', line 26 def perform cmd = "GIT_TERMINAL_PROMPT=0 git clone #{repo_url} #{dir}" Open3.popen3(cmd) do |_s_in, _s_out, s_err, wait_thr| err_msg = s_err.read raise GitError, err_msg unless wait_thr.value.exitstatus.zero? end end |