uc3-dmp-rds 0.0.24 → 0.0.26

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: 604c79df5be49af7962a127336f3218c425eec327437a457856a485c23a552ce
4
- data.tar.gz: d44673cf381d1c9786eace556ca14a38baa7f721ad3219eec5402e6950565fa0
3
+ metadata.gz: bd9a51c00223257f3aa00133b904f00e0c8cede3f166d9521accf5759f928b1a
4
+ data.tar.gz: 4ca625aa165517ca2f8dd3dd9e4ee14a7188ed44bf65f13dc5f6be65afcd31bd
5
5
  SHA512:
6
- metadata.gz: 31e6c505b927e29dde9fb672c2a5ac7408eff714595ad8e96c510e016e8493d7f1f59cd9140de6ffea8274ef103cea2121f295fa5ff6cdd5c90e6f40ea3611e9
7
- data.tar.gz: b65f2969d658f2fdacf796f6f4c009153271900ccd3bed34e7c26c604ad69b1af44435f0f6caa39b5f2c72ac36033786380a6ce3c1e264ac2f759cfa3ee449de
6
+ metadata.gz: 9b647640ad6a581e0721cbdd43cd0c6b033c45578ee3e6bb2d44f2c3537d896a5994146f4d995bdb67769a5ff13bfbd38eec29a38124363fd0046d9108829c52
7
+ data.tar.gz: 319c3c1b995efe7089852318080e6321658aab5bc9099c3c6939e5ca5cb609275f3944e1335ed36794cc16e172049e20d0c4071a71868f06dbc47ac38cefe449
@@ -36,8 +36,8 @@ module Uc3DmpRds
36
36
  host: ENV.fetch('DATABASE_HOST', nil),
37
37
  port: ENV.fetch('DATABASE_PORT', nil),
38
38
  database: ENV.fetch('DATABASE_NAME', nil),
39
- username: username,
40
- password: password,
39
+ username:,
40
+ password:,
41
41
  encoding: 'utf8mb4'
42
42
  )
43
43
  !connection.nil?
@@ -50,7 +50,7 @@ module Uc3DmpRds
50
50
  def execute_query(sql:, **params)
51
51
  return [] unless sql.is_a?(String) && !sql.strip.empty? && (params.nil? || params.is_a?(Hash))
52
52
  # Verify that all of the kewords are accounted for and that values were supplied
53
- raise AdapterError, MSG_KEYWORDS_INVALID unless _verify_params(sql: sql, params: params)
53
+ raise AdapterError, MSG_KEYWORDS_INVALID unless _verify_params(sql:, params:)
54
54
 
55
55
  ActiveRecord::Base.simple_execute(sql, params)
56
56
  rescue StandardError => e
@@ -20,13 +20,13 @@ module Uc3DmpRds
20
20
  def authenticate(token:)
21
21
  raise AuthenticatorError, MSG_INVALID_TOKEN if token.nil? || token.to_s.strip.empty?
22
22
 
23
- users = _query_user(token: token)
23
+ users = _query_user(token:)
24
24
  raise AuthenticatorError, MSG_INVALID_TOKEN unless users.is_a?(Array) && users.any?
25
25
 
26
26
  user = users.first
27
27
  raise AuthenticatorError, MSG_INACTIVE_USER unless user['active']
28
28
 
29
- _serialize_user(user: user)
29
+ _serialize_user(user:)
30
30
  end
31
31
 
32
32
  private
@@ -37,7 +37,7 @@ module Uc3DmpRds
37
37
 
38
38
  sql = <<~SQL.squish
39
39
  SELECT users.id, users.firstname, users.surname, users.email, users.active, i.value orcid,
40
- orgs.name org_name, ro.name ror_name, ro.ror_id,
40
+ orgs.name org_name, ro.name ror_name, ro.ror_id, users.ui_token,
41
41
  (SELECT perms.name FROM users_perms up LEFT OUTER JOIN perms ON up.perm_id = perms.id
42
42
  WHERE users.id = up.user_id AND perms.name = 'modify_templates') perm
43
43
  FROM users
@@ -50,10 +50,11 @@ module Uc3DmpRds
50
50
  AND i.identifier_scheme_id IN (SELECT sch.id FROM identifier_schemes sch WHERE sch.name = 'orcid')
51
51
  WHERE users.api_token = :token
52
52
  SQL
53
- users = ActiveRecord::Base.simple_execute(sql, token: token.to_s.strip)
53
+ ActiveRecord::Base.simple_execute(sql, token: token.to_s.strip)
54
54
  end
55
55
 
56
56
  # Convert the ActiveRecord query results into a JSON object
57
+ # rubocop:disable Metrics/AbcSize
57
58
  def _serialize_user(user:)
58
59
  return {} if user.nil? || user['email'].nil?
59
60
 
@@ -64,6 +65,7 @@ module Uc3DmpRds
64
65
  admin: !user['perm'].nil?,
65
66
  active: user.fetch('active', false)
66
67
  }
68
+ hash[:token] = user['ui_token'] unless user['ui_token'].nil?
67
69
  hash[:user_id] = { type: 'orcid', identifier: user['orcid'] } unless user['orcid'].nil?
68
70
  return hash if user['org_name'].nil?
69
71
 
@@ -71,6 +73,7 @@ module Uc3DmpRds
71
73
  hash[:affiliation][:affiliation_id] = { type: 'ror', identifier: user['ror_id'] } unless user['ror_id'].nil?
72
74
  JSON.parse(hash.to_json)
73
75
  end
76
+ # rubocop:enable Metrics/AbcSize
74
77
  end
75
78
  end
76
79
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpRds
4
- VERSION = '0.0.24'
4
+ VERSION = '0.0.26'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-rds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-01 00:00:00.000000000 Z
11
+ date: 2023-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_record_simple_execute
@@ -139,7 +139,7 @@ licenses:
139
139
  - MIT
140
140
  metadata:
141
141
  rubygems_mfa_required: 'false'
142
- post_install_message:
142
+ post_install_message:
143
143
  rdoc_options: []
144
144
  require_paths:
145
145
  - lib
@@ -147,15 +147,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - ">="
149
149
  - !ruby/object:Gem::Version
150
- version: '2.7'
150
+ version: '3.2'
151
151
  required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - ">="
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
- rubygems_version: 3.1.6
158
- signing_key:
157
+ rubygems_version: 3.4.10
158
+ signing_key:
159
159
  specification_version: 4
160
160
  summary: DMPTool gem that provides general support for accessing MySQL DB hosted on
161
161
  AWS RDS