gitlab-license 1.3.1 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc45d84ba41ec6f999cd4569cdf27b7acaf2476cf87c35e4121369633e1d3251
4
- data.tar.gz: 5076ad7c092c002fbf727b8c16fefc41aeb836e1a150f82d311dd3e5b43cac25
3
+ metadata.gz: 1f9153bcc9df80fb7bcc879d15ae1e21709cec7a352ffd5c0c4de2ae082473d6
4
+ data.tar.gz: a36810ea464918c2f25bb40ebfe877b8561131bebfbf1e0d9530f1270f5f2816
5
5
  SHA512:
6
- metadata.gz: ab4289143609c6f7d9a225d626b8a8c939e734b8eb39105a1994898b63854416ce2ab5b74ee1cc0dcbaee75c6eec28d5fe2a09a3f638ce08fa4b45b29b9af642
7
- data.tar.gz: 9b1e46528d6d2309d40dfba3408fbff1e1edc93b5437ea7b354b08573eb0331a3dcb039b0bf996103a713e3e1470abfadf265c0435b2d33e567af07aa52fc71d
6
+ metadata.gz: b37464c9ce48c030aebf3ca982bc2d4831367e0169e09c76d58e152124d6ed63202dd284e63b13c86f6eb7651cc0692db8685cc29a9bf44409167a45ce3cf722
7
+ data.tar.gz: 935474c12b21840724ae4ed064f6db461777751dae4d7454917b9ada0b93eb80138f4d678ba3b48efb6ed946da38aa11422adf5a4eadef024d3981102ec5b2cf
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  class License
3
- VERSION = '1.3.1'.freeze
3
+ VERSION = '2.1.0'.freeze
4
4
  end
5
5
  end
@@ -51,8 +51,10 @@ module Gitlab
51
51
 
52
52
  attr_reader :version
53
53
  attr_accessor :licensee, :starts_at, :expires_at, :notify_admins_at,
54
- :notify_users_at, :block_changes_at, :type, :last_synced_at,
55
- :next_sync_at, :restrictions
54
+ :notify_users_at, :block_changes_at, :last_synced_at, :next_sync_at,
55
+ :activated_at, :restrictions, :cloud_licensing_enabled,
56
+ :offline_cloud_licensing_enabled, :auto_renew_enabled, :seat_reconciliation_enabled,
57
+ :operational_metrics_enabled, :generated_from_customers_dot
56
58
 
57
59
  alias_method :issued_at, :starts_at
58
60
  alias_method :issued_at=, :starts_at=
@@ -78,10 +80,12 @@ module Gitlab
78
80
  false
79
81
  elsif next_sync_at && !next_sync_at.is_a?(DateTime)
80
82
  false
81
- elsif type && type != 'cloud'
83
+ elsif activated_at && !activated_at.is_a?(DateTime)
82
84
  false
83
85
  elsif restrictions && !restrictions.is_a?(Hash)
84
86
  false
87
+ elsif !cloud_licensing? && offline_cloud_licensing?
88
+ false
85
89
  else
86
90
  true
87
91
  end
@@ -111,6 +115,10 @@ module Gitlab
111
115
  next_sync_at
112
116
  end
113
117
 
118
+ def activated?
119
+ activated_at
120
+ end
121
+
114
122
  def expired?
115
123
  will_expire? && Date.today >= expires_at
116
124
  end
@@ -127,6 +135,30 @@ module Gitlab
127
135
  will_block_changes? && Date.today >= block_changes_at
128
136
  end
129
137
 
138
+ def cloud_licensing?
139
+ cloud_licensing_enabled == true
140
+ end
141
+
142
+ def offline_cloud_licensing?
143
+ offline_cloud_licensing_enabled == true
144
+ end
145
+
146
+ def auto_renew?
147
+ auto_renew_enabled == true
148
+ end
149
+
150
+ def seat_reconciliation?
151
+ seat_reconciliation_enabled == true
152
+ end
153
+
154
+ def operational_metrics?
155
+ operational_metrics_enabled == true
156
+ end
157
+
158
+ def generated_from_customers_dot?
159
+ generated_from_customers_dot == true
160
+ end
161
+
130
162
  def restricted?(key = nil)
131
163
  if key
132
164
  restricted? && restrictions.has_key?(key)
@@ -152,7 +184,15 @@ module Gitlab
152
184
 
153
185
  hash['next_sync_at'] = next_sync_at if will_sync?
154
186
  hash['last_synced_at'] = last_synced_at if will_sync?
155
- hash['type'] = type
187
+ hash['activated_at'] = activated_at if activated?
188
+
189
+ hash['cloud_licensing_enabled'] = cloud_licensing?
190
+ hash['offline_cloud_licensing_enabled'] = offline_cloud_licensing?
191
+ hash['auto_renew_enabled'] = auto_renew?
192
+ hash['seat_reconciliation_enabled'] = seat_reconciliation?
193
+ hash['operational_metrics_enabled'] = operational_metrics?
194
+
195
+ hash['generated_from_customers_dot'] = generated_from_customers_dot?
156
196
 
157
197
  hash['restrictions'] = restrictions if restricted?
158
198
 
@@ -176,7 +216,7 @@ module Gitlab
176
216
  private
177
217
 
178
218
  def load_attributes(attributes)
179
- attributes = Hash[attributes.map { |k, v| [k.to_s, v] }]
219
+ attributes = attributes.transform_keys(&:to_s)
180
220
 
181
221
  version = attributes['version'] || 1
182
222
  raise ArgumentError, 'Version is too new' unless version && version == 1
@@ -184,7 +224,6 @@ module Gitlab
184
224
  @version = version
185
225
 
186
226
  @licensee = attributes['licensee']
187
- @type = attributes['type']
188
227
 
189
228
  # `issued_at` is the legacy name for starts_at.
190
229
  # TODO: Move to starts_at in a next version.
@@ -192,13 +231,24 @@ module Gitlab
192
231
  set_date_attribute(attr_name, attributes[attr_name])
193
232
  end
194
233
 
195
- %w[last_synced_at next_sync_at].each do |attr_name|
234
+ %w[last_synced_at next_sync_at activated_at].each do |attr_name|
196
235
  set_datetime_attribute(attr_name, attributes[attr_name])
197
236
  end
198
237
 
238
+ %w[
239
+ cloud_licensing_enabled
240
+ offline_cloud_licensing_enabled
241
+ auto_renew_enabled
242
+ seat_reconciliation_enabled
243
+ operational_metrics_enabled
244
+ generated_from_customers_dot
245
+ ].each do |attr_name|
246
+ public_send("#{attr_name}=", attributes[attr_name] == true)
247
+ end
248
+
199
249
  restrictions = attributes['restrictions']
200
250
  if restrictions&.is_a?(Hash)
201
- restrictions = Hash[restrictions.map { |k, v| [k.to_sym, v] }]
251
+ restrictions = restrictions.transform_keys(&:to_sym)
202
252
  @restrictions = restrictions
203
253
  end
204
254
  end
@@ -208,7 +258,7 @@ module Gitlab
208
258
 
209
259
  return unless value
210
260
 
211
- send("#{attr_name}=", value)
261
+ public_send("#{attr_name}=", value)
212
262
  end
213
263
 
214
264
  def set_datetime_attribute(attr_name, value)
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.3.1
4
+ version: 2.1.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: 2021-02-23 00:00:00.000000000 Z
13
+ date: 2022-01-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler