class Ruboty::Gitlab::Actions::Base
Constants
- NAMESPACE
Attributes
message[R]
Public Class Methods
new(message)
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 9 def initialize(message) @message = message end
Private Instance Methods
clear_projects()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 55 def clear_projects message.robot.brain.data[NAMESPACE][:projects] = nil end
client()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 59 def client ::Gitlab::Client.new(client_options) end
client_options()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 63 def client_options client_options_with_nil_value.reject {|key, value| value.nil? } end
client_options_with_nil_value()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 67 def client_options_with_nil_value { endpoint: gitlab_endpoint_url, private_token: private_token, } end
exists_project?()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 39 def exists_project? project.present? end
gitlab_endpoint_url()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 74 def gitlab_endpoint_url ENV["GITLAB_URL"] + "/api/v3" end
given_project()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 51 def given_project message[:project] end
has_private_token?()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 23 def has_private_token? !!private_token end
private_token()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 27 def private_token @private_token ||= private_tokens[sender_name] end
private_tokens()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 15 def private_tokens message.robot.brain.data[NAMESPACE] ||= {} end
project()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 47 def project projects[given_project] ||= search_project end
projects()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 35 def projects message.robot.brain.data[NAMESPACE][:projects] ||= {} end
require_private_token()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 19 def require_private_token message.reply("I don't know your gitlab private token") end
search_project()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 43 def search_project client.projects({ search: given_project }).find { |project| project.name == given_project } end
sender_name()
click to toggle source
# File lib/ruboty/gitlab/actions/base.rb, line 31 def sender_name message.from_name end