Class: Terraspace::Cloud::Vcs::LocalGit::Base

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/terraspace/cloud/vcs/local_git/base.rb

Direct Known Subclasses

Azure, Bitbucket, Github, Gitlab

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vars, git_url) ⇒ Base

Returns a new instance of Base.



6
7
8
# File 'lib/terraspace/cloud/vcs/local_git/base.rb', line 6

def initialize(vars, git_url)
  @vars, @git_url = vars, git_url
end

Instance Attribute Details

#git_urlObject (readonly)

Returns the value of attribute git_url.



5
6
7
# File 'lib/terraspace/cloud/vcs/local_git/base.rb', line 5

def git_url
  @git_url
end

Class Method Details

.vars_method(name) ⇒ Object



31
32
33
34
35
# File 'lib/terraspace/cloud/vcs/local_git/base.rb', line 31

def vars_method(name)
  define_method name do
    @vars[name]
  end
end

.vars_methods(*names) ⇒ Object



25
26
27
28
29
# File 'lib/terraspace/cloud/vcs/local_git/base.rb', line 25

def vars_methods(*names)
  names.each do |name|
    vars_method(name)
  end
end

Instance Method Details

#pr_numberObject



20
21
22
# File 'lib/terraspace/cloud/vcs/local_git/base.rb', line 20

def pr_number
  ENV['TS_VCS_PR_NUMBER'] || ENV['PR_NUMBER'] || ENV['MR_NUMBER']
end

#varsObject



10
11
12
13
14
15
16
17
18
# File 'lib/terraspace/cloud/vcs/local_git/base.rb', line 10

def vars
  {
    commit_url: commit_url,  # implemented by subclass
    branch_url: branch_url,  # implemented by subclass
    # pr_url handled when PR_NUMBER set by user outside of ci env. ci plugin pr_url takes higher precedence though
    pr_number: pr_number,
    pr_url: pr_url,
  }
end