gitlab-license 1.0.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 383fa8e8886da54f66d4e605027ff68ce9b32427d9924d659e58c3c5035e6338
4
- data.tar.gz: 502a4ea974f4299d9cd2d1a0c0a02780a79d15f56bdc8332806181227b3ef072
3
+ metadata.gz: e6aecf2ddad9be921880a1603714f79947534ede972c8f47f8b5121c96d912c1
4
+ data.tar.gz: 66b55835b29c3c9c2fdd175b31113523d616802e6a8cfa6898a98f080039760b
5
5
  SHA512:
6
- metadata.gz: a4a4f59660c0aed25f811fa584a281dac4f14cd60ebbec4fdb6ecc47e6ec31f4e35ba5ac0000b20b418761dbdaf20f1a3a2b7a221a2b91480d94f87a57a97862
7
- data.tar.gz: 29b852faadaf76f0d9064c414e954f425290b83618882a7a3bfd47b10babcd8ce7a8a76ebe8990a35688d24a3a9314f69f9a1faec1179d0c5490fde09370de01
6
+ metadata.gz: 1ca37a34899d853c22871e36f70aac9196e127ea92b6c7ef1cdda167eab9e595c9e092ae072857c343158881dad8961b2430150b3e730d2408facac6b94b1c1e
7
+ data.tar.gz: 5d77bbd654db4ad8e4e4458748d15720a3092d6085e73e06ac717b4f5fe6594f52ed517dedcc6e4c33398f3a1f419b7573578d37dae61a0f84b3543e2557383d
@@ -52,6 +52,7 @@ module Gitlab
52
52
  attr_reader :version
53
53
  attr_accessor :licensee, :starts_at, :expires_at
54
54
  attr_accessor :notify_admins_at, :notify_users_at, :block_changes_at
55
+ attr_accessor :type, :last_synced_at, :next_sync_at, :block_changes_without_sync_at
55
56
  attr_accessor :restrictions
56
57
 
57
58
  alias_method :issued_at, :starts_at
@@ -62,15 +63,31 @@ module Gitlab
62
63
  end
63
64
 
64
65
  def valid?
65
- return false if !licensee || !licensee.is_a?(Hash) || licensee.empty?
66
- return false if !starts_at || !starts_at.is_a?(Date)
67
- return false if expires_at && !expires_at.is_a?(Date)
68
- return false if notify_admins_at && !notify_admins_at.is_a?(Date)
69
- return false if notify_users_at && !notify_users_at.is_a?(Date)
70
- return false if block_changes_at && !block_changes_at.is_a?(Date)
71
- return false if restrictions && !restrictions.is_a?(Hash)
72
-
73
- true
66
+ if !licensee || !licensee.is_a?(Hash) || licensee.empty?
67
+ false
68
+ elsif !starts_at || !starts_at.is_a?(Date)
69
+ false
70
+ elsif expires_at && !expires_at.is_a?(Date)
71
+ false
72
+ elsif notify_admins_at && !notify_admins_at.is_a?(Date)
73
+ false
74
+ elsif notify_users_at && !notify_users_at.is_a?(Date)
75
+ false
76
+ elsif block_changes_at && !block_changes_at.is_a?(Date)
77
+ false
78
+ elsif last_synced_at && !last_synced_at.is_a?(DateTime)
79
+ false
80
+ elsif next_sync_at && !next_sync_at.is_a?(DateTime)
81
+ false
82
+ elsif block_changes_without_sync_at && !block_changes_without_sync_at.is_a?(Date)
83
+ false
84
+ elsif type && type != 'sync'
85
+ false
86
+ elsif restrictions && !restrictions.is_a?(Hash)
87
+ false
88
+ else
89
+ true
90
+ end
74
91
  end
75
92
 
76
93
  def validate!
@@ -93,6 +110,14 @@ module Gitlab
93
110
  block_changes_at
94
111
  end
95
112
 
113
+ def will_block_changes_without_sync?
114
+ block_changes_without_sync_at
115
+ end
116
+
117
+ def will_sync?
118
+ next_sync_at
119
+ end
120
+
96
121
  def expired?
97
122
  will_expire? && Date.today >= expires_at
98
123
  end
@@ -109,6 +134,10 @@ module Gitlab
109
134
  will_block_changes? && Date.today >= block_changes_at
110
135
  end
111
136
 
137
+ def block_changes_without_sync?
138
+ will_block_changes_without_sync? && Date.today >= block_changes_without_sync_at
139
+ end
140
+
112
141
  def restricted?(key = nil)
113
142
  if key
114
143
  restricted? && restrictions.has_key?(key)
@@ -120,19 +149,24 @@ module Gitlab
120
149
  def attributes
121
150
  hash = {}
122
151
 
123
- hash['version'] = version
124
- hash['licensee'] = licensee
152
+ hash['version'] = version
153
+ hash['licensee'] = licensee
125
154
 
126
155
  # `issued_at` is the legacy name for starts_at.
127
156
  # TODO: Move to starts_at in a next version.
128
- hash['issued_at'] = starts_at
129
- hash['expires_at'] = expires_at if will_expire?
157
+ hash['issued_at'] = starts_at
158
+ hash['expires_at'] = expires_at if will_expire?
130
159
 
131
160
  hash['notify_admins_at'] = notify_admins_at if will_notify_admins?
132
- hash['notify_users_at'] = notify_users_at if will_notify_users?
161
+ hash['notify_users_at'] = notify_users_at if will_notify_users?
133
162
  hash['block_changes_at'] = block_changes_at if will_block_changes?
134
163
 
135
- hash['restrictions'] = restrictions if restricted?
164
+ hash['block_changes_without_sync_at'] = block_changes_without_sync_at if will_block_changes_without_sync?
165
+ hash['next_sync_at'] = next_sync_at if will_sync?
166
+ hash['last_synced_at'] = last_synced_at if will_sync?
167
+ hash['type'] = type
168
+
169
+ hash['restrictions'] = restrictions if restricted?
136
170
 
137
171
  hash
138
172
  end
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  class License
3
- VERSION = '1.0.1'.freeze
3
+ VERSION = '1.2.0'.freeze
4
4
  end
5
5
  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.1
4
+ version: 1.2.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: 2020-07-30 00:00:00.000000000 Z
13
+ date: 2020-11-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler