dina 0.5.3.0 → 0.5.5.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: f73e6c200e682c91492c0f50854dc73a9fac3537a65eb12a5fe1d974b72adf09
4
- data.tar.gz: 4fa9641b7ff96f95c88b30b1e6857aa9e02dc6ae8639efd84aa034a0908fa182
3
+ metadata.gz: 2219751eeaf3e31b3b3206c5ca7b87a9e724662c3ed64c0781f8c35668b365cf
4
+ data.tar.gz: c951a685a472e4486a8847d1a2bf415e4ff39c540e80b9b4e50da72d073e69c4
5
5
  SHA512:
6
- metadata.gz: 394bac789e4e01efe38447edb8042ae9f6dd3510b1a97aa06f6545f07a9133466a2afbcae3fc0e9d90fa053b8ba0f3c651b46dabb7f7dd702566870d9e5e1787
7
- data.tar.gz: fc3d1f5e15028d8724ff1a37bc6816f28cbe639e79c67e9d75dd8d7dfa9e70f9d017c14cb31c79184f8f0a135d23750548ad98e1127d00fd2ea1d45fff8b97a1
6
+ metadata.gz: 7fe97ac48169a94af0b4b4d8dc5fe380b9b7aca9ac9abf656b915c428df20949f5b2bd034b681b9e23ac2e44d10635a7c64a5c947348a0f7f9f0bd6d79f5f882
7
+ data.tar.gz: 131b8bab4675a4bffec2aa7f22a2b52ef495914ad6f4203cf73866736c16ddceba2142a26e8135f3d5ad161d8618f2a151087ab73658d24799b1043fa2c399b2
@@ -46,6 +46,10 @@ module Dina
46
46
  #
47
47
  # @return [String] the Bearer token
48
48
  def self.header
49
+ if ::File.zero?(@token_store_file)
50
+ create_empty_token
51
+ end
52
+
49
53
  if access_token.nil? || refresh_token.nil?
50
54
  set_token
51
55
  end
@@ -119,6 +123,16 @@ module Dina
119
123
  JSON.parse(::File.read(@token_store_file), symbolize_names: true)
120
124
  end
121
125
 
126
+ def create_empty_token
127
+ data_hash = {}
128
+ data_hash[@server_name.to_sym] = {
129
+ access_token: nil,
130
+ refresh_token: nil,
131
+ auth_expiry: nil
132
+ }
133
+ ::File.write(@token_store_file, JSON.dump(data_hash))
134
+ end
135
+
122
136
  def save_token(access_token:, refresh_token:, auth_expiry:)
123
137
  data_hash = JSON.parse(::File.read(@token_store_file), symbolize_names: true) rescue {}
124
138
  data_hash[@server_name.to_sym] = {
@@ -28,10 +28,18 @@ module Dina
28
28
  "collection"
29
29
  end
30
30
 
31
+ # Finds a Collection object by name
32
+ #
33
+ # @param email [String] a name
34
+ # @return object [Object] a Collection object
31
35
  def self.find_by_name(name)
32
36
  where(name: name).all.first
33
37
  end
34
38
 
39
+ # Finds a Collection object by code
40
+ #
41
+ # @param code [String] a code
42
+ # @return object [Object] a Collection object
35
43
  def self.find_by_code(code)
36
44
  where(code: code).all.first
37
45
  end
@@ -15,16 +15,20 @@ module Dina
15
15
  def initialize
16
16
  end
17
17
 
18
+ def endpoint
19
+ Dina::Authentication.endpoint_url
20
+ end
21
+
18
22
  def endpoint_path
19
23
  "objectstore-api/"
20
24
  end
21
25
 
22
26
  def table_name
23
- "file/#{@group}"
27
+ "file/#{@group.downcase}"
24
28
  end
25
29
 
26
30
  def url
27
- Dina::Authentication.endpoint_url + endpoint_path + table_name
31
+ endpoint + "/" + endpoint_path + table_name
28
32
  end
29
33
 
30
34
  def file
@@ -30,7 +30,7 @@ module Dina
30
30
  begin
31
31
  response = RestClient::Request.execute(
32
32
  method: method,
33
- url: endpoint + endpoint_path + "?" + params.to_query,
33
+ url: endpoint + "/" + endpoint_path + "?" + params.to_query,
34
34
  payload: payload.to_json,
35
35
  headers: {
36
36
  accept: 'application/json',
data/lib/dina/version.rb CHANGED
@@ -3,7 +3,7 @@ module Dina
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 5
6
- PATCH = 3
6
+ PATCH = 5
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.5.3.0
4
+ version: 0.5.5.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-12 00:00:00.000000000 Z
11
+ date: 2022-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client