Class: Xplenty::Kensa::Git
- Inherits:
-
Object
- Object
- Xplenty::Kensa::Git
- Defined in:
- lib/xplenty/kensa/git.rb
Class Method Summary collapse
- .clone(app_name, template) ⇒ Object
- .clone_url(name) ⇒ Object
- .git_installed? ⇒ Boolean
- .run(cmd) ⇒ Object
- .verify_create(app_name, template) ⇒ Object
- .xplenty_prefix ⇒ Object
Class Method Details
.clone(app_name, template) ⇒ Object
13 14 15 16 |
# File 'lib/xplenty/kensa/git.rb', line 13 def clone(app_name, template) verify_create(app_name, template) run("git clone #{clone_url(template)} #{app_name}") end |
.clone_url(name) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/xplenty/kensa/git.rb', line 27 def clone_url(name) if name.include? "://" #its a full url not on github return name elsif !name.include? "/" #its one of ours name = xplenty_prefix + name end "git://github.com/#{name}" end |
.git_installed? ⇒ Boolean
9 10 11 |
# File 'lib/xplenty/kensa/git.rb', line 9 def git_installed? `git` rescue false end |
.run(cmd) ⇒ Object
18 19 20 21 |
# File 'lib/xplenty/kensa/git.rb', line 18 def run(cmd) puts cmd system(cmd) end |
.verify_create(app_name, template) ⇒ Object
5 6 7 |
# File 'lib/xplenty/kensa/git.rb', line 5 def verify_create(app_name, template) raise CommandInvalid.new("Need git to clone repository") unless git_installed? end |
.xplenty_prefix ⇒ Object
23 24 25 |
# File 'lib/xplenty/kensa/git.rb', line 23 def xplenty_prefix ENV["REPO_PREFIX"] || "xplenty/xplenty-kensa-create-" end |