openproject-token 3.0.0 → 4.0.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: c70ad73f805a38cc1846b8c5b1db6492efda10e039c0d417f41577ba4aa0c50d
4
- data.tar.gz: ddc82e67199f997413a1493eef6518f238821eb5f995cf07d945b7fec95cb8b6
3
+ metadata.gz: 26f34040f3ddbd6546761e8e6e33f5081b95550d3795dccccdf86f3610952b52
4
+ data.tar.gz: d387c8130062a25183db07cbb3f43d7319836d143e3857d5271e24d99ef208eb
5
5
  SHA512:
6
- metadata.gz: abd224aeb838bac009ab74e4aa9d31c60891c4d860351c21e18d2bc52aaca39be0bbf008e304b58e842194234cf3e6070b9de2a59f6086fde577abdaaa84a773
7
- data.tar.gz: eb3bb63292374c49f3d6cf39bebeb7584c64b91835107f520d995cebb4047e3e285f83481948b209e40e3364f85be909346f362540548fbe017665c47d932b47
6
+ metadata.gz: 7cfc8e13d23e2d50c5f769ea7482f526b92ecf6a83075ca03790c3415ecf959e073f60f611c217f7546f02b080242d3075cfc32a9185d5e69749c895aa398659
7
+ data.tar.gz: bf8dd5ea2f830eeca4854560f560bcee3ccbbb6993e1d5868bf7caf40c24e0547b454e82b5aa9fde7384ac38314426cb9cac28f838197312596f6dfcf54ccc78
@@ -1,5 +1,5 @@
1
1
  module OpenProject
2
2
  class Token
3
- VERSION = "3.0.0"
3
+ VERSION = "4.0.0"
4
4
  end
5
5
  end
@@ -54,6 +54,7 @@ module OpenProject
54
54
  attr_accessor :reprieve_days
55
55
  attr_accessor :notify_admins_at, :notify_users_at, :block_changes_at
56
56
  attr_accessor :restrictions
57
+ attr_accessor :features
57
58
 
58
59
  validates_presence_of :subscriber
59
60
  validates_presence_of :mail
@@ -91,6 +92,10 @@ module OpenProject
91
92
  self.block_changes_at
92
93
  end
93
94
 
95
+ def has_feature?(name)
96
+ features && features.include?(name.to_sym)
97
+ end
98
+
94
99
  ##
95
100
  # Indicates whether or not the token has expired.
96
101
  #
@@ -134,8 +139,8 @@ module OpenProject
134
139
  end
135
140
 
136
141
  def valid_domain?(input)
137
- if domain.is_a?(Regexp)
138
- domain.match?(input)
142
+ if parsed_domain.is_a?(Regexp)
143
+ parsed_domain.match?(input)
139
144
  else
140
145
  domain == input
141
146
  end
@@ -168,6 +173,7 @@ module OpenProject
168
173
  hash["block_changes_at"] = self.block_changes_at if self.will_block_changes?
169
174
 
170
175
  hash["restrictions"] = self.restrictions if self.restricted?
176
+ hash["features"] = self.features
171
177
 
172
178
  hash
173
179
  end
@@ -182,6 +188,13 @@ module OpenProject
182
188
  raise ParseError, "Failed to load from json: #{e}"
183
189
  end
184
190
 
191
+ def parsed_domain
192
+ @parsed_domain = read_domain!(domain) unless defined?(@parsed_domain)
193
+
194
+ @parsed_domain
195
+ end
196
+
197
+
185
198
  private
186
199
 
187
200
  def load_attributes(attributes)
@@ -191,7 +204,7 @@ module OpenProject
191
204
  @subscriber = attributes["subscriber"]
192
205
  @mail = attributes["mail"]
193
206
  @company = attributes["company"]
194
- @domain = read_domain attributes["domain"]
207
+ @domain = attributes["domain"]
195
208
 
196
209
  date_attribute_keys.each do |attr|
197
210
  value = attributes[attr]
@@ -218,6 +231,11 @@ module OpenProject
218
231
  restrictions = Hash[restrictions.map { |k, v| [k.to_sym, v] }]
219
232
  @restrictions = restrictions
220
233
  end
234
+
235
+ features = attributes['features']
236
+ if features && features.is_a?(Array)
237
+ @features = features.map(&:to_sym)
238
+ end
221
239
  end
222
240
 
223
241
  ##
@@ -253,7 +271,7 @@ module OpenProject
253
271
  version
254
272
  end
255
273
 
256
- def read_domain(input)
274
+ def read_domain!(input)
257
275
  return input if input.nil? || !(input.start_with?('/') && input.end_with?('/'))
258
276
 
259
277
  # Omit the slashes of the input
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openproject-token
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenProject GmbH
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-17 00:00:00.000000000 Z
11
+ date: 2023-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -52,7 +52,21 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.5'
55
- description:
55
+ - !ruby/object:Gem::Dependency
56
+ name: debug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
56
70
  email: info@openproject.com
57
71
  executables: []
58
72
  extensions: []
@@ -69,7 +83,7 @@ homepage: https://www.openproject.org
69
83
  licenses:
70
84
  - GPL-3.0
71
85
  metadata: {}
72
- post_install_message:
86
+ post_install_message:
73
87
  rdoc_options: []
74
88
  require_paths:
75
89
  - lib
@@ -84,8 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
98
  - !ruby/object:Gem::Version
85
99
  version: '0'
86
100
  requirements: []
87
- rubygems_version: 3.3.7
88
- signing_key:
101
+ rubygems_version: 3.4.6
102
+ signing_key:
89
103
  specification_version: 4
90
104
  summary: OpenProject EE token reader
91
105
  test_files: []