Class: Xplenty::Kensa::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/xplenty/kensa/git.rb

Class Method Summary collapse

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

Returns:

  • (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

Raises:

  • (CommandInvalid)


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_prefixObject



23
24
25
# File 'lib/xplenty/kensa/git.rb', line 23

def xplenty_prefix
  ENV["REPO_PREFIX"] || "xplenty/xplenty-kensa-create-"
end