Class: Spectat::Jekyll::RakeTask::GitLabHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/spectat/jekyll/rake_task/helper.rb

Overview

Helper class for generating standardised GitLab CI configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_repo_path, fqdn) ⇒ GitLabHelper

Returns a new instance of GitLabHelper.



50
51
52
53
# File 'lib/spectat/jekyll/rake_task/helper.rb', line 50

def initialize(full_repo_path, fqdn)
  @full_repo_path = full_repo_path
  @fqdn = fqdn
end

Instance Attribute Details

#fqdnObject (readonly)

Returns the value of attribute fqdn.



47
48
49
# File 'lib/spectat/jekyll/rake_task/helper.rb', line 47

def fqdn
  @fqdn
end

#full_repo_pathObject (readonly)

Returns the value of attribute full_repo_path.



48
49
50
# File 'lib/spectat/jekyll/rake_task/helper.rb', line 48

def full_repo_path
  @full_repo_path
end

Instance Method Details

#render_templateObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/spectat/jekyll/rake_task/helper.rb', line 55

def render_template
  template = File.read(File.join(File.dirname(__FILE__), 'gitlab-ci.yml.erb'))
  erb = Erubis::Eruby.new(template)

  staging_helper = Spectat::Fqdn.new(@fqdn, 'staging')
  review_helper = Spectat::Fqdn.new(staging_helper.review_apps_fqdn, 'staging')

  erb.evaluate(
    fqdn_production: Spectat::Fqdn.new(@fqdn, 'production').fqdn,
    fqdn_staging: staging_helper.fqdn,
    fqdn_suffix_review: review_helper.fqdn,
    full_repo_path: @full_repo_path
  )
end