Class: CIQuantum::Adapter::Gitlab

Inherits:
Struct
  • Object
show all
Defined in:
lib/ciquantum/adapter/gitlab.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config

Returns:

  • (Object)

    the current value of config



3
4
5
# File 'lib/ciquantum/adapter/gitlab.rb', line 3

def config
  @config
end

Class Method Details

.config_nameObject



5
6
7
# File 'lib/ciquantum/adapter/gitlab.rb', line 5

def self.config_name
  'gitlab'
end

.from_config(config) ⇒ Object



9
10
11
# File 'lib/ciquantum/adapter/gitlab.rb', line 9

def self.from_config config
  self.new config[config_name]
end

Instance Method Details

#[](command) ⇒ Object



21
22
23
# File 'lib/ciquantum/adapter/gitlab.rb', line 21

def [] command
  return config[command]
end

#commit_from_request(body) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ciquantum/adapter/gitlab.rb', line 25

def commit_from_request body
  begin
    hash = JSON.parse body
    res = (hash["repository"]["name"].downcase == config.project.to_s.downcase) ? hash["after"] : nil
    puts "CIQuantum::Adapter::GitLab#commit_from_request: New commit state \"#{res}\""
    res
  rescue => ex
    puts "CIQuantum::Adapter::GitLab#commit_from_request error: #{ex.to_s}"
    nil
  end
end

#commit_url(commit) ⇒ Object



13
14
15
# File 'lib/ciquantum/adapter/gitlab.rb', line 13

def commit_url commit
  "https://gitlab.sqtools.ru:11443/#{config.project}/commits/#{commit.sha}"
end

#urlObject



17
18
19
# File 'lib/ciquantum/adapter/gitlab.rb', line 17

def url
  "https://gitlab.sqtools.ru:11443/#{config.project}"
end