Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-02-13 07:31:55 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-10 06:58:28 +0300
commit345fd545bf6d5f161686a09c4583a1e7488fd9c6 (patch)
treee103fc9da89da300adf6106a4b387e748850e9a1 /lib/version_check.rb
parentf5eb5fdd5e6d8bcf3ad52749e99a378e411ff8ad (diff)
Add version check badge to admin area
Diffstat (limited to 'lib/version_check.rb')
-rw-r--r--lib/version_check.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/version_check.rb b/lib/version_check.rb
new file mode 100644
index 00000000000..ada5e0db7a9
--- /dev/null
+++ b/lib/version_check.rb
@@ -0,0 +1,30 @@
+# This class is used to encrypt GitLab version and URL
+# with public key when we send it to version.gitlab.com to
+# check if it is a new version for update
+class VersionCheck
+ include SimpleEncrypt
+
+ def public_key
+ public_key_file = Rails.root.join('safe', 'public.pem').to_s
+ File.read(public_key_file)
+ end
+
+ def data
+ {
+ version: Gitlab::VERSION,
+ url: Gitlab.config.gitlab.url
+ }
+ end
+
+ def encrypt(string)
+ encrypt_with_public_key(string, public_key)
+ end
+
+ def url
+ "#{host}?gitlab_info=#{encrypt(data.to_json)}"
+ end
+
+ def host
+ 'http://localhost:9090/check.png'
+ end
+end