openproject-token 7.3.0 → 8.0.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: 8e0816b909165646bbe42b7254dab89bb0169999474ad6fb84b005d5163ae561
4
- data.tar.gz: 79c926e4432ad8d6a8f21a1d5b8fc1e7933b8a7b72d1a60a6c0cb047e093c2ae
3
+ metadata.gz: 3f48b64629de53c6fda9d9e9521c405dceb616e918943c1ea0ba63643641526c
4
+ data.tar.gz: 2d836191f2c4056e4bb15ababa929c6d8be0d8ee89a56d6e9a52bea3ce399daa
5
5
  SHA512:
6
- metadata.gz: 1dbc63100150b1d9124ba96aa7878baacf06a8394d84be7641e55103b4f79eafca193931636077bfdb76577996eacda4ff723bb9505f7b085d385863fe390b07
7
- data.tar.gz: 84d1d38f62f5e26a3a192eb963dc9bf2ad066559f0933da86756b08f51ae2bfe0f088bd9056dec07858d56935bcece8a6540e8fe2ef6b0f1717faf21e679b8f0
6
+ metadata.gz: 8126b0cf871408bd4ef7660904292b38605de41c0458bc404f28b9b1a77dfbce84696802ed6726ade0ed0c014f122cead3afe9c1ea405dd41a245bbbc9a003de
7
+ data.tar.gz: 96f52b9e421ca374d3cda809c79470bb9118f040497c73e743f63eb167f4525fea631a4afc7f69e0fecaea80c251fd47b2b7715f40079710f073248111ffc2e7
@@ -13,7 +13,7 @@ module OpenProject
13
13
  @key = key
14
14
  end
15
15
 
16
- def read(data)
16
+ def read(data) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
17
17
  unless key.public?
18
18
  raise KeyError, "Provided key is not a public key."
19
19
  end
@@ -50,6 +50,7 @@ module OpenProject
50
50
  ].freeze
51
51
 
52
52
  PREMIUM_PLAN_FEATURES = %i[
53
+ calculated_values
53
54
  customize_life_cycle
54
55
  ldap_groups
55
56
  project_list_sharing
@@ -66,15 +67,15 @@ module OpenProject
66
67
  legacy_enterprise: LEGACY_ENTERPRISE_PLAN_FEATURES,
67
68
 
68
69
  # old plan that receives new features from the given new plan name
69
- legacy_enterprise_professional: (LEGACY_ENTERPRISE_PLAN_FEATURES + PROFESSIONAL_PLAN_FEATURES).uniq,
70
- legacy_enterprise_premium: (LEGACY_ENTERPRISE_PLAN_FEATURES + PREMIUM_PLAN_FEATURES + PROFESSIONAL_PLAN_FEATURES).uniq,
70
+ legacy_enterprise_professional: LEGACY_ENTERPRISE_PLAN_FEATURES | PROFESSIONAL_PLAN_FEATURES,
71
+ legacy_enterprise_premium: LEGACY_ENTERPRISE_PLAN_FEATURES | PREMIUM_PLAN_FEATURES | PROFESSIONAL_PLAN_FEATURES,
71
72
 
72
73
  # new plans
73
74
  basic: BASIC_PLAN_FEATURES,
74
- professional: PROFESSIONAL_PLAN_FEATURES + BASIC_PLAN_FEATURES,
75
- premium: PREMIUM_PLAN_FEATURES + PROFESSIONAL_PLAN_FEATURES + BASIC_PLAN_FEATURES,
76
- corporate: CORPORATE_PLAN_FEATURES + PREMIUM_PLAN_FEATURES + PROFESSIONAL_PLAN_FEATURES + BASIC_PLAN_FEATURES
77
- }.freeze
75
+ professional: PROFESSIONAL_PLAN_FEATURES | BASIC_PLAN_FEATURES,
76
+ premium: PREMIUM_PLAN_FEATURES | PROFESSIONAL_PLAN_FEATURES | BASIC_PLAN_FEATURES,
77
+ corporate: CORPORATE_PLAN_FEATURES | PREMIUM_PLAN_FEATURES | PROFESSIONAL_PLAN_FEATURES | BASIC_PLAN_FEATURES
78
+ }.transform_values(&:to_set).freeze
78
79
 
79
80
  # Current plan names, sorted by inheritance
80
81
  ACTIVE_PLAN_NAMES = %i[basic professional premium corporate].freeze
@@ -85,6 +86,13 @@ module OpenProject
85
86
  # All available plan names
86
87
  AVAILABLE_PLAN_NAMES = LEGACY_PLAN_NAMES + ACTIVE_PLAN_NAMES
87
88
 
89
+ # Mapping of every feature to first active plan having it
90
+ LOWEST_PLAN_FOR_FEATURE = ACTIVE_PLAN_NAMES.each_with_object({}) do |name, map|
91
+ FEATURES_PER_PLAN[name].each do |feature|
92
+ map[feature] ||= name
93
+ end
94
+ end
95
+
88
96
  # default plan that is assigned to a token if no plan is given (especially legacy tokens)
89
97
  DEFAULT_PLAN = :legacy_enterprise
90
98
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OpenProject
4
4
  class Token
5
- VERSION = "7.3.0"
5
+ VERSION = "8.0.0"
6
6
  end
7
7
  end
@@ -49,9 +49,7 @@ module OpenProject
49
49
  end
50
50
 
51
51
  def lowest_plan_for(feature)
52
- OpenProject::Token::ACTIVE_PLAN_NAMES.detect do |plan|
53
- OpenProject::Token::FEATURES_PER_PLAN[plan].include?(feature)
54
- end
52
+ LOWEST_PLAN_FOR_FEATURE[feature]
55
53
  end
56
54
  end
57
55
 
@@ -115,12 +113,12 @@ module OpenProject
115
113
  end
116
114
 
117
115
  def available_features
118
- return @available_features if defined?(@available_features)
119
-
120
- relevant_features = OpenProject::Token::FEATURES_PER_PLAN[plan] || []
121
- additional_features = features || []
116
+ @available_features ||= begin
117
+ relevant_features = OpenProject::Token::FEATURES_PER_PLAN[plan] || []
118
+ additional_features = features || []
122
119
 
123
- @available_features = (relevant_features + additional_features).uniq
120
+ relevant_features | additional_features
121
+ end
124
122
  end
125
123
 
126
124
  ##
@@ -205,30 +203,31 @@ module OpenProject
205
203
  end
206
204
  end
207
205
 
208
- def attributes
209
- hash = {}
210
-
211
- hash["version"] = version
212
- hash["subscriber"] = subscriber
213
- hash["mail"] = mail
214
- hash["company"] = company
215
- hash["domain"] = domain
216
- hash["validate_domain"] = validate_domain
217
- hash["plan"] = plan
206
+ def attributes # rubocop:disable Metrics/AbcSize
207
+ hash = {
208
+ "version" => version,
209
+ "subscriber" => subscriber,
210
+ "mail" => mail,
211
+ "company" => company,
212
+ "domain" => domain,
213
+ "validate_domain" => validate_domain,
214
+ "plan" => plan,
215
+ "issued_at" => issued_at,
216
+ "starts_at" => starts_at,
217
+ "trial" => trial,
218
+ "features" => features
219
+ }
218
220
 
219
- hash["issued_at"] = issued_at
220
- hash["starts_at"] = starts_at
221
- hash["expires_at"] = expires_at if will_expire?
222
- hash["reprieve_days"] = reprieve_days if will_expire?
223
-
224
- hash["trial"] = trial
221
+ if will_expire?
222
+ hash["expires_at"] = expires_at
223
+ hash["reprieve_days"] = reprieve_days
224
+ end
225
225
 
226
226
  hash["notify_admins_at"] = notify_admins_at if will_notify_admins?
227
227
  hash["notify_users_at"] = notify_users_at if will_notify_users?
228
228
  hash["block_changes_at"] = block_changes_at if will_block_changes?
229
229
 
230
230
  hash["restrictions"] = restrictions if restricted?
231
- hash["features"] = features
232
231
 
233
232
  hash
234
233
  end
@@ -251,7 +250,7 @@ module OpenProject
251
250
 
252
251
  private
253
252
 
254
- def load_attributes(attributes)
253
+ def load_attributes(attributes) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
255
254
  attributes = attributes.transform_keys(&:to_s)
256
255
 
257
256
  @version = read_version attributes
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openproject-token
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.0
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenProject GmbH
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-07-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activemodel
@@ -48,14 +48,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
48
  requirements:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
- version: 3.4.2
51
+ version: 3.4.5
52
52
  required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  requirements: []
58
- rubygems_version: 3.6.2
58
+ rubygems_version: 3.6.9
59
59
  specification_version: 4
60
60
  summary: OpenProject EE token reader
61
61
  test_files: []