Class: Flow::Build::Service::Git

Inherits:
Object
  • Object
show all
Includes:
Clone, SshKey
Defined in:
lib/flow/build/service/git.rb,
lib/flow/build/service/git/clone.rb,
lib/flow/build/service/git/ssh_key.rb

Defined Under Namespace

Modules: Clone, SshKey

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SshKey

#install_ssh_key

Methods included from Clone

#git_clone

Constructor Details

#initialize(options = {}) ⇒ Git

Returns a new instance of Git.



16
17
18
19
20
21
22
23
# File 'lib/flow/build/service/git.rb', line 16

def initialize(options = {})
  @git_url   = options.fetch(:git_url, '')
  @ssh_key   = options.fetch(:ssh_key, '')
  @repo_dir  = options.fetch(:repo_dir, '')
  @repo_name = options.fetch(:repo_name, '')
  @branch    = options.fetch(:branch, 'master')
  @script    = []
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



13
14
15
# File 'lib/flow/build/service/git.rb', line 13

def branch
  @branch
end

#git_urlObject (readonly)

Returns the value of attribute git_url.



13
14
15
# File 'lib/flow/build/service/git.rb', line 13

def git_url
  @git_url
end

#repo_dirObject (readonly)

Returns the value of attribute repo_dir.



13
14
15
# File 'lib/flow/build/service/git.rb', line 13

def repo_dir
  @repo_dir
end

#repo_nameObject (readonly)

Returns the value of attribute repo_name.



13
14
15
# File 'lib/flow/build/service/git.rb', line 13

def repo_name
  @repo_name
end

#scriptObject

Returns the value of attribute script.



14
15
16
# File 'lib/flow/build/service/git.rb', line 14

def script
  @script
end

#ssh_keyObject (readonly)

Returns the value of attribute ssh_key.



13
14
15
# File 'lib/flow/build/service/git.rb', line 13

def ssh_key
  @ssh_key
end

Instance Method Details

#applyObject



29
30
31
32
33
# File 'lib/flow/build/service/git.rb', line 29

def apply
  install_ssh_key
  git_clone
  script.join("\n")
end

#git_hostObject



25
26
27
# File 'lib/flow/build/service/git.rb', line 25

def git_host
  git_url =~ %r(^(?:https?|git)(?:://|@)([^/]*?)(?:/|:)) && $1.split('@').last
end