gitlab-license 1.0.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gitlab/license.rb +99 -23
- data/lib/gitlab/license/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e2099828f195390b3feec3baff3129202e17b50d2ef98e9db12a5627e149f9c
|
4
|
+
data.tar.gz: 50d9e48ca255e0b4cf1e6155fc8eeffaaa25c8b1682c8c04f9910135bb16fa68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27d52f399c1640c873c34158daf4fc07a60c63df0bc1937e7559ffab7b1ebd3e2f590c98c47bde5e5855dc736d2b51efa35c1a4172a5dcde58fc7f50c8681b00
|
7
|
+
data.tar.gz: c583ecccdbb22b0849e2101e4ddba8974ba078bf4f7ecda243d2ef529f5903ddce0e3a6c78376f77bf1b2933a6e5894b0da82bee5a05dcd00cad84f7cfb36304
|
data/lib/gitlab/license.rb
CHANGED
@@ -50,9 +50,11 @@ module Gitlab
|
|
50
50
|
end
|
51
51
|
|
52
52
|
attr_reader :version
|
53
|
-
attr_accessor :licensee, :starts_at, :expires_at
|
54
|
-
|
55
|
-
|
53
|
+
attr_accessor :licensee, :starts_at, :expires_at, :notify_admins_at,
|
54
|
+
:notify_users_at, :block_changes_at, :last_synced_at, :next_sync_at,
|
55
|
+
:activated_at, :restrictions, :cloud_licensing_enabled, :auto_renew_enabled,
|
56
|
+
:seat_reconciliation_enabled, :usage_ping_required_metrics_enabled,
|
57
|
+
:generated_from_customers_dot
|
56
58
|
|
57
59
|
alias_method :issued_at, :starts_at
|
58
60
|
alias_method :issued_at=, :starts_at=
|
@@ -62,15 +64,29 @@ module Gitlab
|
|
62
64
|
end
|
63
65
|
|
64
66
|
def valid?
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
if !licensee || !licensee.is_a?(Hash) || licensee.empty?
|
68
|
+
false
|
69
|
+
elsif !starts_at || !starts_at.is_a?(Date)
|
70
|
+
false
|
71
|
+
elsif expires_at && !expires_at.is_a?(Date)
|
72
|
+
false
|
73
|
+
elsif notify_admins_at && !notify_admins_at.is_a?(Date)
|
74
|
+
false
|
75
|
+
elsif notify_users_at && !notify_users_at.is_a?(Date)
|
76
|
+
false
|
77
|
+
elsif block_changes_at && !block_changes_at.is_a?(Date)
|
78
|
+
false
|
79
|
+
elsif last_synced_at && !last_synced_at.is_a?(DateTime)
|
80
|
+
false
|
81
|
+
elsif next_sync_at && !next_sync_at.is_a?(DateTime)
|
82
|
+
false
|
83
|
+
elsif activated_at && !activated_at.is_a?(DateTime)
|
84
|
+
false
|
85
|
+
elsif restrictions && !restrictions.is_a?(Hash)
|
86
|
+
false
|
87
|
+
else
|
88
|
+
true
|
89
|
+
end
|
74
90
|
end
|
75
91
|
|
76
92
|
def validate!
|
@@ -93,6 +109,14 @@ module Gitlab
|
|
93
109
|
block_changes_at
|
94
110
|
end
|
95
111
|
|
112
|
+
def will_sync?
|
113
|
+
next_sync_at
|
114
|
+
end
|
115
|
+
|
116
|
+
def activated?
|
117
|
+
activated_at
|
118
|
+
end
|
119
|
+
|
96
120
|
def expired?
|
97
121
|
will_expire? && Date.today >= expires_at
|
98
122
|
end
|
@@ -109,6 +133,26 @@ module Gitlab
|
|
109
133
|
will_block_changes? && Date.today >= block_changes_at
|
110
134
|
end
|
111
135
|
|
136
|
+
def cloud_licensing?
|
137
|
+
cloud_licensing_enabled == true
|
138
|
+
end
|
139
|
+
|
140
|
+
def auto_renew?
|
141
|
+
auto_renew_enabled == true
|
142
|
+
end
|
143
|
+
|
144
|
+
def seat_reconciliation?
|
145
|
+
seat_reconciliation_enabled == true
|
146
|
+
end
|
147
|
+
|
148
|
+
def usage_ping_required_metrics?
|
149
|
+
usage_ping_required_metrics_enabled == true
|
150
|
+
end
|
151
|
+
|
152
|
+
def generated_from_customers_dot?
|
153
|
+
generated_from_customers_dot == true
|
154
|
+
end
|
155
|
+
|
112
156
|
def restricted?(key = nil)
|
113
157
|
if key
|
114
158
|
restricted? && restrictions.has_key?(key)
|
@@ -120,19 +164,30 @@ module Gitlab
|
|
120
164
|
def attributes
|
121
165
|
hash = {}
|
122
166
|
|
123
|
-
hash['version']
|
124
|
-
hash['licensee']
|
167
|
+
hash['version'] = version
|
168
|
+
hash['licensee'] = licensee
|
125
169
|
|
126
170
|
# `issued_at` is the legacy name for starts_at.
|
127
171
|
# TODO: Move to starts_at in a next version.
|
128
|
-
hash['issued_at']
|
129
|
-
hash['expires_at']
|
172
|
+
hash['issued_at'] = starts_at
|
173
|
+
hash['expires_at'] = expires_at if will_expire?
|
130
174
|
|
131
175
|
hash['notify_admins_at'] = notify_admins_at if will_notify_admins?
|
132
|
-
hash['notify_users_at']
|
176
|
+
hash['notify_users_at'] = notify_users_at if will_notify_users?
|
133
177
|
hash['block_changes_at'] = block_changes_at if will_block_changes?
|
134
178
|
|
135
|
-
hash['
|
179
|
+
hash['next_sync_at'] = next_sync_at if will_sync?
|
180
|
+
hash['last_synced_at'] = last_synced_at if will_sync?
|
181
|
+
hash['activated_at'] = activated_at if activated?
|
182
|
+
|
183
|
+
hash['cloud_licensing_enabled'] = cloud_licensing?
|
184
|
+
hash['auto_renew_enabled'] = auto_renew?
|
185
|
+
hash['seat_reconciliation_enabled'] = seat_reconciliation?
|
186
|
+
hash['usage_ping_required_metrics_enabled'] = usage_ping_required_metrics?
|
187
|
+
|
188
|
+
hash['generated_from_customers_dot'] = generated_from_customers_dot?
|
189
|
+
|
190
|
+
hash['restrictions'] = restrictions if restricted?
|
136
191
|
|
137
192
|
hash
|
138
193
|
end
|
@@ -165,13 +220,22 @@ module Gitlab
|
|
165
220
|
|
166
221
|
# `issued_at` is the legacy name for starts_at.
|
167
222
|
# TODO: Move to starts_at in a next version.
|
168
|
-
%w[issued_at expires_at notify_admins_at notify_users_at block_changes_at].each do |
|
169
|
-
|
170
|
-
|
223
|
+
%w[issued_at expires_at notify_admins_at notify_users_at block_changes_at].each do |attr_name|
|
224
|
+
set_date_attribute(attr_name, attributes[attr_name])
|
225
|
+
end
|
171
226
|
|
172
|
-
|
227
|
+
%w[last_synced_at next_sync_at activated_at].each do |attr_name|
|
228
|
+
set_datetime_attribute(attr_name, attributes[attr_name])
|
229
|
+
end
|
173
230
|
|
174
|
-
|
231
|
+
%w[
|
232
|
+
cloud_licensing_enabled
|
233
|
+
auto_renew_enabled
|
234
|
+
seat_reconciliation_enabled
|
235
|
+
usage_ping_required_metrics_enabled
|
236
|
+
generated_from_customers_dot
|
237
|
+
].each do |attr_name|
|
238
|
+
public_send("#{attr_name}=", attributes[attr_name] == true)
|
175
239
|
end
|
176
240
|
|
177
241
|
restrictions = attributes['restrictions']
|
@@ -180,5 +244,17 @@ module Gitlab
|
|
180
244
|
@restrictions = restrictions
|
181
245
|
end
|
182
246
|
end
|
247
|
+
|
248
|
+
def set_date_attribute(attr_name, value, date_class = Date)
|
249
|
+
value = date_class.parse(value) rescue nil if value.is_a?(String)
|
250
|
+
|
251
|
+
return unless value
|
252
|
+
|
253
|
+
public_send("#{attr_name}=", value)
|
254
|
+
end
|
255
|
+
|
256
|
+
def set_datetime_attribute(attr_name, value)
|
257
|
+
set_date_attribute(attr_name, value, DateTime)
|
258
|
+
end
|
183
259
|
end
|
184
260
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-license
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Douwe Maan
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-05-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|