summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorBinsztock Rémy <remy.binsztock@tech-angels.com>2014-02-19 00:09:16 +0100
committerOlivier Gonzalez <olivier.gonzalez@tech-angels.com>2014-02-21 16:25:22 +0100
commite7382de1084f75bc8cfb2a5135412fdbd81f3b25 (patch)
tree6ab0a8105cd711eb31118262a3238a47088a2849 /app/models
parent490f99d45e0f610e88505ff0fb2dc83a557e22c5 (diff)
downloadgitlab-ce-e7382de1084f75bc8cfb2a5135412fdbd81f3b25.tar.gz
Add Gemnasium Service for Gitlab
Conflicts: db/schema.rb
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project.rb3
-rw-r--r--app/models/project_services/assembla_service.rb1
-rw-r--r--app/models/project_services/campfire_service.rb1
-rw-r--r--app/models/project_services/emails_on_push_service.rb1
-rw-r--r--app/models/project_services/flowdock_service.rb1
-rw-r--r--app/models/project_services/gemnasium_service.rb54
-rw-r--r--app/models/project_services/gitlab_ci_service.rb1
-rw-r--r--app/models/project_services/hipchat_service.rb1
-rw-r--r--app/models/project_services/pivotaltracker_service.rb1
-rw-r--r--app/models/service.rb3
10 files changed, 65 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index d9da2c377c8..2c926ff8a9a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -53,6 +53,7 @@ class Project < ActiveRecord::Base
has_one :hipchat_service, dependent: :destroy
has_one :flowdock_service, dependent: :destroy
has_one :assembla_service, dependent: :destroy
+ has_one :gemnasium_service, dependent: :destroy
has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id"
has_one :forked_from_project, through: :forked_project_link
@@ -256,7 +257,7 @@ class Project < ActiveRecord::Base
end
def available_services_names
- %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push)
+ %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium)
end
def gitlab_ci?
diff --git a/app/models/project_services/assembla_service.rb b/app/models/project_services/assembla_service.rb
index ad7eade5c7b..2a2c5172916 100644
--- a/app/models/project_services/assembla_service.rb
+++ b/app/models/project_services/assembla_service.rb
@@ -13,6 +13,7 @@
# project_url :string(255)
# subdomain :string(255)
# room :string(255)
+# api_key :string(255)
#
class AssemblaService < Service
diff --git a/app/models/project_services/campfire_service.rb b/app/models/project_services/campfire_service.rb
index fb2a49fd586..f9247e054c7 100644
--- a/app/models/project_services/campfire_service.rb
+++ b/app/models/project_services/campfire_service.rb
@@ -13,6 +13,7 @@
# project_url :string(255)
# subdomain :string(255)
# room :string(255)
+# api_key :string(255)
#
class CampfireService < Service
diff --git a/app/models/project_services/emails_on_push_service.rb b/app/models/project_services/emails_on_push_service.rb
index 2a46eff7846..0a453166342 100644
--- a/app/models/project_services/emails_on_push_service.rb
+++ b/app/models/project_services/emails_on_push_service.rb
@@ -13,6 +13,7 @@
# project_url :string(255)
# subdomain :string(255)
# room :string(255)
+# api_key :string(255)
#
class EmailsOnPushService < Service
diff --git a/app/models/project_services/flowdock_service.rb b/app/models/project_services/flowdock_service.rb
index f72d9fa9015..2603a1f67a4 100644
--- a/app/models/project_services/flowdock_service.rb
+++ b/app/models/project_services/flowdock_service.rb
@@ -13,6 +13,7 @@
# project_url :string(255)
# subdomain :string(255)
# room :string(255)
+# api_key :string(255)
#
require "flowdock-git-hook"
diff --git a/app/models/project_services/gemnasium_service.rb b/app/models/project_services/gemnasium_service.rb
new file mode 100644
index 00000000000..0b8e7bad353
--- /dev/null
+++ b/app/models/project_services/gemnasium_service.rb
@@ -0,0 +1,54 @@
+# == Schema Information
+#
+# Table name: services
+#
+# id :integer not null, primary key
+# type :string(255)
+# title :string(255)
+# token :string(255)
+# project_id :integer not null
+# created_at :datetime not null
+# updated_at :datetime not null
+# active :boolean default(FALSE), not null
+# project_url :string(255)
+# subdomain :string(255)
+# room :string(255)
+# api_key :string(255)
+#
+
+require "gemnasium/gitlab_service"
+
+class GemnasiumService < Service
+ 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)
+ repo_path = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git")
+ Gemnasium::GitlabService.execute(
+ ref: push_data[:ref],
+ before: push_data[:before],
+ after: push_data[:after],
+ token: token,
+ api_key: api_key,
+ repo: repo_path
+ )
+ end
+end
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index 7f5380a4551..017cd9eeaab 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -13,6 +13,7 @@
# project_url :string(255)
# subdomain :string(255)
# room :string(255)
+# api_key :string(255)
#
class GitlabCiService < Service
diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb
index d4795867baf..3cee047a32a 100644
--- a/app/models/project_services/hipchat_service.rb
+++ b/app/models/project_services/hipchat_service.rb
@@ -13,6 +13,7 @@
# project_url :string(255)
# subdomain :string(255)
# room :string(255)
+# api_key :string(255)
#
class HipchatService < Service
diff --git a/app/models/project_services/pivotaltracker_service.rb b/app/models/project_services/pivotaltracker_service.rb
index c5b1b9ab8d3..877b9a77404 100644
--- a/app/models/project_services/pivotaltracker_service.rb
+++ b/app/models/project_services/pivotaltracker_service.rb
@@ -13,6 +13,7 @@
# project_url :string(255)
# subdomain :string(255)
# room :string(255)
+# api_key :string(255)
#
class PivotaltrackerService < Service
diff --git a/app/models/service.rb b/app/models/service.rb
index 540aaad1ce5..26060d00b02 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -13,12 +13,13 @@
# project_url :string(255)
# subdomain :string(255)
# room :string(255)
+# api_key :string(255)
#
# To add new service you should build a class inherited from Service
# and implement a set of methods
class Service < ActiveRecord::Base
- attr_accessible :title, :token, :type, :active
+ attr_accessible :title, :token, :type, :active, :api_key
belongs_to :project
has_one :service_hook