okcomputer 1.18.3 → 1.18.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ok_computer/built_in_checks/app_version_check.rb +19 -5
- data/lib/ok_computer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 964bccbd2510184da0f52827f5558f8745076a8c8725745a9c7659b04779c6db
|
4
|
+
data.tar.gz: 4525ecd9968072a9f2be2da58dbbe63d238e55800168e3e3b3b26006335f79a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76d6c635b55919898267bcbdb48e4a2da3342c52316038427d6771d2f277890ddd88f9389a9016a41ee2c2c0e7cb28f7a1a1b2cf5a3535ba9122724fac8eb961
|
7
|
+
data.tar.gz: 4be31489a2a1bf21d5e91aff93f675cbbe75e30c2cfbeea3687faed27ab204965e1e75765fb7c02e0b57eb6620b8ae07824e596eff3520c607009608a9405443
|
@@ -5,6 +5,21 @@ module OkComputer
|
|
5
5
|
# * Otherwise, checks for Capistrano's REVISION file in the app root.
|
6
6
|
# * Failing these, the check fails
|
7
7
|
class AppVersionCheck < Check
|
8
|
+
attr_accessor :file
|
9
|
+
attr_accessor :env
|
10
|
+
attr_accessor :transform
|
11
|
+
|
12
|
+
# Public: Initialize a check for a backed-up Sidekiq queue
|
13
|
+
#
|
14
|
+
# file - The path of the version file to check
|
15
|
+
# env - The key in ENV to check for a revision SHA
|
16
|
+
# transform - The block to optionally transform the version string
|
17
|
+
def initialize(file: "REVISION", env: "SHA", &transform)
|
18
|
+
self.file = file
|
19
|
+
self.env = env
|
20
|
+
self.transform = transform || proc { |v| v }
|
21
|
+
end
|
22
|
+
|
8
23
|
# Public: Return the application version
|
9
24
|
def check
|
10
25
|
mark_message "Version: #{version}"
|
@@ -17,21 +32,20 @@ module OkComputer
|
|
17
32
|
#
|
18
33
|
# Returns a String
|
19
34
|
def version
|
20
|
-
version_from_env || version_from_file || raise(UnknownRevision)
|
35
|
+
transform.call(version_from_env || version_from_file || raise(UnknownRevision))
|
21
36
|
end
|
22
37
|
|
23
38
|
private
|
24
39
|
|
25
40
|
# Private: Version stored in environment variable
|
26
41
|
def version_from_env
|
27
|
-
ENV[
|
42
|
+
ENV[env]
|
28
43
|
end
|
29
44
|
|
30
45
|
# Private: Version stored in Capistrano revision file
|
31
46
|
def version_from_file
|
32
|
-
|
33
|
-
|
34
|
-
end
|
47
|
+
path = Rails.root.join(file)
|
48
|
+
File.read(path).chomp if File.exist?(path)
|
35
49
|
end
|
36
50
|
|
37
51
|
UnknownRevision = Class.new(StandardError)
|
data/lib/ok_computer/version.rb
CHANGED