gemnasium_service.rb 1.2 KB
Newer Older
1 2 3 4
# == Schema Information
#
# Table name: services
#
V
Valery Sizov 已提交
5 6 7
#  id         :integer          not null, primary key
#  type       :string(255)
#  title      :string(255)
8
#  project_id :integer
V
Valery Sizov 已提交
9 10 11 12
#  created_at :datetime
#  updated_at :datetime
#  active     :boolean          default(FALSE), not null
#  properties :text
13
#  template   :boolean          default(FALSE)
14 15 16 17 18
#

require "gemnasium/gitlab_service"

class GemnasiumService < Service
D
Drew Blessing 已提交
19
  prop_accessor :token, :api_key
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
  validates :token, :api_key, presence: true, if: :activated?

  def title
    'Gemnasium'
  end

  def description
    'Gemnasium monitors your project dependencies and alerts you about updates and security vulnerabilities.'
  end

  def to_param
    'gemnasium'
  end

  def fields
    [
      { type: 'text', name: 'api_key', placeholder: 'Your personal API KEY on gemnasium.com ' },
      { type: 'text', name: 'token', placeholder: 'The project\'s slug on gemnasium.com' }
    ]
  end

  def execute(push_data)
    Gemnasium::GitlabService.execute(
      ref: push_data[:ref],
      before: push_data[:before],
      after: push_data[:after],
      token: token,
      api_key: api_key,
48
      repo: project.repository.path_to_repo
49 50 51
      )
  end
end