dina 0.6.0.0 → 0.6.1.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: a04c4026773ff1a9e6b972dde877db7db2ce24f266a6eedec9c557201b913836
4
- data.tar.gz: 8482b240897f73716a649e69c7d616cc1be6e66fd2d0f5237d2f4ef71f16af48
3
+ metadata.gz: fce6aa7545f2fe1bb7a340fd5ef64fb85ed56e50ad12b970a37cad5d0ba3bfc2
4
+ data.tar.gz: 532c2e30e916fe27a13b3739efccd5adb770f12e4b6706f2fed7eec4276b80b8
5
5
  SHA512:
6
- metadata.gz: 1ee8a029d86598ae2f8e63afe9713aad2707d19347d3e305c800a93e74a5955adff10a191e37fb5615b75ba994c07d0db72f028b002e35096ed36c4854095dca
7
- data.tar.gz: 41640031cd2cebbb32a624866b1cd44ed7fac03b8e4b8854c9a94d1276b5a7f91f70b7d467f696d1034b998330cdeeb8577f33d1c1d5483aee0206096c12faf2
6
+ metadata.gz: 2e7ff2cd1b927195c3c17d7986e31bc60fad738dff9f7198029af2e822673b05d8ea5748db0e7aeb330fd1cd59366a5e75870556fd7cf7b74d8160b8558fa79b
7
+ data.tar.gz: 95f10aa0889f8eb03b782925458398ba1ed7c066df7cb5ff94c630710170a1fd567381334207242381d6e4736cb960c4fd4edad29b047ba7328ff86aa40ae5b1
@@ -63,7 +63,8 @@ module Dina
63
63
 
64
64
  # Flushes instance variables from memory
65
65
  # but token store file content remains intact
66
- def self.flush
66
+ def self.flush_variables
67
+ @token = nil
67
68
  @token_store_file = nil
68
69
  @user = nil
69
70
  @password = nil
@@ -74,11 +75,17 @@ module Dina
74
75
  Keycloak.realm = nil
75
76
  end
76
77
 
77
- # Replaces content of token store file with default values
78
+ # Saves default values in token store file
78
79
  def self.flush_token
79
80
  create_empty_token
80
81
  end
81
82
 
83
+ # Flush instance variables and save default values in token store file
84
+ def self.flush
85
+ flush_variables
86
+ flush_token
87
+ end
88
+
82
89
  class << self
83
90
  attr_accessor :endpoint_url
84
91
 
@@ -86,7 +93,7 @@ module Dina
86
93
 
87
94
  def access_token
88
95
  begin
89
- read_token[@server_name.to_sym][:access_token]
96
+ token[@server_name.to_sym][:access_token]
90
97
  rescue
91
98
  raise TokenStoreContentInvalid
92
99
  end
@@ -94,7 +101,7 @@ module Dina
94
101
 
95
102
  def refresh_token
96
103
  begin
97
- read_token[@server_name.to_sym][:refresh_token]
104
+ token[@server_name.to_sym][:refresh_token]
98
105
  rescue
99
106
  raise TokenStoreContentInvalid
100
107
  end
@@ -102,7 +109,7 @@ module Dina
102
109
 
103
110
  def auth_expiry
104
111
  begin
105
- read_token[@server_name.to_sym][:auth_expiry]
112
+ token[@server_name.to_sym][:auth_expiry]
106
113
  rescue
107
114
  raise TokenStoreContentInvalid
108
115
  end
@@ -137,28 +144,33 @@ module Dina
137
144
  end
138
145
  end
139
146
 
140
- def read_token
141
- JSON.parse(::File.read(@token_store_file), symbolize_names: true)
147
+ def token
148
+ @token ||= JSON.parse(::File.read(@token_store_file), symbolize_names: true)
142
149
  end
143
150
 
144
151
  def create_empty_token
145
- data_hash = {}
146
- data_hash[@server_name.to_sym] = {
152
+ data = {}
153
+ data[@server_name.to_sym] = {
147
154
  access_token: nil,
148
155
  refresh_token: nil,
149
156
  auth_expiry: nil
150
157
  }
151
- ::File.write(@token_store_file, JSON.dump(data_hash))
158
+ write_token(data: data)
152
159
  end
153
160
 
154
161
  def save_token(access_token:, refresh_token:, auth_expiry:)
155
- data_hash = JSON.parse(::File.read(@token_store_file), symbolize_names: true) rescue {}
156
- data_hash[@server_name.to_sym] = {
162
+ data = JSON.parse(::File.read(@token_store_file), symbolize_names: true) rescue {}
163
+ data[@server_name.to_sym] = {
157
164
  access_token: access_token,
158
165
  refresh_token: refresh_token,
159
166
  auth_expiry: auth_expiry
160
167
  }
161
- ::File.write(@token_store_file, JSON.dump(data_hash))
168
+ write_token(data: data)
169
+ end
170
+
171
+ def write_token(data:)
172
+ ::File.write(@token_store_file, JSON.dump(data))
173
+ @token = data
162
174
  end
163
175
 
164
176
  end
data/lib/dina/version.rb CHANGED
@@ -3,7 +3,7 @@ module Dina
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 6
6
- PATCH = 0
6
+ PATCH = 1
7
7
  BUILD = 0
8
8
 
9
9
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.0
4
+ version: 0.6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David P. Shorthouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-30 00:00:00.000000000 Z
11
+ date: 2022-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client